File tree Expand file tree Collapse file tree 3 files changed +63
-3
lines changed Expand file tree Collapse file tree 3 files changed +63
-3
lines changed Original file line number Diff line number Diff line change 1
1
Revision history for DBIx::Class
2
2
3
+ * Fixes
4
+ - Fix another embarrassing regression preventing correct refining of
5
+ the search criteria on a prefetched relation (broken in 0.08205)
6
+
3
7
0.08208 2013-02-20 09:56 (UTC)
4
8
* New Features / Changes
5
9
- A bunch of nonsensically named arguments to the SQL::Translator
Original file line number Diff line number Diff line change @@ -389,11 +389,11 @@ sub search_rs {
389
389
my $cache ;
390
390
my %safe = (alias => 1, cache => 1);
391
391
if ( ! List::Util::first { !$safe {$_ } } keys %$call_attrs and (
392
- ! defined $_ [0]
392
+ ! defined $call_cond
393
393
or
394
- ref $_ [0] eq ' HASH' && ! keys %{ $_ [0]}
394
+ ref $call_cond eq ' HASH' && ! keys %$call_cond
395
395
or
396
- ref $_ [0] eq ' ARRAY' && ! @{ $_ [0]}
396
+ ref $call_cond eq ' ARRAY' && ! @$call_cond
397
397
)) {
398
398
$cache = $self -> get_cache;
399
399
}
Original file line number Diff line number Diff line change
1
+ use strict;
2
+ use warnings;
3
+
4
+ use Test::More;
5
+ use lib qw( t/lib) ;
6
+ use DBICTest;
7
+
8
+ my $schema = DBICTest-> init_schema();
9
+
10
+ my $art = $schema -> resultset(' Artist' )-> find(
11
+ { ' me.artistid' => 1 },
12
+ { prefetch => ' cds' , order_by => { -desc => ' cds.year' } }
13
+ );
14
+
15
+ is (
16
+ $art -> cds-> search({ year => 1999 })-> next-> year,
17
+ 1999,
18
+ ' Found expected CD with year 1999 after refined search' ,
19
+ );
20
+
21
+ is (
22
+ $art -> cds-> count({ year => 1999 }),
23
+ 1,
24
+ ' Correct refined count' ,
25
+ );
26
+
27
+ # this still should emit no queries:
28
+ {
29
+ my $queries = 0;
30
+ my $orig_debug = $schema -> storage-> debug;
31
+ $schema -> storage-> debugcb(sub { $queries ++; });
32
+ $schema -> storage-> debug(1);
33
+
34
+ my $cds = $art -> cds;
35
+ is (
36
+ $cds -> count,
37
+ 3,
38
+ ' Correct prefetched count' ,
39
+ );
40
+
41
+ my @years = qw( 2001 1999 1997) ;
42
+ while (my $cd = $cds -> next) {
43
+ is (
44
+ $cd -> year,
45
+ (shift @years ),
46
+ ' Correct prefetched cd year' ,
47
+ );
48
+ }
49
+
50
+ $schema -> storage-> debug($orig_debug );
51
+ $schema -> storage-> debugcb(undef );
52
+
53
+ is ($queries , 0, ' No queries on prefetched operations' );
54
+ }
55
+
56
+ done_testing;
You can’t perform that action at this time.
0 commit comments