[CDBI] Weird things with has_a and lazy population

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

From: Dmitry
Subject: [CDBI] Weird things with has_a and lazy population
Date: 10:00 on 16 Nov 2005
I have  following code with 3 classes:

package ClientApp::DB;
use strict;                              
use Class::DBI::FromForm;                
use Class::DBI::AbstractSearch;          
use base qw/Class::DBI::Pg/;             
__PACKAGE__->set_db('Main', '...', { RaiseError => 1, AutoCommit => 1});
1;

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;

package ClientApp::Plan;
use strict;                                                 
use base qw/Catalyst::Base ClientApp::DB/;
__PACKAGE__->set_up_table('my_plans');
1;

So when i do following simple test:

use ClientApp::Domain;
my $domain = ClientApp::Domain->retrieve(1); # row actually exists in database
print $domain->name;
print $domain->plan;

then it just prints empty strings

Ok, i reading about lazy population and doing the following:

Adding this string to ClientApp::Domain
__PACKAGE__->columns(Essential => qw/name plan/);
and to ClientApp::Plan
__PACKAGE__->columns(Essential => qw/nick/);

result:
print $domain->name; # prints test.com
print $domain->plan; # prints 10

yes thats fine, but:
print $domain->plan->nick; # STILL EMPTY STRING!!

and when i do such way:
use ClientApp::Plan;
my $plan = ClientApp::Plan->retrieve(10);
print $plan->nick; # yes, it prints "good plan" as expected

My curiousity here about "has_a", why Essential thing didn't worked with
it ???
Thanks for help.

PS: Class::DBI version 0.96

--


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

[CDBI] Weird things with has_a and lazy population
Dmitry 10:00 on 16 Nov 2005

Generated at 21:49 on 21 Nov 2005 by mariachi v0.52