diff options
author | Andi Albrecht <albrecht.andi@gmail.com> | 2013-06-17 21:23:30 +0200 |
---|---|---|
committer | Andi Albrecht <albrecht.andi@gmail.com> | 2013-06-17 21:23:30 +0200 |
commit | b62b79f9550c1d36383c4bb41eb5dd1ca9474a59 (patch) | |
tree | 2e521584a661ad0fef7f1cb903bdf2885ae3e84d | |
parent | 14ca59da81146014657ded3019c9680e58ea17e4 (diff) | |
download | sqlparse-b62b79f9550c1d36383c4bb41eb5dd1ca9474a59.tar.gz |
Fix indentation and simplify processing logic in example (fixes issue98, issue99).
-rw-r--r-- | examples/extract_table_names.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/examples/extract_table_names.py b/examples/extract_table_names.py index dbe83f9..891ff6f 100644 --- a/examples/extract_table_names.py +++ b/examples/extract_table_names.py @@ -5,8 +5,8 @@ # http://groups.google.com/group/sqlparse/browse_thread/thread/b0bd9a022e9d4895 sql = """ -select K.a from (select H.b from (select G.c from (select F.d from -(select E.e from A, B, C, D, E), F), G), H), I, J, K; +select K.a,K.b from (select H.b from (select G.c from (select F.d from +(select E.e from A, B, C, D, E), F), G), H), I, J, K order by 1,2; """ import sqlparse @@ -24,12 +24,12 @@ def is_subselect(parsed): def extract_from_part(parsed): from_seen = False for item in parsed.tokens: - if item.ttype is Keyword: - from_seen = False - elif from_seen: + if from_seen: if is_subselect(item): for x in extract_from_part(item): yield x + elif item.ttype is Keyword: + raise StopIteration else: yield item elif item.ttype is Keyword and item.value.upper() == 'FROM': |