From: Alexander Hartmaier Date: Mon, 14 Jun 2010 12:05:18 +0000 (+0200) Subject: fixed rels ending with me breaking subquery realiasing X-Git-Tag: v0.08124~137 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=dbsrgits%2FDBIx-Class.git;a=commitdiff_plain;h=f8583f8f51fd7ac8eeb348ad390219152a8a3bf8 fixed rels ending with me breaking subquery realiasing --- diff --git a/Changes b/Changes index 13f03bd..0f6aa20 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,8 @@ Revision history for DBIx::Class + * Fixes + - Fixed rels ending with me breaking subqueried limit realiasing + 0.08123 2010-06-12 14:46 (UTC) * Fixes - Make sure Oracle identifier shortener applies to auto-generated diff --git a/lib/DBIx/Class/SQLAHacks.pm b/lib/DBIx/Class/SQLAHacks.pm index 68566f3..3cf750c 100644 --- a/lib/DBIx/Class/SQLAHacks.pm +++ b/lib/DBIx/Class/SQLAHacks.pm @@ -122,7 +122,7 @@ sub _subqueried_limit_attrs { # for possible further chaining) my (@in_sel, @out_sel, %renamed); for my $node (@sel) { - if (first { $_ =~ / (?{as}, $node->{unquoted_sql}) ) { + if (first { $_ =~ / (?{as}, $node->{unquoted_sql}) ) { $node->{as} = $self->_unqualify_colname($node->{as}); my $quoted_as = $self->_quote($node->{as}); push @in_sel, sprintf '%s AS %s', $node->{sql}, $quoted_as; diff --git a/t/sqlahacks/limit_dialects/rownum.t b/t/sqlahacks/limit_dialects/rownum.t index 85ca3e8..34619fc 100644 --- a/t/sqlahacks/limit_dialects/rownum.t +++ b/t/sqlahacks/limit_dialects/rownum.t @@ -32,4 +32,23 @@ is_same_sql_bind ( 'Rownum subsel aliasing works correctly' ); +is_same_sql_bind ( + $rs->search ({}, { rows => 1, offset => 3,columns => [ + { id => 'foo.id' }, + { 'ends_with_me.id' => 'ends_with_me.id' }, + ]})->as_query, + '(SELECT id, ends_with_me__id + FROM ( + SELECT id, ends_with_me__id, ROWNUM rownum__index + FROM ( + SELECT foo.id AS id, ends_with_me.id AS ends_with_me__id + FROM cd me + ) me + ) me + WHERE rownum__index BETWEEN 4 AND 4 + )', + [], + 'Rownum subsel aliasing works correctly' +); + done_testing;