use Test::More;
-BEGIN {
- eval "use SQL::Abstract 1.49";
- plan $@
- ? ( skip_all => "Needs SQLA 1.49+" )
- : ( tests => 4 );
-}
+plan ( tests => 5 );
use lib qw(t/lib);
use DBICTest;
my $cdrs = $schema->resultset('CD');
{
- my $arr = $art_rs->as_query;
- my ($query, @bind) = @{$$arr};
-
is_same_sql_bind(
- $query, \@bind,
+ $art_rs->as_query,
"(SELECT me.artistid, me.name, me.rank, me.charfield FROM artist me)", [],
);
}
$art_rs = $art_rs->search({ name => 'Billy Joel' });
{
- my $arr = $art_rs->as_query;
- my ($query, @bind) = @{$$arr};
-
is_same_sql_bind(
- $query, \@bind,
+ $art_rs->as_query,
"(SELECT me.artistid, me.name, me.rank, me.charfield FROM artist me WHERE ( name = ? ))",
[ [ name => 'Billy Joel' ] ],
);
$art_rs = $art_rs->search({ rank => 2 });
{
- my $arr = $art_rs->as_query;
- my ($query, @bind) = @{$$arr};
-
is_same_sql_bind(
- $query, \@bind,
+ $art_rs->as_query,
"(SELECT me.artistid, me.name, me.rank, me.charfield FROM artist me WHERE ( ( ( rank = ? ) AND ( name = ? ) ) ) )",
[ [ rank => 2 ], [ name => 'Billy Joel' ] ],
);
my $rscol = $art_rs->get_column( 'charfield' );
{
- my $arr = $rscol->as_query;
- my ($query, @bind) = @{$$arr};
-
is_same_sql_bind(
- $query, \@bind,
+ $rscol->as_query,
"(SELECT me.charfield FROM artist me WHERE ( ( ( rank = ? ) AND ( name = ? ) ) ) )",
[ [ rank => 2 ], [ name => 'Billy Joel' ] ],
);
}
-__END__
+{
+ my $rs = $schema->resultset("CD")->search(
+ { 'artist.name' => 'Caterwauler McCrae' },
+ { join => [qw/artist/]}
+ );
+ my $subsel_rs = $schema->resultset("CD")->search( { cdid => { IN => $rs->get_column('cdid')->as_query } } );
+ is($subsel_rs->count, $rs->count, 'Subselect on PK got the same row count');
+}