summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/selectable.py
diff options
context:
space:
mode:
authorDobes Vandermeer <dvandermeer@roovy.com>2014-05-09 11:27:30 -0700
committerDobes Vandermeer <dvandermeer@roovy.com>2014-05-09 11:27:30 -0700
commit9605b051b04aab66d5192f354b7a836c4957019c (patch)
tree2a802f925ca137f1dd8379fd7fbe7da623e0c385 /lib/sqlalchemy/sql/selectable.py
parent0d95386ca3cacff201717b1a390b3e1882262c36 (diff)
downloadsqlalchemy-9605b051b04aab66d5192f354b7a836c4957019c.tar.gz
Remove unused import
Diffstat (limited to 'lib/sqlalchemy/sql/selectable.py')
-rw-r--r--lib/sqlalchemy/sql/selectable.py35
1 files changed, 29 insertions, 6 deletions
diff --git a/lib/sqlalchemy/sql/selectable.py b/lib/sqlalchemy/sql/selectable.py
index 38a04334a..38188de72 100644
--- a/lib/sqlalchemy/sql/selectable.py
+++ b/lib/sqlalchemy/sql/selectable.py
@@ -64,6 +64,23 @@ def _offset_or_limit_clause(element, name=None, type_=None):
value = util.asint(element)
return BindParameter(name, value, type_=type_, unique=True)
+def _offset_or_limit_clause_asint(clause):
+ """
+ Get the integer value of an offset or limit clause, for database engines that
+ require it to be a plain integer instead of a BindParameter or other custom
+ clause.
+
+ If the clause is None, returns None.
+ If the clause is not a BindParameter, throws an exception.
+ If the clause is a BindParameter but its value is not set yet or not an int, throws an exception.
+ Otherwise, returns the integer in the clause.
+ """
+ if clause is None:
+ return None
+ if not isinstance(clause, BindParameter):
+ raise Exception("Limit is not a simple integer")
+ return util.asint(clause.effective_value)
+
def subquery(alias, *args, **kwargs):
"""Return an :class:`.Alias` object derived
from a :class:`.Select`.
@@ -1659,15 +1676,21 @@ class GenerativeSelect(SelectBase):
@property
def _limit(self):
- if not isinstance(self._limit_clause, BindParameter):
- return None
- return util.asint(self._limit_clause.effective_value)
+ """
+ Get an integer value for the limit. This should only be used by code that
+ cannot support a limit as a BindParameter or other custom clause as it will
+ throw an exception if the limit isn't currently set to an integer.
+ """
+ return _offset_or_limit_clause_asint(self._limit_clause)
@property
def _offset(self):
- if not isinstance(self._offset_clause, BindParameter):
- return None
- return util.asint(self._offset_clause.effective_value)
+ """
+ Get an integer value for the offset. This should only be used by code that
+ cannot support an offset as a BindParameter or other custom clause as it will
+ throw an exception if the offset isn't currently set to an integer.
+ """
+ return _offset_or_limit_clause_asint(self._offset_clause)
@_generative
def limit(self, limit):