[Dbix-class] Oracle Prefetch / Join
SHAD0WRUNNER at gmx.de
SHAD0WRUNNER at gmx.de
Fri May 4 13:26:22 GMT 2007
Hello again,
I tried this example with Oracle:
Tables CDS -> Tracks
#1. Package:
#############
package Schema::CD;
use base qw/DBIx::Class/;
__PACKAGE__->load_components(qw/ PK::Auto Core /);
__PACKAGE__->table('cds');
__PACKAGE__->add_columns(
id => {
data_type => "varchar2",
size => "64",
prec => "0",
scale => "0",
is_nullable => "n",
}
);
__PACKAGE__->set_primary_key(qw/ id / );
__PACKAGE__->has_many('tracks' => 'Schema::Track', 'cd_id');
1;
#2. Package:
#############
package Schema::Track;
use base qw/DBIx::Class/;
__PACKAGE__->load_components(qw/ PK::Auto Core /);
__PACKAGE__->table('tracks');
__PACKAGE__->add_columns(
id => {
data_type => "varchar2",
size => "64",
prec => "0",
scale => "0",
is_nullable => "n",
},
cd_id => {
data_type => "varchar2",
size => "64",
}
);
__PACKAGE__->set_primary_key(qw/ id / );
__PACKAGE__->belongs_to('cd' => 'Schema::CD', 'cd_id');
1;
#test.pl
#########
....
$rs = $schema->resultset('CD')->search( { id => "test" },
{prefetch => "tracks"}
);
$i=1;
while($rs->next){
print "$i ...\n";
$i++;
}
If there is 1 recordset in table CDS and 2 related recordsets in
TRACKS I would expect:
1 ...
but i got:
1 ...
2 ...
3 ...
Is this the expected behavior?
The same effect I got with join.
Greetz
Dieter
--
FastJack
"Feel free" - 10 GB Mailbox, 100 FreeSMS/Monat ...
Jetzt GMX TopMail testen: http://www.gmx.net/de/go/topmail
More information about the Dbix-class
mailing list