From: Peter Rabbitson Date: Mon, 24 Jan 2011 10:12:19 +0000 (+0100) Subject: Fix broken select/group bind in Oracle (after 0542ec57 & 4c2b30d6) X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=55d02972c8c10a22e2bcd606dca693de34455231;p=dbsrgits%2FDBIx-Class-Historic.git Fix broken select/group bind in Oracle (after 0542ec57 & 4c2b30d6) --- diff --git a/Changes b/Changes index 622ce52..a67b17b 100644 --- a/Changes +++ b/Changes @@ -4,6 +4,8 @@ Revision history for DBIx::Class - Disable mysql_auto_reconnect for MySQL - depending on the ENV it sometimes defaults to on and causes major borkage on older DBD::mysql versions + - Fix dropped bind values in select/group_by on Oracle (omission + from 0542ec57 and 4c2b30d6) 0.08127 2011-01-19 16:40 (UTC) * New Features / Changes diff --git a/lib/DBIx/Class/SQLMaker/Oracle.pm b/lib/DBIx/Class/SQLMaker/Oracle.pm index b05f3c2..5c0f7cd 100644 --- a/lib/DBIx/Class/SQLMaker/Oracle.pm +++ b/lib/DBIx/Class/SQLMaker/Oracle.pm @@ -27,7 +27,7 @@ sub new { sub _assemble_binds { my $self = shift; - return map { @{ (delete $self->{"${_}_bind"}) || [] } } (qw/from where oracle_connect_by having order/); + return map { @{ (delete $self->{"${_}_bind"}) || [] } } (qw/select from where oracle_connect_by group having order/); } diff --git a/t/73oracle_hq.t b/t/73oracle_hq.t index 11e42ef..397a97f 100644 --- a/t/73oracle_hq.t +++ b/t/73oracle_hq.t @@ -343,30 +343,37 @@ do_creates($dbh); } # combine a connect_by with group_by and having + # add some bindvals to make sure things still work { my $rs = $schema->resultset('Artist')->search({}, { - select => { count => 'rank', -as => 'cnt' }, + select => \[ 'COUNT(rank) + ?', [ __cbind => 3 ] ], + as => 'cnt', start_with => { name => 'root' }, connect_by => { parentid => { -prior => { -ident => 'artistid' } } }, - group_by => ['rank'], + group_by => \[ 'rank + ? ', [ __gbind => 1] ], having => \[ 'count(rank) < ?', [ cnt => 2 ] ], }); is_same_sql_bind ( $rs->as_query, '( - SELECT COUNT(rank) AS cnt + SELECT COUNT(rank) + ? FROM artist me START WITH name = ? CONNECT BY parentid = PRIOR artistid - GROUP BY rank HAVING count(rank) < ? + GROUP BY( rank + ? ) HAVING count(rank) < ? )', - [ [ name => 'root' ], [ cnt => 2 ] ], + [ + [ __cbind => 3 ], + [ name => 'root' ], + [ __gbind => 1 ], + [ cnt => 2 ] + ], ); is_deeply ( [ $rs->get_column ('cnt')->all ], - [1, 1], + [4, 4], 'Group By a Connect By query - correct values' ); }