David-Wobrock / sqlvalidator

SQL queries formatting, syntactic and semantic validation
https://pypi.org/project/sqlvalidator/
MIT License
67 stars 16 forks source link

validate() missing 1 required positional argument: 'known_fields' #39

Open timotta opened 2 years ago

timotta commented 2 years ago

Using python 3.9 and sqlvalidator==0.0.18

When running sqlvalidator.parse(query).is_valid() i'm getting

    def _validate(self):
        self.validated = True
        try:
>           self.errors = self.sql_query.validate()
E           TypeError: validate() missing 1 required positional argument: 'known_fields'

The class of self.sql_query is WithStatement

David-Wobrock commented 2 years ago

Hey @timotta

Thanks for opening an issue.

What's the content of the query variable? :) So that I can reproduce the issue

vchauhan-ai commented 2 years ago

I am getting similar issue. When I am validating the query using WITH to create an alias, then it is giving this error

MilesMartinez commented 1 year ago

I get this error when attempting to use WITH AS as well.

Example

with cte as (select * from a)
select * from cte