]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- make these failure cases more specific to catch Oracle.
authorMike Bayer <mike_mp@zzzcomputing.com>
Sat, 15 Aug 2015 17:52:24 +0000 (13:52 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sat, 15 Aug 2015 17:53:38 +0000 (13:53 -0400)
Would be nice to fix Oracle here

doc/build/changelog/migration_11.rst
lib/sqlalchemy/testing/requirements.py
lib/sqlalchemy/testing/suite/test_select.py
test/requirements.py

index 6ce0d031cfa9d0e75e57163d9b4e77aa0ffc25ce..727b820158497591e47471a34b337e3d567db999 100644 (file)
@@ -96,13 +96,15 @@ SQLAlchemy Core looks like::
 Previously, the above construct would not produce parenthesization for the
 inner SELECT statements, producing a query that fails on all backends.
 
-The above formats will **continue to fail on SQLite**.
+The above formats will **continue to fail on SQLite**; additionally, the format
+that includes ORDER BY but no LIMIT/SELECT will **continue to fail on Oracle**.
 This is not a backwards-incompatible change, because the queries fail without
 the parentheses as well; with the fix, the queries at least work on all other
 databases.
 
 In all cases, in order to produce a UNION of limited SELECT statements that
-also works on SQLite, the subqueries must be a SELECT of an ALIAS::
+also works on SQLite and in all cases on Oracle, the
+subqueries must be a SELECT of an ALIAS::
 
     stmt1 = select([table1.c.x]).order_by(table1.c.y).limit(1).alias().select()
     stmt2 = select([table2.c.x]).order_by(table2.c.y).limit(2).alias().select()
index 8b02f3e40504a8812b03193a8d0b0f91e23b4783..15bfad8310d137665f1ddefc4b33d0095cec2ef2 100644 (file)
@@ -111,8 +111,9 @@ class SuiteRequirements(Requirements):
         return exclusions.open()
 
     @property
-    def parens_in_union_contained_select(self):
-        """Target database must support parenthesized SELECT in UNION.
+    def parens_in_union_contained_select_w_limit_offset(self):
+        """Target database must support parenthesized SELECT in UNION
+        when LIMIT/OFFSET is specifically present.
 
         E.g. (SELECT ...) UNION (SELECT ..)
 
@@ -121,6 +122,20 @@ class SuiteRequirements(Requirements):
         """
         return exclusions.open()
 
+    @property
+    def parens_in_union_contained_select_wo_limit_offset(self):
+        """Target database must support parenthesized SELECT in UNION
+        when OFFSET/LIMIT is specifically not present.
+
+        E.g. (SELECT ... LIMIT ..) UNION (SELECT .. OFFSET ..)
+
+        This is known to fail on SQLite.  It also fails on Oracle
+        because without LIMIT/OFFSET, there is currently no step that
+        creates an additional subquery.
+
+        """
+        return exclusions.open()
+
     @property
     def boolean_col_expressions(self):
         """Target database must support boolean expressions as columns"""
index 0bcd35fd2440c01e10cec07653437482733e14bd..e7de356b8590ff17e2649f14e30feb83e71ee7da 100644 (file)
@@ -242,7 +242,7 @@ class CompoundSelectTest(fixtures.TablesTest):
             [(2, 2, 3), (3, 3, 4)]
         )
 
-    @testing.requires.parens_in_union_contained_select
+    @testing.requires.parens_in_union_contained_select_w_limit_offset
     def test_limit_offset_selectable_in_unions(self):
         table = self.tables.some_table
         s1 = select([table]).where(table.c.id == 2).\
@@ -256,7 +256,7 @@ class CompoundSelectTest(fixtures.TablesTest):
             [(2, 2, 3), (3, 3, 4)]
         )
 
-    @testing.requires.parens_in_union_contained_select
+    @testing.requires.parens_in_union_contained_select_wo_limit_offset
     def test_order_by_selectable_in_unions(self):
         table = self.tables.some_table
         s1 = select([table]).where(table.c.id == 2).\
@@ -283,7 +283,7 @@ class CompoundSelectTest(fixtures.TablesTest):
             [(2, 2, 3), (3, 3, 4)]
         )
 
-    @testing.requires.parens_in_union_contained_select
+    @testing.requires.parens_in_union_contained_select_w_limit_offset
     def test_limit_offset_in_unions_from_alias(self):
         table = self.tables.some_table
         s1 = select([table]).where(table.c.id == 2).\
index 939af4db154965b184968d422d639880ad1ba809..fc8a3afd9d0a116c0fed95aaf6328454983d238d 100644 (file)
@@ -362,14 +362,31 @@ class DefaultRequirements(SuiteRequirements):
             ], 'no support for EXCEPT')
 
     @property
-    def parens_in_union_contained_select(self):
-        """Target database must support parenthesized SELECT in UNION.
+    def parens_in_union_contained_select_w_limit_offset(self):
+        """Target database must support parenthesized SELECT in UNION
+        when LIMIT/OFFSET is specifically present.
 
         E.g. (SELECT ...) UNION (SELECT ..)
 
+        This is known to fail on SQLite.
+
         """
         return fails_if('sqlite')
 
+    @property
+    def parens_in_union_contained_select_wo_limit_offset(self):
+        """Target database must support parenthesized SELECT in UNION
+        when OFFSET/LIMIT is specifically not present.
+
+        E.g. (SELECT ... LIMIT ..) UNION (SELECT .. OFFSET ..)
+
+        This is known to fail on SQLite.  It also fails on Oracle
+        because without LIMIT/OFFSET, there is currently no step that
+        creates an additional subquery.
+
+        """
+        return fails_if('sqlite', 'oracle')
+
     @property
     def offset(self):
         """Target database must support some method of adding OFFSET or