From: Peter Rabbitson Date: Thu, 10 Apr 2014 11:10:55 +0000 (+0200) Subject: Add explicit AS keyword to RowNum (Oracle) limit dialect X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=db2b35cc74e1128b2bb612caf771c5df9c4b636e;p=dbsrgits%2FDBIx-Class.git Add explicit AS keyword to RowNum (Oracle) limit dialect This should have no effect on the actual query, only done to bring in line with the generalized DQ engine --- diff --git a/lib/DBIx/Class/SQLMaker/LimitDialects.pm b/lib/DBIx/Class/SQLMaker/LimitDialects.pm index ec9300a..9abaded 100644 --- a/lib/DBIx/Class/SQLMaker/LimitDialects.pm +++ b/lib/DBIx/Class/SQLMaker/LimitDialects.pm @@ -221,7 +221,7 @@ sub _FirstSkip { Depending on the resultset attributes one of: SELECT * FROM ( - SELECT *, ROWNUM rownum__index FROM ( + SELECT *, ROWNUM AS rownum__index FROM ( SELECT ... ) WHERE ROWNUM <= ($limit+$offset) ) WHERE rownum__index >= ($offset+1) @@ -229,7 +229,7 @@ Depending on the resultset attributes one of: or SELECT * FROM ( - SELECT *, ROWNUM rownum__index FROM ( + SELECT *, ROWNUM AS rownum__index FROM ( SELECT ... ) ) WHERE rownum__index BETWEEN ($offset+1) AND ($limit+$offset) @@ -286,7 +286,7 @@ EOS return <{selection_outer} FROM ( - SELECT $sq_attrs->{selection_outer}, ROWNUM $idx_name FROM ( + SELECT $sq_attrs->{selection_outer}, ROWNUM AS $idx_name FROM ( SELECT $sq_attrs->{selection_inner} $sq_attrs->{query_leftover}${order_group_having} ) $qalias WHERE ROWNUM <= ? ) $qalias WHERE $idx_name >= ? @@ -297,7 +297,7 @@ EOS return <{selection_outer} FROM ( - SELECT $sq_attrs->{selection_outer}, ROWNUM $idx_name FROM ( + SELECT $sq_attrs->{selection_outer}, ROWNUM AS $idx_name FROM ( SELECT $sq_attrs->{selection_inner} $sq_attrs->{query_leftover}${order_group_having} ) $qalias ) $qalias WHERE $idx_name BETWEEN ? AND ? diff --git a/t/sqlmaker/limit_dialects/rownum.t b/t/sqlmaker/limit_dialects/rownum.t index b01790f..6985c23 100644 --- a/t/sqlmaker/limit_dialects/rownum.t +++ b/t/sqlmaker/limit_dialects/rownum.t @@ -42,7 +42,7 @@ for my $test_set ( sql => '( SELECT id, artist__id, bleh FROM ( - SELECT id, artist__id, bleh, ROWNUM rownum__index + SELECT id, artist__id, bleh, ROWNUM AS rownum__index FROM ( SELECT foo.id AS id, bar.id AS artist__id, TO_CHAR (foo.womble, "blah") AS bleh FROM cd me @@ -70,7 +70,7 @@ for my $test_set ( sql => '( SELECT id, artist__id, bleh FROM ( - SELECT id, artist__id, bleh, ROWNUM rownum__index + SELECT id, artist__id, bleh, ROWNUM AS rownum__index FROM ( SELECT foo.id AS id, bar.id AS artist__id, TO_CHAR(foo.womble, "blah") AS bleh FROM cd me @@ -102,7 +102,7 @@ for my $test_set ( sql => '( SELECT id, artist__id, bleh FROM ( - SELECT id, artist__id, bleh, ROWNUM rownum__index + SELECT id, artist__id, bleh, ROWNUM AS rownum__index FROM ( SELECT foo.id AS id, bar.id AS artist__id, TO_CHAR(foo.womble, "blah") AS bleh FROM cd me @@ -130,7 +130,7 @@ for my $test_set ( sql => '( SELECT id, ends_with_me__id FROM ( - SELECT id, ends_with_me__id, ROWNUM rownum__index + SELECT id, ends_with_me__id, ROWNUM AS rownum__index FROM ( SELECT foo.id AS id, ends_with_me.id AS ends_with_me__id FROM cd me @@ -157,7 +157,7 @@ for my $test_set ( sql => '( SELECT id, ends_with_me__id FROM ( - SELECT id, ends_with_me__id, ROWNUM rownum__index + SELECT id, ends_with_me__id, ROWNUM AS rownum__index FROM ( SELECT foo.id AS id, ends_with_me.id AS ends_with_me__id FROM cd me @@ -202,7 +202,7 @@ is_same_sql_bind( '( SELECT owner_name, owner_books FROM ( - SELECT owner_name, owner_books, ROWNUM rownum__index + SELECT owner_name, owner_books, ROWNUM AS rownum__index FROM ( SELECT owner.name AS owner_name, ( SELECT COUNT( * ) FROM owners owner WHERE (count.id = owner.id)) AS owner_books diff --git a/t/sqlmaker/limit_dialects/torture.t b/t/sqlmaker/limit_dialects/torture.t index f4e7d1d..f273189 100644 --- a/t/sqlmaker/limit_dialects/torture.t +++ b/t/sqlmaker/limit_dialects/torture.t @@ -392,7 +392,7 @@ my $tests = { '( SELECT me.id, owner__id, owner__name, bar, baz FROM ( - SELECT me.id, owner__id, owner__name, bar, baz, ROWNUM rownum__index + SELECT me.id, owner__id, owner__name, bar, baz, ROWNUM AS rownum__index FROM ( SELECT me.id, owner.id AS owner__id, owner.name AS owner__name, ? * ? AS bar, ? AS baz FROM books me @@ -428,7 +428,7 @@ my $tests = { '( SELECT me.id, owner__id, owner__name, bar, baz FROM ( - SELECT me.id, owner__id, owner__name, bar, baz, ROWNUM rownum__index + SELECT me.id, owner__id, owner__name, bar, baz, ROWNUM AS rownum__index FROM ( SELECT me.id, owner.id AS owner__id, owner.name AS owner__name, ? * ? AS bar, ? AS baz FROM books me @@ -459,7 +459,7 @@ my $tests = { FROM ( SELECT me.name, me.id FROM ( - SELECT me.name, me.id, ROWNUM rownum__index + SELECT me.name, me.id, ROWNUM AS rownum__index FROM ( SELECT me.name, me.id FROM owners me