mirror of
https://github.com/harelba/q.git
synced 2024-10-03 22:39:52 +03:00
wip
This commit is contained in:
parent
192ec6db4a
commit
4c03e6b026
13
bin/q.py
13
bin/q.py
@ -381,11 +381,19 @@ class Sql(object):
|
||||
|
||||
self.query_column_names = None
|
||||
|
||||
aliases_to_skip = []
|
||||
|
||||
# Go over all sql parts
|
||||
idx = 0
|
||||
while idx < len(self.sql_parts):
|
||||
# Get the part string
|
||||
part = self.sql_parts[idx]
|
||||
|
||||
if part.upper() == 'WITH':
|
||||
aliases_to_skip.append(self.sql_parts[idx + 1])
|
||||
idx += 2
|
||||
continue
|
||||
|
||||
# If it's a FROM or a JOIN
|
||||
if part.upper() in ['FROM', 'JOIN']:
|
||||
# and there is nothing after it,
|
||||
@ -395,6 +403,11 @@ class Sql(object):
|
||||
'FROM/JOIN is missing a table name after it')
|
||||
|
||||
qtable_name = self.sql_parts[idx + 1]
|
||||
|
||||
if qtable_name in aliases_to_skip:
|
||||
idx += 1
|
||||
continue
|
||||
|
||||
# Otherwise, the next part contains the qtable name. In most cases the next part will be only the qtable name.
|
||||
# We handle one special case here, where this is a subquery as a column: "SELECT (SELECT ... FROM qtable),100 FROM ...".
|
||||
# In that case, there will be an ending paranthesis as part of the name, and we want to handle this case gracefully.
|
||||
|
Loading…
Reference in New Issue
Block a user