7 use DBICTest ':DiffSQL';
9 my $schema = DBICTest->init_schema();
10 my $art_rs = $schema->resultset('Artist');
11 my $cdrs = $schema->resultset('CD');
16 "(SELECT me.artistid, me.name, me.rank, me.charfield FROM artist me)", [],
20 $art_rs = $art_rs->search({ name => 'Billy Joel' });
22 my $name_resolved_bind = [
23 { sqlt_datatype => 'varchar', sqlt_size => 100, dbic_colname => 'name' }
30 "(SELECT me.artistid, me.name, me.rank, me.charfield FROM artist me WHERE ( name = ? ))",
31 [ $name_resolved_bind ],
35 $art_rs = $art_rs->search({ rank => 2 });
37 my $rank_resolved_bind = [
38 { sqlt_datatype => 'integer', dbic_colname => 'rank' }
45 "(SELECT me.artistid, me.name, me.rank, me.charfield FROM artist me WHERE name = ? AND rank = ? )",
46 [ $name_resolved_bind, $rank_resolved_bind ],
50 my $rscol = $art_rs->get_column( 'charfield' );
55 "(SELECT me.charfield FROM artist me WHERE name = ? AND rank = ? )",
56 [ $name_resolved_bind, $rank_resolved_bind ],
61 my $rs = $schema->resultset("CD")->search(
62 { 'artist.name' => 'Caterwauler McCrae' },
63 { join => [qw/artist/]}
65 my $subsel_rs = $schema->resultset("CD")->search( { cdid => { IN => $rs->get_column('cdid')->as_query } } );
66 is($subsel_rs->count, $rs->count, 'Subselect on PK got the same row count');
70 is_same_sql_bind($schema->resultset('Artist')->search({
73 from => $schema->resultset('Artist')->search({ 'name' => 'frew'})->as_query,
75 '(SELECT me.artistid, me.name, me.rank, me.charfield FROM (
76 SELECT me.artistid, me.name, me.rank, me.charfield FROM
86 [{ dbic_colname => 'name', sqlt_datatype => 'varchar', sqlt_size => 100 }, 'frew'],
87 [{ dbic_colname => 'rank' }, 1],
89 'from => ...->as_query works'