summaryrefslogtreecommitdiff
path: root/sqlparse
diff options
context:
space:
mode:
authorJesús Leganés Combarro "Piranna" <jesus.lc@vaelsys.com>2012-05-17 16:44:52 +0200
committerJesús Leganés Combarro "Piranna" <jesus.lc@vaelsys.com>2012-05-17 16:44:52 +0200
commit93eb88cbc88d239e70268b98ab9a96236c73efee (patch)
tree438d4f30ab5d260b0eff1cb0a6f6f0e5291a8215 /sqlparse
parent7f422d3e99bb21801db6f65619c876f709cdf44a (diff)
downloadsqlparse-93eb88cbc88d239e70268b98ab9a96236c73efee.tar.gz
Raise an exception on max recursion limit reached
Diffstat (limited to 'sqlparse')
-rw-r--r--sqlparse/filters.py6
1 files changed, 5 insertions, 1 deletions
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