diff options
| author | Jesús Leganés Combarro "Piranna" <piranna@gmail.com> | 2012-05-15 16:23:17 +0200 |
|---|---|---|
| committer | Jesús Leganés Combarro "Piranna" <piranna@gmail.com> | 2012-05-15 16:23:17 +0200 |
| commit | fc67a2cb3cbf47512946f116b7d3d4d959e4d7f0 (patch) | |
| tree | d157649e031e337cff31075f2c91d76e78b6dc99 /sqlparse | |
| parent | cd39dca84378747ddf151e6d379c03e8c155fefc (diff) | |
| download | sqlparse-fc67a2cb3cbf47512946f116b7d3d4d959e4d7f0.tar.gz | |
Changed Limit to function
Diffstat (limited to 'sqlparse')
| -rw-r--r-- | sqlparse/filters.py | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/sqlparse/filters.py b/sqlparse/filters.py index 7efc75f..312999b 100644 --- a/sqlparse/filters.py +++ b/sqlparse/filters.py @@ -606,25 +606,21 @@ class OutputPHPFilter(OutputFilter): yield sql.Token(T.Punctuation, ';') -class Limit: +def limit(stream): """Get the LIMIT of a query. If not defined, return -1 (SQL specification for no LIMIT query) """ - def process(self, stack, stream): - warn("Deprecated, use callable objects. This will be removed at 0.2.0", - DeprecationWarning) - - index = 7 - stream = list(stream) - stream.reverse() + index = 7 + stream = list(stream) + stream.reverse() - # Run over all tokens in the stream from the end - for token_type, value in stream: - index -= 1 + # Run over all tokens in the stream from the end + for token_type, value in stream: + index -= 1 # if index and token_type in Keyword: - if index and token_type in Keyword and value == 'LIMIT': - return stream[4 - index][1] + if index and token_type in Keyword and value == 'LIMIT': + return stream[4 - index][1] - return -1 + return -1 |
