Re: [CDBI] new reserved words in 3.0.11?

[prev] [thread] [next] [Date index for 2005/11/04]

From: William Ross
Subject: Re: [CDBI] new reserved words in 3.0.11?
Date: 12:36 on 04 Nov 2005
On 4 Nov 2005, at 11:36, Patrik Wallstrom wrote:

> Did anybody understand what I meant in this mail?
>
> With the example objects below in version 3.0.11, I can't access
> method $object->name or $object->type, only those accessors which
> actually changed name in accessor_name_for.

I think this may be because you're changing the accessor name (by  
lowercasing it) but not the mutator name. If they differ, cdbi will  
create separate get and set methods rather than a single mutator  
method. This comment is in the code:

   # Make a set of accessors for each of a list of columns. We construct
   # the method name by calling accessor_name_for() and  
mutator_name_for()
   # with the normalized column name.

   # mutator name will be the same as accessor name unless you  
override it.

   # If both the accessor and mutator are to have the same method name,
   # (which will always be true unless you override mutator_name_for), a
   # read-write method is constructed for it. If they differ we  
create both
   # a read-only accessor and a write-only mutator.

but I don't think it's exactly right. the accessor and mutator names  
are set when the column object is constructed, then  
_mk_column_accessors calls $col->accessor($class->accessor_name_for 
($col)), which in your case *will* mean that the accessor name  
changes. The comment suggests that this will only happen if you set  
the mutator name, which is wrong. I think Tony must have changed the  
order of events when he factored out the column code.

incidentally, your lc($column) is likely redundant anyway: $column is  
an object and stringifies to a lowercased version of its name. As a  
test, I'd suggest that you either omit the lc($column) or add a  
simple mutator_name_for method:

   sub mutator_name_for {
     return lc(shift);
   }

and see if that makes any difference.

best

will





>
> On Thu, 03 Nov 2005, Patrik Wallstrom wrote:
>
>> On Thu, 03 Nov 2005, Christopher H. Laco wrote:
>>
>>> Patrik Wallstrom wrote:
>>>> Is the word "type" a new reserved word in the 3 series of  
>>>> Class::DBI?
>>>>
>>> I hope not. I've to a field named type littered throughout Handel.
>>> So far, I've only tested  up to 3.0.10...
>>
>> When I look at it a bit closer it seems like the new  
>> accessor_name_for
>> does something I am not used to. There are some more fields that does
>> not show up at all. At least if I don't change the accessor name for
>> that field other than lowercase it like this:
>>
>>
>> sub accessor_name_for
>> {
>>     my($class,$column) = @_;
>>     $column =~ s/^(parameter_name|person)_id$/$1/i;
>>     return lc $column;
>> }
>>
>> this is the object...
>>
>> $VAR1 = bless( {
>>                  'person_id' => undef,
>>                  'name' => 'example.scalar',
>>                  'type' => '1',
>>                  'from_date' => '0000-00-00 00:00:00',
>>                  'parameter_name_id' => '1',
>>                  'to_date' => undef
>>                }, 'SECore::DB::Parameter' );
>>
>> ...and this is the Columns for this object:
>>
>> $VAR2 = bless( {
>>                  'name' => 'NAME',
>>                  '_groups' => {
>>                                 'Essential' => 1
>>                               },
>>                  'mutator' => 'NAME',
>>                  'placeholder' => '?',
>>                  'accessor' => 'name'
>>                }, 'Class::DBI::Column' );
>>
>> But ... I don't seem to have an accessor (that I can access anyway)
>> with the name "name" (or "type" in my previous question). I have only
>> got accessors for the has_a and has_many in the above
>> accessor_name_for. I am very confused.
>>
>
> -- 
> patrik_wallstrom->foodfight->pawal@xxxxx.xxx->+46-733173956
> _______________________________________________
> ClassDBI mailing list
> ClassDBI@xxxxx.xxxxxxxxxxxxxxxx.xxx
> http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi


_______________________________________________
ClassDBI mailing list
ClassDBI@xxxxx.xxxxxxxxxxxxxxxx.xxx
http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi

(message missing)

[CDBI] new reserved words in 3.0.11?
Patrik Wallstrom 12:33 on 03 Nov 2005

Re: [CDBI] new reserved words in 3.0.11?
Christopher H. Laco 13:43 on 03 Nov 2005

Re: [CDBI] new reserved words in 3.0.11?
Patrik Wallstrom 13:59 on 03 Nov 2005

Re: [CDBI] new reserved words in 3.0.11?
Patrik Wallstrom 11:36 on 04 Nov 2005

Re: [CDBI] new reserved words in 3.0.11?
William Ross 12:36 on 04 Nov 2005

Re: [CDBI] new reserved words in 3.0.11?
William Ross 12:56 on 04 Nov 2005

Re: [CDBI] new reserved words in 3.0.11?
Dave Howorth 13:10 on 04 Nov 2005

Re: [CDBI] new reserved words in 3.0.11?
Jay Strauss 13:31 on 04 Nov 2005

Re: [CDBI] new reserved words in 3.0.11?
Dave Howorth 13:47 on 04 Nov 2005

Re: [CDBI] new reserved words in 3.0.11?
Matt S Trout 13:58 on 03 Nov 2005

Re: [CDBI] new reserved words in 3.0.11?
Dave Howorth 13:14 on 04 Nov 2005

Re: [CDBI] new reserved words in 3.0.11?
William Ross 13:31 on 04 Nov 2005

Re: [CDBI] new reserved words in 3.0.11?
William Ross 13:28 on 04 Nov 2005

Generated at 20:55 on 09 Nov 2005 by mariachi v0.52