From 51fea2e159ca93daa0bc8066a5c35d8436d99418 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Thu, 7 Apr 2011 13:34:38 -0400 Subject: - The limit/offset keywords to select() as well as the value passed to select.limit()/offset() will be coerced to integer. [ticket:2116] (also in 0.6.7) - Oracle dialect adds use_binds_for_limits=False create_engine() flag, will render the LIMIT/OFFSET values inline instead of as binds, reported to modify the execution plan used by Oracle. [ticket:2116] (Also in 0.6.7) --- lib/sqlalchemy/sql/expression.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'lib/sqlalchemy/sql/expression.py') diff --git a/lib/sqlalchemy/sql/expression.py b/lib/sqlalchemy/sql/expression.py index 3323dcca9..f5ec41a60 100644 --- a/lib/sqlalchemy/sql/expression.py +++ b/lib/sqlalchemy/sql/expression.py @@ -3972,6 +3972,8 @@ class _SelectBase(Executable, FromClause): _order_by_clause = ClauseList() _group_by_clause = ClauseList() + _limit = None + _offset = None def __init__(self, use_labels=False, @@ -3991,8 +3993,10 @@ class _SelectBase(Executable, FromClause): self._execution_options = \ self._execution_options.union({'autocommit' : autocommit}) - self._limit = limit - self._offset = offset + if limit is not None: + self._limit = util.asint(limit) + if offset is not None: + self._offset = util.asint(offset) self._bind = bind if order_by is not None: @@ -4061,14 +4065,14 @@ class _SelectBase(Executable, FromClause): """return a new selectable with the given LIMIT criterion applied.""" - self._limit = limit + self._limit = util.asint(limit) @_generative def offset(self, offset): """return a new selectable with the given OFFSET criterion applied.""" - self._offset = offset + self._offset = util.asint(offset) @_generative def order_by(self, *clauses): -- cgit v1.2.1