[Bast-commits] r7629 - in DBIx-Class/0.08/trunk: lib/DBIx/Class
t/prefetch t/relationship
ribasushi at dev.catalyst.perl.org
ribasushi at dev.catalyst.perl.org
Fri Sep 11 21:06:55 GMT 2009
Author: ribasushi
Date: 2009-09-11 21:06:54 +0000 (Fri, 11 Sep 2009)
New Revision: 7629
Modified:
DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSource.pm
DBIx-Class/0.08/trunk/t/prefetch/via_search_related.t
DBIx-Class/0.08/trunk/t/relationship/after_update.t
DBIx-Class/0.08/trunk/t/relationship/doesnt_exist.t
DBIx-Class/0.08/trunk/t/relationship/update_or_create_single.t
Log:
Extend prefetch tests
Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSource.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSource.pm 2009-09-11 18:59:07 UTC (rev 7628)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSource.pm 2009-09-11 21:06:54 UTC (rev 7629)
@@ -1462,7 +1462,7 @@
$p = $p->{$_} for (@$pref_path, $pre);
$self->throw_exception (
- "Unable to resolve prefetch $pre - join alias map does not contain an entry for path: "
+ "Unable to resolve prefetch '$pre' - join alias map does not contain an entry for path: "
. join (' -> ', @$pref_path, $pre)
) if (ref $p->{-join_aliases} ne 'ARRAY' or not @{$p->{-join_aliases}} );
Modified: DBIx-Class/0.08/trunk/t/prefetch/via_search_related.t
===================================================================
--- DBIx-Class/0.08/trunk/t/prefetch/via_search_related.t 2009-09-11 18:59:07 UTC (rev 7628)
+++ DBIx-Class/0.08/trunk/t/prefetch/via_search_related.t 2009-09-11 21:06:54 UTC (rev 7629)
@@ -57,34 +57,46 @@
# test where conditions at the root of the related chain
- my $artist_rs = $schema->resultset("Artist")->search({artistid => 11});
+ my $artist_rs = $schema->resultset("Artist")->search({artistid => 2});
+ my $artist = $artist_rs->next;
+ $artist->create_related ('cds', $_) for (
+ {
+ year => 1999, title => 'vague cd', genre => { name => 'vague genre' }
+ },
+ {
+ year => 1999, title => 'vague cd2', genre => { name => 'vague genre' }
+ },
+ );
-
$rs = $artist_rs->search_related('cds')->search_related('genre',
- { 'genre.name' => 'foo' },
+ { 'genre.name' => 'vague genre' },
{ prefetch => 'cds' },
);
- is($rs->all, 0, 'prefetch without distinct (objects)');
- is($rs->count, 0, 'prefetch without distinct (count)');
+ is($rs->all, 1, 'base without distinct (objects)');
+ is($rs->count, 1, 'base without distinct (count)');
+ # artist -> 2 cds -> 2 genres -> 2 cds for each genre = 4
+ is($rs->search_related('cds')->all, 4, 'prefetch without distinct (objects)');
+ is($rs->search_related('cds')->count, 4, 'prefetch without distinct (count)');
-
$rs = $artist_rs->search(undef, {distinct => 1})
->search_related('cds')->search_related('genre',
- { 'genre.name' => 'foo' },
+ { 'genre.name' => 'vague genre' },
);
- is($rs->all, 0, 'distinct without prefetch (objects)');
- is($rs->count, 0, 'distinct without prefetch (count)');
+ is($rs->all, 1, 'distinct without prefetch (objects)');
+ is($rs->count, 1, 'distinct without prefetch (count)');
-
$rs = $artist_rs->search({}, {distinct => 1})
->search_related('cds')->search_related('genre',
- { 'genre.name' => 'foo' },
+ { 'genre.name' => 'vague genre' },
{ prefetch => 'cds' },
);
- is($rs->all, 0, 'distinct with prefetch (objects)');
- is($rs->count, 0, 'distinct with prefetch (count)');
+ is($rs->all, 1, 'distinct with prefetch (objects)');
+ is($rs->count, 1, 'distinct with prefetch (count)');
+ # artist -> 2 cds -> 2 genres -> 2 cds for each genre + distinct = 2
+ is($rs->search_related('cds')->all, 2, 'prefetched distinct with prefetch (objects)');
+ is($rs->search_related('cds')->count, 2, 'prefetched distinct with prefetch (count)');
Modified: DBIx-Class/0.08/trunk/t/relationship/after_update.t
===================================================================
--- DBIx-Class/0.08/trunk/t/relationship/after_update.t 2009-09-11 18:59:07 UTC (rev 7628)
+++ DBIx-Class/0.08/trunk/t/relationship/after_update.t 2009-09-11 21:06:54 UTC (rev 7629)
@@ -1,7 +1,5 @@
-#!/usr/bin/perl -w
-
use strict;
-use warnings;
+use warnings;
use Test::More;
use lib qw(t/lib);
Modified: DBIx-Class/0.08/trunk/t/relationship/doesnt_exist.t
===================================================================
--- DBIx-Class/0.08/trunk/t/relationship/doesnt_exist.t 2009-09-11 18:59:07 UTC (rev 7628)
+++ DBIx-Class/0.08/trunk/t/relationship/doesnt_exist.t 2009-09-11 21:06:54 UTC (rev 7629)
@@ -1,7 +1,5 @@
-#!/usr/bin/perl -w
-
use strict;
-use warnings;
+use warnings;
use Test::More;
use lib qw(t/lib);
Modified: DBIx-Class/0.08/trunk/t/relationship/update_or_create_single.t
===================================================================
--- DBIx-Class/0.08/trunk/t/relationship/update_or_create_single.t 2009-09-11 18:59:07 UTC (rev 7628)
+++ DBIx-Class/0.08/trunk/t/relationship/update_or_create_single.t 2009-09-11 21:06:54 UTC (rev 7629)
@@ -78,7 +78,7 @@
# expect a year update on the only related row
-# (non-qunique column only)
+# (non-unique column only)
$genre->update_or_create_related ('model_cd', {
year => 2011,
});
@@ -95,5 +95,3 @@
},
'CD year column updated correctly without a disambiguator',
);
-
-
More information about the Bast-commits
mailing list