Skip to content

SQLQuery.is_valid() raises an exception for with query statements #53

Description

@IlyaMichlin

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions