[CDBI] Weird things with has_a and lazy population

Dmitry df2 at wm.ru
Thu Nov 17 08:26:09 GMT 2005


On Wed, 16 Nov 2005 13:26:23 -0500
Perrin Harkins <perrin at elem.com> wrote:

> > 
> > then it just prints empty strings
> 
> That's obviously broken, and you don't even have a has_a() on name().
> Forget the lazy-loading, has_a(), etc. and just figure out why name() is
> returning nothing when that row in the database has a value.
> 
> - Perrin
> 

Now i tried to make test more clear, without columns(Essential, but
still cant figure out what wrong:

> DBI Class:
package ClientApp::Domain;
use strict;                                                            
use base qw/Catalyst::Base ClientApp:DB/;
__PACKAGE__->set_up_table('my_domains')
__PACKAGE__->has_a(plan => 'ClientApp::Plan');                                                     
1;

> Client code:
my $domain = ClientApp::Domain->retrieve(1); # row actually exists in
database
print $domain->name; # --> empty
print $domain->plan; # --> empty
print ref($domain); # --> ClientApp::Domain
print Dumper($domain); # --> $VAR1 = bless( {  'id' => '1'  },'ClientApp::Domain' );

> here is DBI->trace:
....
 T  <- prepare_cached('SELECT id FROM my_domains WHERE  id = ?
')= ( DBIx::ContextualFetch::st=HASH(0x8426a7c) ) [1 items] at DBI.pm
line 391
 T  <- FETCH('Active')= '' at DBI.pm line 1124
 T  <- FETCH('Taint')= 1 at ContextualFetch.pm line 49
    <- STORE('Taint' 0)= 1 at ContextualFetch.pm line 50
    <- execute(46)= 1 at ContextualFetch.pm line 51
 T  <- STORE('Taint' 1)= 1 at ContextualFetch.pm line 52
 T  <- FETCH('NAME_lc')= [ 'id' ] at DBI.pm line 1125
 T  <- bind_columns(SCALAR(0x84709f8))= 1 at DBI.pm line 1125
 T  <- fetchrow_arrayref= [ '46' ] row1 at ContextualFetch.pm line 59
 T  <- fetchrow_arrayref= undef row1 at ContextualFetch.pm line 59
    <- disconnect_all= '' at DBI.pm line 677                                  
!T  <- DESTROY(DBIx::ContextualFetch::st=HASH(8426a7c))= undef during global des...

-- 
Dmitry <df2 at wm.ru>





More information about the ClassDBI mailing list