From: Peter Rabbitson Date: Tue, 1 Jun 2010 13:04:48 +0000 (+0000) Subject: Move order outside of the GenSubQ subquery, to appease retarded Sybase X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b13d22484161991bed36099c9e473c4ea67c84c9;p=dbsrgits%2FDBIx-Class-Historic.git Move order outside of the GenSubQ subquery, to appease retarded Sybase --- diff --git a/lib/DBIx/Class/SQLAHacks.pm b/lib/DBIx/Class/SQLAHacks.pm index faa3a48..32cc47f 100644 --- a/lib/DBIx/Class/SQLAHacks.pm +++ b/lib/DBIx/Class/SQLAHacks.pm @@ -466,7 +466,8 @@ sub _GenericSubQ { my $cmp_op = $direction eq 'desc' ? '>' : '<'; my $count_tbl_alias = 'rownum__emulation'; - my $order_group_having = $self->_parse_rs_attrs($rs_attrs); + my $order_sql = $self->_order_by (delete $rs_attrs->{order_by}); + my $group_having_sql = $self->_parse_rs_attrs($rs_attrs); # add the order supplement (if any) as this is what will be used for the outer WHERE $in_sel .= ", $_" for keys %{$extra_order_sel||{}}; @@ -474,9 +475,10 @@ sub _GenericSubQ { $sql = sprintf (<_quote ($_) } ( $rs_attrs->{alias}, diff --git a/t/sqlahacks/limit_dialects/generic_subq.t b/t/sqlahacks/limit_dialects/generic_subq.t index 7f924d1..8bd47b7 100644 --- a/t/sqlahacks/limit_dialects/generic_subq.t +++ b/t/sqlahacks/limit_dialects/generic_subq.t @@ -28,7 +28,6 @@ is_same_sql_bind( FROM books me JOIN owners owner ON owner.id = me.owner WHERE ( source = ? ) - ORDER BY me.title ) me WHERE ( @@ -36,6 +35,7 @@ is_same_sql_bind( FROM books rownum__emulation WHERE rownum__emulation.title < me.title ) < 2 + ORDER BY me.title )', [ [ 'source', 'Library' ] ], ); @@ -69,7 +69,6 @@ is_same_sql_bind( FROM "books" "me" JOIN "owners" "owner" ON "owner"."id" = "me"."owner" WHERE ( "source" = ? ) - ORDER BY "title" DESC ) "me" WHERE ( @@ -77,6 +76,7 @@ is_same_sql_bind( FROM "books" "rownum__emulation" WHERE "rownum__emulation"."title" > "me"."title" ) BETWEEN 1 AND 3 + ORDER BY "title" DESC )', [ [ 'source', 'Library' ] ], ); @@ -104,7 +104,6 @@ is_same_sql_bind( FROM "books" "me" JOIN "owners" "owner" ON "owner"."id" = "me"."owner" WHERE ( "source" = ? ) - ORDER BY "title" ) "me" WHERE ( @@ -112,6 +111,7 @@ is_same_sql_bind( FROM "books" "rownum__emulation" WHERE "rownum__emulation"."title" < "me"."title" ) BETWEEN 1 AND 4294967295 + ORDER BY "title" )', [ [ 'source', 'Library' ] ], );