You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To Reproduce
I ran the function below to get the columns but "range" and "section" didn't return as expected.
def find_selected_columns(select_query):
tokens = sqlparse.parse(query)[0].tokens
found_select = False
for token in tokens:
if found_select:
if isinstance(token, sqlparse.sql.IdentifierList):
return [
col.value.split(" ")[-1].strip("`").rpartition('.')[-1]
for col in token.tokens
if isinstance(col, sqlparse.sql.Identifier)
]
else:
found_select = token.match(
sqlparse.tokens.Keyword.DML, ["select", "SELECT"])
raise Exception("Could not find a select statement. Weird query :)")
Expected behavior
Columns "range" and "section" needs to be returned.
Versions (please complete the following information):
Python: [e.g. 3.8.8]
sqlparse: [e.g. 0.4.4]
The text was updated successfully, but these errors were encountered:
Describe the bug
select_query = 'select locid, locname, drn, pipelineid, pipelineshortname, loctype, subtype, facilitytype, town, range, section, segmentmilepost, milemarker, segmentname, locpro, zone, dirflow, statuscode, state, county, unsubscribedcapacity, latitude, longitude, pbgroupcode, enableparkloan, updwnpartydrn, scadastationcode, updatedt, createon, getdate() ap_import_time from table1'
To Reproduce
I ran the function below to get the columns but "range" and "section" didn't return as expected.
def find_selected_columns(select_query):
tokens = sqlparse.parse(query)[0].tokens
found_select = False
for token in tokens:
if found_select:
if isinstance(token, sqlparse.sql.IdentifierList):
return [
col.value.split(" ")[-1].strip("`").rpartition('.')[-1]
for col in token.tokens
if isinstance(col, sqlparse.sql.Identifier)
]
else:
found_select = token.match(
sqlparse.tokens.Keyword.DML, ["select", "SELECT"])
raise Exception("Could not find a select statement. Weird query :)")
Expected behavior
Columns "range" and "section" needs to be returned.
Versions (please complete the following information):
The text was updated successfully, but these errors were encountered: