David-Wobrock / sqlvalidator

SQL queries formatting, syntactic and semantic validation

Home Page:https://pypi.org/project/sqlvalidator/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Validation examples suggestions

ReinierKoops opened this issue · comments

Hi David-Wobrock,

I really like the idea of this repository.

I've tried this tool and found that the following query is validated as valid; maybe something to add to the test cases:

"SELECT Name FROM singer WHERE Birth_Year = 1948 OR Birth_Year = 1949 SELECT SELECT"
"SELECT Name FROM singer WHERE Birth_Year = 1948 OR WHERE Birth_Year = 1949"
"SELECT Name FROM singer WHERE Birth_Year = 1948 SELECT name FROM a WHERE"

Hi Reinier,
Thanks for your feedback!

I have to admit that the first purpose of the tool is to format valid SQL.
However, the ultimate goal would be that the tool can also both:

  • reliably validate the syntax (what you are requesting basically)
  • validate the semantics (e.g. raise if my outer SELECT-query is selecting fields that are not exposed by my subquery)

I believe that syntax validation would be sweet, but the tool is not ready for that yet. I'm still mainly focusing on formatting. Sorry!