]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- hardwire the huge LIMIT number on MySQL. this might fix the OurSQL py3k
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 6 Dec 2010 23:45:19 +0000 (18:45 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 6 Dec 2010 23:45:19 +0000 (18:45 -0500)
bug we're having, though I'm not able to get a good run of OurSQL
on OSX right now either Python 2 or 3.

lib/sqlalchemy/dialects/mysql/base.py
test/dialect/test_mysql.py

index a6e8f8c21bcaad26eea719454440452cb5dbaf5d..42072699e0befd84a35d6d89aa68af72b025aa4e 100644 (file)
@@ -1224,9 +1224,19 @@ class MySQLCompiler(compiler.SQLCompiler):
         elif offset is not None:
             # As suggested by the MySQL docs, need to apply an
             # artificial limit if one wasn't provided
+            # http://dev.mysql.com/doc/refman/5.0/en/select.html
             if limit is None:
-                limit = 18446744073709551615
-            return ' \n LIMIT %s, %s' % (
+                # hardwire the upper limit.  Currently
+                # needed by OurSQL with Python 3
+                # (https://bugs.launchpad.net/oursql/+bug/686232), 
+                # but also is consistent with the usage of the upper
+                # bound as part of MySQL's "syntax" for OFFSET with
+                # no LIMIT
+                return ' \n LIMIT %s, %s' % (
+                                self.process(sql.literal(offset)), 
+                                "18446744073709551615")
+            else:
+                return ' \n LIMIT %s, %s' % (
                                 self.process(sql.literal(offset)), 
                                 self.process(sql.literal(limit)))
         else:
index 7b06f412a56e5f934d75b0a203dd9d0a57ce0f65..02b888fed93ca395af6726bcb81d75dc7cab3202 100644 (file)
@@ -1073,8 +1073,8 @@ class SQLTest(TestBase, AssertsCompiledSQL):
             
         self.assert_compile(
             select([t]).offset(10),
-            "SELECT t.col1, t.col2 FROM t  LIMIT %s, %s",
-            {'param_1':10, 'param_2':18446744073709551615}
+            "SELECT t.col1, t.col2 FROM t  LIMIT %s, 18446744073709551615",
+            {'param_1':10}
             )
     
     def test_varchar_raise(self):