[Bast-commits] r7981 - DBIx-Class/0.08/branches/prefetch/t/prefetch
ribasushi at dev.catalyst.perl.org
ribasushi at dev.catalyst.perl.org
Sun Nov 29 11:51:39 GMT 2009
Author: ribasushi
Date: 2009-11-29 11:51:39 +0000 (Sun, 29 Nov 2009)
New Revision: 7981
Modified:
DBIx-Class/0.08/branches/prefetch/t/prefetch/multiple_hasmany_torture.t
Log:
Add extra joinlevels to the multi hasmany torture, and general cleanup
Modified: DBIx-Class/0.08/branches/prefetch/t/prefetch/multiple_hasmany_torture.t
===================================================================
--- DBIx-Class/0.08/branches/prefetch/t/prefetch/multiple_hasmany_torture.t 2009-11-29 05:23:32 UTC (rev 7980)
+++ DBIx-Class/0.08/branches/prefetch/t/prefetch/multiple_hasmany_torture.t 2009-11-29 11:51:39 UTC (rev 7981)
@@ -15,7 +15,7 @@
# prefetch => [
# {
# cds => [
-# { tracks => 'cd_single' },
+# { tracks => { cd_single => 'tracks } },
# { producer_to_cd => 'producer' }
# ]
# },
@@ -27,27 +27,24 @@
rank => '1337',
cds => [
{
- artist => 4,
title => 'Song of a Foo',
year => '1999',
tracks => [
{
- position => 1,
title => 'Foo Me Baby One More Time',
- cd_single =>
- { artist => 6, title => 'MO! Single', year => 2001 }
},
{
- position => 2,
title => 'Foo Me Baby One More Time II',
},
{
- position => 3,
title => 'Foo Me Baby One More Time III',
},
{
- position => 4,
title => 'Foo Me Baby One More Time IV',
+ cd_single =>
+ { artist => 1, title => 'MO! Single', year => 2021, tracks => [
+ { title => 'singled out' }, { title => 'still alone' },
+ ] },
}
],
cd_to_producer => [
@@ -56,26 +53,27 @@
]
},
{
- artist => 4,
title => 'Song of a Foo II',
year => '2002',
tracks => [
{
- position => 1,
title => 'Quit Playing Games With My Heart',
- cd_single =>
- { artist => 5, title => 'MO! Single', year => 2001 }
},
{
- position => 2,
title => 'Bar Foo',
},
{
- position => 3,
title => 'Foo Bar',
+ cd_single =>
+ { artist => 2, title => 'MO! Single', year => 2020, tracks => [
+ { title => 'singled out' }, { title => 'still alone' },
+ ] },
}
],
- cd_to_producer => [ { producer => 4 }, { producer => 5 }, ]
+ cd_to_producer => [
+ { producer => { name => 'riba' } },
+ { producer => { name => 'sushi' } },
+ ],
}
],
artwork_to_artist =>
@@ -83,24 +81,26 @@
}
);
-my $mo = $schema->resultset('Artist')->search(
- undef,
+my $mo_rs = $schema->resultset('Artist')->search(
+ { 'me.artistid' => 4 },
{
result_class => 'DBIx::Class::ResultClass::HashRefInflator',
prefetch => [
{
cds => [
- { tracks => 'cd_single' },
+ { tracks => { cd_single => 'tracks' } },
{ cd_to_producer => 'producer' }
]
},
{ artwork_to_artist => 'artwork' }
- ]
+ ],
}
-)->find(4);
+);
-is( scalar @{ $mo->{cds} }, 2, 'two CDs' );
+my $mo = $mo_rs->next;
+is( @{$mo->{cds}}, 2, 'two CDs' );
+
is_deeply(
$mo,
{
@@ -114,14 +114,7 @@
'position' => '1',
'trackid' => '19',
'title' => 'Foo Me Baby One More Time',
- 'cd_single' => {
- 'single_track' => '19',
- 'artist' => '6',
- 'cdid' => '7',
- 'title' => 'MO! Single',
- 'genreid' => undef,
- 'year' => '2001'
- },
+ 'cd_single' => undef,
'last_updated_on' => undef,
'last_updated_at' => undef
},
@@ -151,9 +144,36 @@
'position' => '4',
'trackid' => '22',
'title' => 'Foo Me Baby One More Time IV',
- 'cd_single' => undef,
'last_updated_on' => undef,
- 'last_updated_at' => undef
+ 'last_updated_at' => undef,
+ 'cd_single' => {
+ 'single_track' => '22',
+ 'artist' => '1',
+ 'cdid' => '7',
+ 'title' => 'MO! Single',
+ 'genreid' => undef,
+ 'year' => '2021',
+ 'tracks' => [
+ {
+ 'small_dt' => undef,
+ 'cd' => '7',
+ 'position' => '1',
+ 'title' => 'singled out',
+ 'trackid' => '23',
+ 'last_updated_at' => undef,
+ 'last_updated_on' => undef
+ },
+ {
+ 'small_dt' => undef,
+ 'cd' => '7',
+ 'position' => '2',
+ 'title' => 'still alone',
+ 'trackid' => '24',
+ 'last_updated_at' => undef,
+ 'last_updated_on' => undef
+ },
+ ],
+ },
}
],
'artist' => '4',
@@ -183,43 +203,69 @@
{
'single_track' => undef,
'tracks' => [
+ # FIXME
+ # although the positional ordering is correct, SQLite seems to return
+ # the rows randomly if an ORDER BY is not supplied. Of course ordering
+ # by right side of prefetch joins is not yet possible, thus we just hope
+ # that the order is stable
{
'small_dt' => undef,
'cd' => '8',
'position' => '2',
- 'trackid' => '24',
+ 'trackid' => '26',
'title' => 'Bar Foo',
'cd_single' => undef,
'last_updated_on' => undef,
'last_updated_at' => undef
},
{
+ 'small_dt' => undef,
+ 'cd' => '8',
+ 'position' => '1',
+ 'trackid' => '25',
+ 'title' => 'Quit Playing Games With My Heart',
+ 'last_updated_on' => undef,
+ 'last_updated_at' => undef,
+ 'cd_single' => undef,
+ },
+ {
'small_dt' => undef,
'cd' => '8',
'position' => '3',
- 'trackid' => '25',
+ 'trackid' => '27',
'title' => 'Foo Bar',
- 'cd_single' => undef,
'last_updated_on' => undef,
- 'last_updated_at' => undef
- },
- {
- 'small_dt' => undef,
- 'cd' => '8',
- 'position' => '1',
- 'trackid' => '23',
- 'title' => 'Quit Playing Games With My Heart',
+ 'last_updated_at' => undef,
'cd_single' => {
- 'single_track' => '23',
- 'artist' => '5',
+ 'single_track' => '27',
+ 'artist' => '2',
'cdid' => '9',
'title' => 'MO! Single',
'genreid' => undef,
- 'year' => '2001'
- },
- 'last_updated_on' => undef,
- 'last_updated_at' => undef
- }
+ 'year' => '2020',
+ 'tracks' => [
+ {
+ 'small_dt' => undef,
+ 'cd' => '9',
+ 'position' => '1',
+ 'title' => 'singled out',
+ 'trackid' => '28',
+ 'last_updated_at' => undef,
+ 'last_updated_on' => undef
+ },
+ {
+ 'small_dt' => undef,
+ 'cd' => '9',
+ 'position' => '2',
+ 'title' => 'still alone',
+ 'trackid' => '29',
+ 'last_updated_at' => undef,
+ 'last_updated_on' => undef
+ },
+ ],
+
+ },
+ },
],
'artist' => '4',
'cdid' => '8',
More information about the Bast-commits
mailing list