Re: select trigger and warnings

[prev] [thread] [next] [Date index for 2004/11/19]

From: Carlos Vicente
Subject: Re: select trigger and warnings
Date: 00:34 on 19 Nov 2004
Just to clarify that in the example code below, the string "Vlan" is
appended *twice* to the description field.  The original value was just
the number.

If this is not a bug, then I need another way to inflate a value each
time it is fetched, other than calling the 'select' trigger.  I'm still
clueless. 

Thanks,

cv

	From: 	Carlos Vicente <cvicente@xxxxxxxxxxxxxxxx.xxxxxxx.xxx>
To: 	cdbi-talk <cdbi-talk@xxxxxx.xxxxx.xxx>
Subject: 	Re: select trigger and warnings
Date: 	17 Nov 2004 17:49:21 -0800	

Thanks.  I've modified the triggers to call $self->_attribute_store. 
The 'before_create' trigger works fine.  The problem now is that I the
'select' trigger seems to be called twice! (I think one for 'construct'
and one for '_flesh'), thus the values returned to the app are not
correct.  I added another trigger with a test method to illustrate:

In MyPackage::DBI:

sub test {
   my $self = shift;
    my $val = "Vlan ". $self->description;  
    $self->_attribute_store( description => $val );    
}
Vlan->add_trigger( select => \&test );

In test.pl:
...
foreach my $o (Vlan->retrieve_all){
    print " desc: ", $o->description, "\n"; 
}
# perl test.pl
 desc: Vlan Vlan 1
 desc: Vlan Vlan 60
 desc: Vlan Vlan 2060
 desc: Vlan Vlan 170
 desc: Vlan Vlan 190
 desc: Vlan Vlan 252
 desc: Vlan Vlan 182
 desc: Vlan Vlan 194
 desc: Vlan Vlan 192
 desc: Vlan Vlan 198
 desc: Vlan Vlan 188
 desc: Vlan Vlan 168
 desc: Vlan Vlan 184
 desc: Vlan Vlan 172
 desc: Vlan Vlan 116
 desc: Vlan Vlan 186
 desc: Vlan Vlan 144
 desc: Vlan Vlan 196

Am I doing something wrong?  Or is this a bug?

Again, thanks for your help.

cv

select trigger and warnings
Carlos Vicente 18:43 on 16 Nov 2004

Re: select trigger and warnings
Tony Bowden 11:01 on 17 Nov 2004

Re: select trigger and warnings
Carlos Vicente 01:49 on 18 Nov 2004

Re: select trigger and warnings
Carlos Vicente 00:34 on 19 Nov 2004

Generated at 11:34 on 01 Dec 2004 by mariachi v0.52