]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- The unsupported Sybase dialect now raises ``NotImplementedError``
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 20 Jan 2016 21:32:27 +0000 (16:32 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 20 Jan 2016 21:32:27 +0000 (16:32 -0500)
when attempting to compile a query that includes "offset"; Sybase
has no straightforward "offset" feature.  fixes #2278

doc/build/changelog/changelog_11.rst
lib/sqlalchemy/dialects/sybase/base.py
test/dialect/test_sybase.py

index 80c8ece33b493c6dd47757300e36ecc71c77abe0..23965818e0fc4e5eda943b8207e42b811aaef075 100644 (file)
 .. changelog::
     :version: 1.1.0b1
 
+    .. change::
+        :tags: bug, sybase
+        :tickets: 2278
+
+        The unsupported Sybase dialect now raises ``NotImplementedError``
+        when attempting to compile a query that includes "offset"; Sybase
+        has no straightforward "offset" feature.
+
     .. change::
         :tags: feature, orm
         :tickets: 3631
index b3f8e307af76f49546cb884acc5902f5910a32b0..18752183157a4519a3279317e01c6f5ac8d4a9ac 100644 (file)
@@ -336,11 +336,7 @@ class SybaseSQLCompiler(compiler.SQLCompiler):
             s += "TOP %s " % (limit,)
         offset = select._offset
         if offset:
-            if not limit:
-                # FIXME: sybase doesn't allow an offset without a limit
-                # so use a huge value for TOP here
-                s += "TOP 1000000 "
-            s += "START AT %s " % (offset + 1,)
+            raise NotImplementedError("Sybase ASE does not support OFFSET")
         return s
 
     def get_from_hint_text(self, table, text):
index 1318a282bd00a968955098e2795b44abce235194..d8f7d3aaec65dbbd381588ec89c5e3efc47c5b33 100644 (file)
@@ -1,7 +1,8 @@
-from sqlalchemy import *
+from sqlalchemy import extract, select
 from sqlalchemy import sql
 from sqlalchemy.databases import sybase
-from sqlalchemy.testing import *
+from sqlalchemy.testing import assert_raises_message, \
+    fixtures, AssertsCompiledSQL
 
 
 class CompileTest(fixtures.TestBase, AssertsCompiledSQL):
@@ -17,12 +18,19 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL):
             'milliseconds': 'millisecond',
             'millisecond': 'millisecond',
             'year': 'year',
-            }
+        }
 
         for field, subst in list(mapping.items()):
             self.assert_compile(
                 select([extract(field, t.c.col1)]),
                 'SELECT DATEPART("%s", t.col1) AS anon_1 FROM t' % subst)
 
+    def test_offset_not_supported(self):
+        stmt = select([1]).offset(10)
+        assert_raises_message(
+            NotImplementedError,
+            "Sybase ASE does not support OFFSET",
+            stmt.compile, dialect=self.__dialect__
+        )