fix: handle comments in has_table_query (#23882)

This commit is contained in:
Beto Dealmeida
2023-05-01 11:06:54 -07:00
committed by Elizabeth Thompson
parent 4af81bf70a
commit 60a1652be2
2 changed files with 11 additions and 1 deletions

View File

@@ -509,6 +509,9 @@ def has_table_query(token_list: TokenList) -> bool:
"""
state = InsertRLSState.SCANNING
for token in token_list.tokens:
# Ignore comments
if isinstance(token, sqlparse.sql.Comment):
continue
# Recurse into child token list
if isinstance(token, TokenList) and has_table_query(token):
@@ -607,7 +610,6 @@ def insert_rls(
rls: Optional[TokenList] = None
state = InsertRLSState.SCANNING
for token in token_list.tokens:
# Recurse into child token list
if isinstance(token, TokenList):
i = token_list.tokens.index(token)