Commit | Line | Data |
47c10423 |
1 | use strict; |
2 | use warnings; |
3 | |
4 | use Test::More; |
5 | use Test::Exception; |
6 | |
7 | use lib qw(t/lib); |
8 | use DBIC::SqlMakerTest; |
9 | use DBICTest; |
10 | |
11 | my $schema = DBICTest->init_schema(); |
12 | |
13 | my $rs = $schema->resultset('CD')->search ( |
14 | { 'tracks.id' => { '!=', 666 }}, |
15 | { join => 'artist', prefetch => 'tracks' } |
16 | ); |
17 | |
18 | my $rel_rs = $rs->search_related ('tags'); |
19 | |
20 | is_same_sql_bind ( |
21 | $rel_rs->as_query, |
22 | '( |
23 | SELECT tags.tagid, tags.cd, tags.tag |
24 | FROM cd me |
25 | JOIN artist artist ON artist.artistid = me.artist |
26 | LEFT JOIN track tracks ON tracks.cd = me.cdid |
27 | LEFT JOIN tags tags ON tags.cd = me.cdid |
28 | WHERE ( tracks.id != ? ) |
29 | )', |
30 | [ [ 'tracks.id' => 666 ] ], |
31 | 'Prefetch spec successfully stripped on search_related' |
32 | ); |
33 | |
34 | done_testing; |