From: Peter Rabbitson Date: Fri, 5 Feb 2010 17:01:33 +0000 (+0000) Subject: No idea how I missed all these fails... X-Git-Tag: v0.08117~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0491b597f9bf7f3731f5a2799041f2596b0f46be;p=dbsrgits%2FDBIx-Class.git No idea how I missed all these fails... --- diff --git a/lib/DBIx/Class/SQLAHacks.pm b/lib/DBIx/Class/SQLAHacks.pm index 4c783c1..5c374b0 100644 --- a/lib/DBIx/Class/SQLAHacks.pm +++ b/lib/DBIx/Class/SQLAHacks.pm @@ -407,7 +407,7 @@ sub _recurse_fields { $self->_sqlcase($func), $self->_recurse_fields($args), $as - ? sprintf (' %s %s', $self->_sqlcase('as'), $as) + ? sprintf (' %s %s', $self->_sqlcase('as'), $self->_quote ($as) ) : '' ); diff --git a/t/bind/attribute.t b/t/bind/attribute.t index 1a1d0c7..c4f99c4 100644 --- a/t/bind/attribute.t +++ b/t/bind/attribute.t @@ -38,7 +38,7 @@ TODO: { ->search({ artistid => 1}); is ( $rs->count, 1, 'where/bind first' ); - + $rs = $schema->resultset('Artist')->search({ artistid => 1}) ->search({}, $where_bind); @@ -76,7 +76,7 @@ TODO: { $rs = $schema->resultset('Complex')->search({}, { bind => [ 1999 ] })->search({}, { where => \"title LIKE ?", bind => [ 'Spoon%' ] }); is_same_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 ?)", + "(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 = ?) me WHERE title LIKE ?)", [ [ '!!dummy' => '1999' ], [ '!!dummy' => 'Spoon%' ] @@ -105,7 +105,7 @@ TODO: { $rs = $schema->resultset('CustomSql')->search({}, { bind => [ 1999 ] })->search({}, { where => \"title LIKE ?", bind => [ 'Spoon%' ] }); is_same_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 ?)", + "(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 = ?) me WHERE title LIKE ?)", [ [ '!!dummy' => '1999' ], [ '!!dummy' => 'Spoon%' ] diff --git a/t/prefetch/grouped.t b/t/prefetch/grouped.t index ca4209d..edb69b6 100644 --- a/t/prefetch/grouped.t +++ b/t/prefetch/grouped.t @@ -87,12 +87,12 @@ for ($cd_rs->all) { '( SELECT me.cd, me.track_count, cd.cdid, cd.artist, cd.title, cd.year, cd.genreid, cd.single_track FROM ( - SELECT me.cd, COUNT (me.trackid) AS track_count, + SELECT me.cd, COUNT (me.trackid) AS track_count FROM track me JOIN cd cd ON cd.cdid = me.cd WHERE ( me.cd IN ( ?, ?, ?, ?, ? ) ) GROUP BY me.cd - ) as me + ) me JOIN cd cd ON cd.cdid = me.cd WHERE ( me.cd IN ( ?, ?, ?, ?, ? ) ) )', @@ -164,7 +164,7 @@ for ($cd_rs->all) { tracks.trackid, tracks.cd, tracks.position, tracks.title, tracks.last_updated_on, tracks.last_updated_at, tracks.small_dt, liner_notes.liner_id, liner_notes.notes FROM ( - SELECT me.cdid, COUNT( tracks.trackid ) AS track_count, MAX( tracks.trackid ) AS maxtr, + SELECT me.cdid, COUNT( tracks.trackid ) AS track_count, MAX( tracks.trackid ) AS maxtr FROM cd me LEFT JOIN track tracks ON tracks.cd = me.cdid WHERE ( me.cdid IS NOT NULL ) diff --git a/t/search/subquery.t b/t/search/subquery.t index 5d0a255..15ac08e 100644 --- a/t/search/subquery.t +++ b/t/search/subquery.t @@ -19,7 +19,7 @@ my @tests = ( search => \[ "title = ? AND year LIKE ?", 'buahaha', '20%' ], attrs => { rows => 5 }, sqlbind => \[ - "( SELECT me.cdid,me.artist,me.title,me.year,me.genreid,me.single_track FROM cd me WHERE (title = ? AND year LIKE ?) LIMIT 5)", + "( SELECT me.cdid, me.artist, me.title, me.year, me.genreid, me.single_track FROM cd me WHERE (title = ? AND year LIKE ?) LIMIT 5)", 'buahaha', '20%', ], @@ -31,7 +31,7 @@ my @tests = ( artist_id => { 'in' => $art_rs->search({}, { rows => 1 })->get_column( 'id' )->as_query }, }, sqlbind => \[ - "( 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 ) )", + "( 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 ) )", ], }, @@ -68,7 +68,10 @@ my @tests = ( ], }, sqlbind => \[ - "( 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 )", + "( 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 ] ], }, @@ -107,9 +110,9 @@ my @tests = ( sqlbind => \[ "( 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 + (SELECT cd3.cdid, cd3.artist, cd3.title, cd3.year, cd3.genreid, cd3.single_track FROM - (SELECT me.cdid,me.artist,me.title,me.year,me.genreid,me.single_track + (SELECT me.cdid, me.artist, me.title, me.year, me.genreid, me.single_track FROM cd me WHERE id < ?) cd3 WHERE id > ?) cd2 )", @@ -142,7 +145,10 @@ my @tests = ( ], }, sqlbind => \[ - "(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)", + "(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' ] diff --git a/t/sqlahacks/limit_dialects/toplimit.t b/t/sqlahacks/limit_dialects/toplimit.t index 242e623..3323574 100644 --- a/t/sqlahacks/limit_dialects/toplimit.t +++ b/t/sqlahacks/limit_dialects/toplimit.t @@ -84,7 +84,7 @@ my @tests = ( { order_by => [ qw{ foo bar} ], order_req => 'foo, bar', - order_inner => 'foo ASC,bar ASC', + order_inner => 'foo ASC, bar ASC', order_outer => 'foo DESC, bar DESC', }, { diff --git a/t/storage/debug.t b/t/storage/debug.t index 480ad6e..cb6dd2c 100644 --- a/t/storage/debug.t +++ b/t/storage/debug.t @@ -51,7 +51,7 @@ open(STDERR, '>&STDERRCOPY'); my @cds = $schema->resultset('CD')->search( { artist => 1, cdid => { -between => [ 1, 3 ] }, } ); is_same_sql_bind( $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'", + "SELECT me.cdid, me.artist, me.title, me.year, me.genreid, me.single_track FROM cd me WHERE ( artist = ? AND (cdid BETWEEN ? AND ?) )", [qw/'1' '1' '3'/], 'got correct SQL with all bind parameters (debugcb)' );