]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Extract limit/offset to variables
authorDobes Vandermeer <dvandermeer@roovy.com>
Fri, 25 Apr 2014 17:22:50 +0000 (10:22 -0700)
committerDobes Vandermeer <dvandermeer@roovy.com>
Fri, 25 Apr 2014 17:22:50 +0000 (10:22 -0700)
lib/sqlalchemy/dialects/sybase/base.py

index 501270778f5e3377d0f82d212be4f1d33ea293d7..3e61b5ba68481af4873990bc4646881019a5b0a7 100644 (file)
@@ -325,18 +325,20 @@ class SybaseSQLCompiler(compiler.SQLCompiler):
         s = select._distinct and "DISTINCT " or ""
         # TODO: don't think Sybase supports
         # bind params for FIRST / TOP
-        if select._limit:
+        limit = select._limit
+        if limit:
             #if select._limit == 1:
                 #s += "FIRST "
             #else:
                 #s += "TOP %s " % (select._limit,)
-            s += "TOP %s " % (select._limit,)
-        if select._offset:
-            if not select._limit:
+            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 " % (select._offset + 1,)
+            s += "START AT %s " % (offset + 1,)
         return s
 
     def get_from_hint_text(self, table, text):