-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix regression breaking search on prefetched rel (broken by 5e2a051)
Boy 0.08205 was a bad release, so much crap went in undetected by any of our tests :( Maybe it's time for Devel::Cover...?
- Loading branch information
Showing
3 changed files
with
63 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| use strict; | ||
| use warnings; | ||
|
|
||
| use Test::More; | ||
| use lib qw(t/lib); | ||
| use DBICTest; | ||
|
|
||
| my $schema = DBICTest->init_schema(); | ||
|
|
||
| my $art = $schema->resultset('Artist')->find( | ||
| { 'me.artistid' => 1 }, | ||
| { prefetch => 'cds', order_by => { -desc => 'cds.year' } } | ||
| ); | ||
|
|
||
| is ( | ||
| $art->cds->search({ year => 1999 })->next->year, | ||
| 1999, | ||
| 'Found expected CD with year 1999 after refined search', | ||
| ); | ||
|
|
||
| is ( | ||
| $art->cds->count({ year => 1999 }), | ||
| 1, | ||
| 'Correct refined count', | ||
| ); | ||
|
|
||
| # this still should emit no queries: | ||
| { | ||
| my $queries = 0; | ||
| my $orig_debug = $schema->storage->debug; | ||
| $schema->storage->debugcb(sub { $queries++; }); | ||
| $schema->storage->debug(1); | ||
|
|
||
| my $cds = $art->cds; | ||
| is ( | ||
| $cds->count, | ||
| 3, | ||
| 'Correct prefetched count', | ||
| ); | ||
|
|
||
| my @years = qw(2001 1999 1997); | ||
| while (my $cd = $cds->next) { | ||
| is ( | ||
| $cd->year, | ||
| (shift @years), | ||
| 'Correct prefetched cd year', | ||
| ); | ||
| } | ||
|
|
||
| $schema->storage->debug($orig_debug); | ||
| $schema->storage->debugcb(undef); | ||
|
|
||
| is ($queries, 0, 'No queries on prefetched operations'); | ||
| } | ||
|
|
||
| done_testing; |