1 BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) }
9 use DBICTest ':DiffSQL';
11 my $schema = DBICTest->init_schema();
12 my $art_rs = $schema->resultset('Artist');
13 my $cdrs = $schema->resultset('CD');
18 "(SELECT me.artistid, me.name, me.rank, me.charfield FROM artist me)", [],
22 $art_rs = $art_rs->search({ name => 'Billy Joel' });
24 my $name_resolved_bind = [
25 { sqlt_datatype => 'varchar', sqlt_size => 100, dbic_colname => 'name' }
32 "(SELECT me.artistid, me.name, me.rank, me.charfield FROM artist me WHERE ( name = ? ))",
33 [ $name_resolved_bind ],
37 $art_rs = $art_rs->search({ rank => 2 });
39 my $rank_resolved_bind = [
40 { sqlt_datatype => 'integer', dbic_colname => 'rank' }
47 "(SELECT me.artistid, me.name, me.rank, me.charfield FROM artist me WHERE name = ? AND rank = ? )",
48 [ $name_resolved_bind, $rank_resolved_bind ],
52 my $rscol = $art_rs->get_column( 'charfield' );
57 "(SELECT me.charfield FROM artist me WHERE name = ? AND rank = ? )",
58 [ $name_resolved_bind, $rank_resolved_bind ],
63 my $rs = $schema->resultset("CD")->search(
64 { 'artist.name' => 'Caterwauler McCrae' },
65 { join => [qw/artist/]}
67 my $subsel_rs = $schema->resultset("CD")->search( { cdid => { IN => $rs->get_column('cdid')->as_query } } );
68 is($subsel_rs->count, $rs->count, 'Subselect on PK got the same row count');
72 is_same_sql_bind($schema->resultset('Artist')->search({
75 from => $schema->resultset('Artist')->search({ 'name' => 'frew'})->as_query,
77 '(SELECT me.artistid, me.name, me.rank, me.charfield FROM (
78 SELECT me.artistid, me.name, me.rank, me.charfield FROM
88 [{ dbic_colname => 'name', sqlt_datatype => 'varchar', sqlt_size => 100 }, 'frew'],
89 [{ dbic_colname => 'rank' }, 1],
91 'from => ...->as_query works'