sqlvalidator
sqlvalidator copied to clipboard
`SQLQuery.is_valid()` raises an exception for `with` query statements
SQLQuery.is_valid()
raises an exception for with
query statements:
from sqlvalidator.sql_validator import SQLQuery
sql_with = """with a as (select * from b) select * from a """
sql_query = SQLQuery(sql_with)
sql_query.is_valid()
# TypeError: Expression.validate() missing 1 required positional argument: 'known_fields'
sql_query.is_valid()
# True
sql_select = """select * from a"""
sql_query = SQLQuery(sql_select)
sql_query.is_valid()
# True
After digging a bit in the code, the issue is that when calling self.sql_query.validate(). While SelectStatement.validate has a default value for known_fields
, WithStatement.validate does not have.