From 93eb88cbc88d239e70268b98ab9a96236c73efee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Legan=C3=A9s=20Combarro=20=22Piranna=22?= Date: Thu, 17 May 2012 16:44:52 +0200 Subject: Raise an exception on max recursion limit reached --- sqlparse/filters.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'sqlparse') diff --git a/sqlparse/filters.py b/sqlparse/filters.py index 9ee2ce0..8430687 100644 --- a/sqlparse/filters.py +++ b/sqlparse/filters.py @@ -93,6 +93,9 @@ class IncludeStatement: """Filter that enable a INCLUDE statement""" def __init__(self, dirpath=".", maxRecursive=10): + if maxRecursive <= 0: + raise ValueError('Max recursion limit reached') + self.dirpath = abspath(dirpath) self.maxRecursive = maxRecursive @@ -131,7 +134,8 @@ class IncludeStatement: # and add all its tokens to the main stack recursively # [ToDo] Add maximum recursive iteration value stack = FilterStack() - stack.preprocess.append(IncludeStatement(self.dirpath)) + stack.preprocess.append(IncludeStatement(self.dirpath, + self.maxRecursive - 1)) for tv in stack.run(raw_sql): yield tv -- cgit v1.2.1