Commit | Line | Data |
3170049a |
1 | use strict; |
2 | use warnings; |
3 | |
4 | use Test::More; |
3170049a |
5 | use lib qw(t/lib); |
6 | use DBICTest; |
3170049a |
7 | |
8 | my $schema = DBICTest->init_schema(); |
9 | |
10 | $schema->resultset('Artist')->delete; |
11 | $schema->resultset('CD')->delete; |
12 | |
13 | my $artist = $schema->resultset("Artist")->create({ artistid => 21, name => 'Michael Jackson', rank => 20 }); |
14 | my $cd = $artist->create_related('cds', { year => 1975, title => 'Compilation from 1975' }); |
15 | |
2cfc22dd |
16 | $schema->is_executed_sql_bind(sub { |
17 | my $find_cd = $artist->find_related('cds',{title => 'Compilation from 1975'}); |
18 | }, [ |
19 | [ |
20 | ' SELECT me.cdid, me.artist, me.title, me.year, me.genreid, me.single_track |
21 | FROM cd me |
22 | WHERE me.artist = ? AND me.title = ? |
23 | ORDER BY year ASC |
24 | ', |
25 | [ { dbic_colname => "me.artist", sqlt_datatype => "integer" } |
26 | => 21 ], |
27 | [ { dbic_colname => "me.title", sqlt_datatype => "varchar", sqlt_size => 100 } |
28 | => "Compilation from 1975" ], |
29 | ] |
30 | ], 'find_related only uses foreign key condition once' ); |
3170049a |
31 | |
32 | done_testing; |