[Bast-commits] r6355 - in DBIx-Class/0.08/trunk/t: . count
resultset search
ribasushi at dev.catalyst.perl.org
ribasushi at dev.catalyst.perl.org
Wed May 20 21:00:13 GMT 2009
Author: ribasushi
Date: 2009-05-20 21:00:13 +0000 (Wed, 20 May 2009)
New Revision: 6355
Modified:
DBIx-Class/0.08/trunk/t/19quotes.t
DBIx-Class/0.08/trunk/t/19quotes_newstyle.t
DBIx-Class/0.08/trunk/t/47bind_attribute.t
DBIx-Class/0.08/trunk/t/76joins.t
DBIx-Class/0.08/trunk/t/76select.t
DBIx-Class/0.08/trunk/t/91debug.t
DBIx-Class/0.08/trunk/t/count/prefetch.t
DBIx-Class/0.08/trunk/t/from_subquery.t
DBIx-Class/0.08/trunk/t/resultset/as_query.t
DBIx-Class/0.08/trunk/t/search/subquery.t
Log:
Switch as_query testing to direct specification in is_same_sql_bind
Modified: DBIx-Class/0.08/trunk/t/19quotes.t
===================================================================
--- DBIx-Class/0.08/trunk/t/19quotes.t 2009-05-20 20:59:10 UTC (rev 6354)
+++ DBIx-Class/0.08/trunk/t/19quotes.t 2009-05-20 21:00:13 UTC (rev 6355)
@@ -24,7 +24,7 @@
$schema->storage->sql_maker->quote_char('`');
$schema->storage->sql_maker->name_sep('.');
-my ($sql, @bind) = ('');
+my ($sql, @bind);
$schema->storage->debugobj(DBIC::DebugObj->new(\$sql, \@bind));
$schema->storage->debug(1);
Modified: DBIx-Class/0.08/trunk/t/19quotes_newstyle.t
===================================================================
--- DBIx-Class/0.08/trunk/t/19quotes_newstyle.t 2009-05-20 20:59:10 UTC (rev 6354)
+++ DBIx-Class/0.08/trunk/t/19quotes_newstyle.t 2009-05-20 21:00:13 UTC (rev 6355)
@@ -30,7 +30,7 @@
{ quote_char => '`', name_sep => '.' },
);
-my ($sql, @bind) = ('');
+my ($sql, @bind);
$schema->storage->debugobj(DBIC::DebugObj->new(\$sql, \@bind)),
$schema->storage->debug(1);
Modified: DBIx-Class/0.08/trunk/t/47bind_attribute.t
===================================================================
--- DBIx-Class/0.08/trunk/t/47bind_attribute.t 2009-05-20 20:59:10 UTC (rev 6354)
+++ DBIx-Class/0.08/trunk/t/47bind_attribute.t 2009-05-20 21:00:13 UTC (rev 6355)
@@ -74,9 +74,8 @@
{
$rs = $schema->resultset('Complex')->search({}, { bind => [ 1999 ] })->search({}, { where => \"title LIKE ?", bind => [ 'Spoon%' ] });
- my ($sql, @bind) = @${$rs->as_query};
is_same_sql_bind(
- $sql, \@bind,
+ $rs->as_query,
"(SELECT me.artistid, me.name, me.rank, me.charfield FROM (SELECT a.*, cd.cdid AS cdid, cd.title AS title, cd.year AS year FROM artist a JOIN cd ON cd.artist = a.artistid WHERE cd.year = ?) WHERE title LIKE ?)",
[
[ '!!dummy' => '1999' ],
Modified: DBIx-Class/0.08/trunk/t/76joins.t
===================================================================
--- DBIx-Class/0.08/trunk/t/76joins.t 2009-05-20 20:59:10 UTC (rev 6354)
+++ DBIx-Class/0.08/trunk/t/76joins.t 2009-05-20 21:00:13 UTC (rev 6355)
@@ -32,9 +32,9 @@
. 'child.father_id ) JOIN person mother ON ( mother.person_id '
. '= child.mother_id )'
;
-is_same_sql_bind(
- $sa->_recurse_from(@j), [],
- $match, [],
+is_same_sql(
+ $sa->_recurse_from(@j),
+ $match,
'join 1 ok'
);
@@ -52,9 +52,9 @@
. ' father.person_id = child.father_id )) ON ( mother.person_id = '
. 'child.mother_id )'
;
-is_same_sql_bind(
- $sa->_recurse_from(@j2), [],
- $match, [],
+is_same_sql(
+ $sa->_recurse_from(@j2),
+ $match,
'join 2 ok'
);
@@ -69,9 +69,9 @@
. '= child.mother_id )'
;
-is_same_sql_bind(
- $sa->_recurse_from(@j3), [],
- $match, [],
+is_same_sql(
+ $sa->_recurse_from(@j3),
+ $match,
'join 3 (inner join) ok'
);
@@ -89,9 +89,9 @@
. ' father.person_id = child.father_id )) ON ( mother.person_id = '
. 'child.mother_id )'
;
-is_same_sql_bind(
- $sa->_recurse_from(@j4), [],
- $match, [],
+is_same_sql(
+ $sa->_recurse_from(@j4),
+ $match,
'join 4 (nested joins + join types) ok'
);
@@ -104,9 +104,9 @@
. 'child.father_id ) JOIN person mother ON ( mother.person_id '
. '= child.mother_id )'
;
-is_same_sql_bind(
- $sa->_recurse_from(@j5), [],
- $match, [],
+is_same_sql(
+ $sa->_recurse_from(@j5),
+ $match,
'join 5 (SCALAR reference for ON statement) ok'
);
Modified: DBIx-Class/0.08/trunk/t/76select.t
===================================================================
--- DBIx-Class/0.08/trunk/t/76select.t 2009-05-20 20:59:10 UTC (rev 6354)
+++ DBIx-Class/0.08/trunk/t/76select.t 2009-05-20 21:00:13 UTC (rev 6355)
@@ -84,10 +84,8 @@
}
);
-my ($sql, @bind) = @${$rs->as_query};
is_same_sql_bind (
- $sql,
- \@bind,
+ $rs->as_query,
'(SELECT me.cdid, me.title, artist.name FROM cd me JOIN artist artist ON artist.artistid = me.artist)',
[],
'Use of columns attribute results in proper sql'
@@ -114,10 +112,8 @@
}
);
-($sql, @bind) = @${$rs->as_query};
is_same_sql_bind (
- $sql,
- \@bind,
+ $rs->as_query,
'(SELECT me.cdid, me.artist, me.title, me.year, me.genreid, me.single_track, me.cdid, me.title, artist.name FROM cd me JOIN artist artist ON artist.artistid = me.artist)',
[],
'Use of columns attribute results in proper sql'
Modified: DBIx-Class/0.08/trunk/t/91debug.t
===================================================================
--- DBIx-Class/0.08/trunk/t/91debug.t 2009-05-20 20:59:10 UTC (rev 6354)
+++ DBIx-Class/0.08/trunk/t/91debug.t 2009-05-20 21:00:13 UTC (rev 6355)
@@ -51,18 +51,17 @@
# test trace output correctness for bind params
{
- my ($sql, @bind) = ('');
- $schema->storage->debugcb( sub { $sql = $_[1] } );
+ my ($sql, @bind);
+ $schema->storage->debugobj(DBIC::DebugObj->new(\$sql, \@bind));
my @cds = $schema->resultset('CD')->search( { artist => 1, cdid => { -between => [ 1, 3 ] }, } );
is_same_sql_bind(
- $sql, [],
- "SELECT me.cdid, me.artist, me.title, me.year, me.genreid, me.single_track FROM cd me WHERE ( artist = ? AND (cdid BETWEEN ? AND ?) ): '1', '1', '3'", [],
+ $sql, \@bind,
+ "SELECT me.cdid, me.artist, me.title, me.year, me.genreid, me.single_track FROM cd me WHERE ( artist = ? AND (cdid BETWEEN ? AND ?) ): '1', '1', '3'",
+ [qw/'1' '1' '3'/],
'got correct SQL with all bind parameters (debugcb)'
);
- $schema->storage->debugcb(undef);
- $schema->storage->debugobj(DBIC::DebugObj->new(\$sql, \@bind));
@cds = $schema->resultset('CD')->search( { artist => 1, cdid => { -between => [ 1, 3 ] }, } );
is_same_sql_bind(
$sql, \@bind,
Modified: DBIx-Class/0.08/trunk/t/count/prefetch.t
===================================================================
--- DBIx-Class/0.08/trunk/t/count/prefetch.t 2009-05-20 20:59:10 UTC (rev 6354)
+++ DBIx-Class/0.08/trunk/t/count/prefetch.t 2009-05-20 21:00:13 UTC (rev 6355)
@@ -33,7 +33,7 @@
$sql,
\@bind,
'SELECT COUNT( * ) FROM (SELECT cds.cdid FROM artist me LEFT JOIN cd cds ON cds.artist = me.artistid LEFT JOIN track tracks ON tracks.cd = cds.cdid JOIN artist artist ON artist.artistid = cds.artist WHERE tracks.position = ? OR tracks.position = ? GROUP BY cds.cdid ORDER BY tracks.cd) count_subq',
- [ qw/'1' '2'/ ], # wtf? we quote bind vals?
+ [ qw/'1' '2'/ ],
);
}
@@ -58,6 +58,6 @@
$sql,
\@bind,
'SELECT COUNT( * ) FROM cd me LEFT JOIN track tracks ON tracks.cd = me.cdid JOIN cd disc ON disc.cdid = tracks.cd LEFT JOIN lyrics lyrics ON lyrics.track_id = tracks.trackid WHERE ( ( position = ? OR position = ? ) )',
- [ qw/'1' '2'/ ], # wtf? we quote bind vals?
+ [ qw/'1' '2'/ ],
);
}
Modified: DBIx-Class/0.08/trunk/t/from_subquery.t
===================================================================
--- DBIx-Class/0.08/trunk/t/from_subquery.t 2009-05-20 20:59:10 UTC (rev 6354)
+++ DBIx-Class/0.08/trunk/t/from_subquery.t 2009-05-20 21:00:13 UTC (rev 6355)
@@ -23,10 +23,8 @@
artist_id => { 'in' => $art_rs->search({}, { rows => 1 })->get_column( 'id' )->as_query },
});
- my $arr = $cdrs2->as_query;
- my ($query, @bind) = @{$$arr};
is_same_sql_bind(
- $query, \@bind,
+ $cdrs2->as_query,
"(SELECT me.cdid,me.artist,me.title,me.year,me.genreid,me.single_track FROM cd me WHERE artist_id IN ( SELECT id FROM artist me LIMIT 1 ))",
[],
);
@@ -42,10 +40,8 @@
},
);
- my $arr = $rs->as_query;
- my ($query, @bind) = @{$$arr};
is_same_sql_bind(
- $query, \@bind,
+ $rs->as_query,
"(SELECT (SELECT id FROM cd me LIMIT 1) FROM artist me)",
[],
);
@@ -61,10 +57,8 @@
},
);
- my $arr = $rs->as_query;
- my ($query, @bind) = @{$$arr};
is_same_sql_bind(
- $query, \@bind,
+ $rs->as_query,
"(SELECT me.artistid, me.name, me.rank, me.charfield, (SELECT id FROM cd me LIMIT 1) FROM artist me)",
[],
);
@@ -82,10 +76,8 @@
},
);
- my $arr = $rs->as_query;
- my ($query, @bind) = @{$$arr};
is_same_sql_bind(
- $query, \@bind,
+ $rs->as_query,
"(SELECT cd2.cdid, cd2.artist, cd2.title, cd2.year, cd2.genreid, cd2.single_track FROM (SELECT me.cdid,me.artist,me.title,me.year,me.genreid,me.single_track FROM cd me WHERE ( id > ? ) ) cd2)",
[
[ 'id', 20 ]
@@ -102,10 +94,8 @@
{ 'me.artistid' => 'cds_artist' } ] ]
});
- my $arr = $art_rs2->as_query;
- my ($query, @bind) = @{$$arr};
is_same_sql_bind(
- $query, \@bind,
+ $art_rs2->as_query,
"(SELECT me.artistid, me.name, me.rank, me.charfield FROM artist me JOIN (SELECT me.artist as cds_artist FROM cd me) cds ON me.artistid = cds_artist)",
[]
);
@@ -132,10 +122,8 @@
},
);
- my $arr = $rs->as_query;
- my ($query, @bind) = @{$$arr};
is_same_sql_bind(
- $query, \@bind,
+ $rs->as_query,
"(SELECT cd2.cdid, cd2.artist, cd2.title, cd2.year, cd2.genreid, cd2.single_track
FROM
(SELECT cd3.cdid,cd3.artist,cd3.title,cd3.year,cd3.genreid,cd3.single_track
@@ -160,10 +148,8 @@
)->get_column('year')->max_rs->as_query,
},
});
- my $arr = $rs->as_query;
- my ($query, @bind) = @{$$arr};
is_same_sql_bind(
- $query, \@bind,
+ $rs->as_query,
"(SELECT me.cdid, me.artist, me.title, me.year, me.genreid, me.single_track FROM cd me WHERE year = (SELECT MAX(inner.year) FROM cd inner WHERE artistid = me.artistid))",
[],
);
@@ -180,13 +166,9 @@
},
);
- my $arr = $rs->as_query;
- my ($query, @bind) = @{$$arr};
is_same_sql_bind(
- $query, \@bind,
+ $rs->as_query,
"(SELECT cd2.cdid, cd2.artist, cd2.title, cd2.year, cd2.genreid, cd2.single_track FROM (SELECT me.cdid,me.artist,me.title,me.year,me.genreid,me.single_track FROM cd me WHERE ( title = ? ) ) cd2)",
[ [ 'title', 'Thriller' ] ],
);
}
-
-__END__
Modified: DBIx-Class/0.08/trunk/t/resultset/as_query.t
===================================================================
--- DBIx-Class/0.08/trunk/t/resultset/as_query.t 2009-05-20 20:59:10 UTC (rev 6354)
+++ DBIx-Class/0.08/trunk/t/resultset/as_query.t 2009-05-20 21:00:13 UTC (rev 6355)
@@ -18,11 +18,8 @@
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)", [],
);
}
@@ -30,11 +27,8 @@
$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' ] ],
);
@@ -43,11 +37,8 @@
$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' ] ],
);
@@ -56,11 +47,8 @@
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' ] ],
);
Modified: DBIx-Class/0.08/trunk/t/search/subquery.t
===================================================================
--- DBIx-Class/0.08/trunk/t/search/subquery.t 2009-05-20 20:59:10 UTC (rev 6354)
+++ DBIx-Class/0.08/trunk/t/search/subquery.t 2009-05-20 21:00:13 UTC (rev 6355)
@@ -22,10 +22,8 @@
artist_id => { 'in' => $art_rs->search({}, { rows => 1 })->get_column( 'id' )->as_query },
});
- my $arr = $cdrs2->as_query;
- my ($query, @bind) = @{$$arr};
is_same_sql_bind(
- $query, \@bind,
+ $cdrs2->as_query,
"( SELECT me.cdid,me.artist,me.title,me.year,me.genreid,me.single_track FROM cd me WHERE artist_id IN ( SELECT id FROM artist me LIMIT 1 ) )",
[],
);
@@ -41,10 +39,8 @@
},
);
- my $arr = $rs->as_query;
- my ($query, @bind) = @{$$arr};
is_same_sql_bind(
- $query, \@bind,
+ $rs->as_query,
"( SELECT (SELECT id FROM cd me LIMIT 1) FROM artist me )",
[],
);
@@ -60,10 +56,8 @@
},
);
- my $arr = $rs->as_query;
- my ($query, @bind) = @{$$arr};
is_same_sql_bind(
- $query, \@bind,
+ $rs->as_query,
"( SELECT me.artistid, me.name, me.rank, me.charfield, (SELECT id FROM cd me LIMIT 1) FROM artist me )",
[],
);
@@ -81,10 +75,8 @@
},
);
- my $arr = $rs->as_query;
- my ($query, @bind) = @{$$arr};
is_same_sql_bind(
- $query, \@bind,
+ $rs->as_query,
"( SELECT cd2.cdid, cd2.artist, cd2.title, cd2.year, cd2.genreid, cd2.single_track FROM (SELECT me.cdid,me.artist,me.title,me.year,me.genreid,me.single_track FROM cd me WHERE id > ?) cd2 )",
[
[ 'id', 20 ]
@@ -101,10 +93,8 @@
{ 'me.artistid' => 'cds_artist' } ] ]
});
- my $arr = $art_rs2->as_query;
- my ($query, @bind) = @{$$arr};
is_same_sql_bind(
- $query, \@bind,
+ $art_rs2->as_query,
"( SELECT me.artistid, me.name, me.rank, me.charfield FROM artist me JOIN (SELECT me.artist as cds_artist FROM cd me) cds ON me.artistid = cds_artist )", []
);
@@ -130,10 +120,8 @@
},
);
- my $arr = $rs->as_query;
- my ($query, @bind) = @{$$arr};
is_same_sql_bind(
- $query, \@bind,
+ $rs->as_query,
"( SELECT cd2.cdid, cd2.artist, cd2.title, cd2.year, cd2.genreid, cd2.single_track
FROM
(SELECT cd3.cdid,cd3.artist,cd3.title,cd3.year,cd3.genreid,cd3.single_track
@@ -159,10 +147,9 @@
)->get_column('year')->max_rs->as_query,
},
});
- my $arr = $rs->as_query;
- my ($query, @bind) = @{$$arr};
+
is_same_sql_bind(
- $query, \@bind,
+ $rs->as_query,
"( SELECT me.cdid, me.artist, me.title, me.year, me.genreid, me.single_track FROM cd me WHERE year = (SELECT MAX(inner.year) FROM cd inner WHERE artistid = me.artistid) )",
[],
);
@@ -179,10 +166,8 @@
},
);
- my $arr = $rs->as_query;
- my ($query, @bind) = @{$$arr};
is_same_sql_bind(
- $query, \@bind,
+ $rs->as_query,
"(SELECT cd2.cdid, cd2.artist, cd2.title, cd2.year, cd2.genreid, cd2.single_track FROM (SELECT me.cdid,me.artist,me.title,me.year,me.genreid,me.single_track FROM cd me WHERE title = ?) cd2)",
[
[ 'title',
@@ -191,5 +176,3 @@
],
);
}
-
-__END__
More information about the Bast-commits
mailing list