From fc67a2cb3cbf47512946f116b7d3d4d959e4d7f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Legan=C3=A9s=20Combarro=20=22Piranna=22?= Date: Tue, 15 May 2012 16:23:17 +0200 Subject: Changed Limit to function --- sqlparse/filters.py | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'sqlparse') 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 -- cgit v1.2.1