summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorRobert Nix <com.github@rnix.org>2013-06-17 10:56:03 -0300
committerRobert Nix <com.github@rnix.org>2013-06-17 10:56:03 -0300
commit7d0fb12663479da1dd8b1d9a2ee97527c6c51863 (patch)
treee3f29b658a7f4766f0cfd96ea33fc90ad00d4944 /examples
parent91a9efe0511ab5b1c769d90c04b8b329fe3173ad (diff)
downloadsqlparse-7d0fb12663479da1dd8b1d9a2ee97527c6c51863.tar.gz
Stop parsing tables at first keyword after "from".
Currently, the parser isn't smart enough to acknowledge the end of the from-clause list so keywords as table names will still fail. But in simple tests, this solution works. Best-practice: don't use SQL keywords as table names. :)
Diffstat (limited to 'examples')
-rw-r--r--examples/extract_table_names.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/examples/extract_table_names.py b/examples/extract_table_names.py
index b153850..dbe83f9 100644
--- a/examples/extract_table_names.py
+++ b/examples/extract_table_names.py
@@ -24,7 +24,9 @@ def is_subselect(parsed):
def extract_from_part(parsed):
from_seen = False
for item in parsed.tokens:
- if from_seen:
+ if item.ttype is Keyword:
+ from_seen = False
+ elif from_seen:
if is_subselect(item):
for x in extract_from_part(item):
yield x