From b3c3562ecf67ae7c94091287504579fcace6a500 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sat, 9 Nov 2019 16:12:30 -0500 Subject: Interpret empty LIMIT, expression LIMIT correctly Fixed issue in MSSQL dialect where an expression-based OFFSET value in a SELECT would be rejected, even though the dialect can render this expression inside of a ROW NUMBER-oriented LIMIT/OFFSET construct. Fixes: #4973 Change-Id: I040d34f781791c4ed5a727e1b8fb98c68ddd0622 --- lib/sqlalchemy/dialects/mssql/base.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/sqlalchemy/dialects') diff --git a/lib/sqlalchemy/dialects/mssql/base.py b/lib/sqlalchemy/dialects/mssql/base.py index 5d4de4a33..261ebe5c2 100644 --- a/lib/sqlalchemy/dialects/mssql/base.py +++ b/lib/sqlalchemy/dialects/mssql/base.py @@ -1612,7 +1612,10 @@ class MSSQLCompiler(compiler.SQLCompiler): if select._distinct: s += "DISTINCT " - if select._simple_int_limit and not select._offset: + if select._simple_int_limit and ( + select._offset_clause is None + or (select._simple_int_offset and select._offset == 0) + ): # ODBC drivers and possibly others # don't support bind params in the SELECT clause on SQL Server. # so have to use literal here. -- cgit v1.2.1