Use "LIMIT <offset>, <limit>" syntax on MySQL to support older versions

Issue #794 resolved
Former user created an issue

As discussed on the mailing list:

http://groups.google.com/group/sqlalchemy/browse_thread/thread/b4b6bced77c9e67a/55fb4f81792f2d99#55fb4f81792f2d99

Old versions of MySQL don't support the LIMIT <limit> OFFSET <offset> syntax that SA currently uses. Instead they use LIMIT <limit>, <offset>. As far as I can tell there is no disadvantage to using the syntax on new versions of MySQL as well.

The attached patch changes MySQLCompiler.limit_clause to use the older syntax. I also added a test to the test suite in dialect/mysql.py, which passes. When I run the whole test suite I do get a number of errors, but I don't think they are related to my change.

The patch is against trunk revision 3515, but I think the same function definition could be used in the 0.3 branch.

Comments (2)

  1. jek

    Commited in 6f3f85e48c7dca360f029c23231711036c66a95f, thanks for the patch!

    I tested this up through 6.0 and there's no signs of deprecating the <offset>, <limit> syntax. That said, when it's easy to branch a dialog by server revision versions 4.0 and up will probably move back to the Postgres OFFSET syntax for better readability of the generated SQL.

  2. Log in to comment