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