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 of bool for WHERE clause might be unnecessary

tatulea opened this issue · comments

There are SQL queries that don't have a bool type in the where clause (e.g.: the usage of JSON_CONTAINS_PATH).

if self.value.return_type != bool:
should be the place to change this.

Hi @tatulea, thanks for opening an issue :)
mysql/MariaDB indeed supports WHERE conditions on other column types than boolean. Good catch, thanks for reporting it.

I based myself on postgresql, where the condition is stricter:

ERROR:  argument of WHERE must be type boolean, not type integer
LINE 1: select * from sometable where id;

I'll probably make the validation a bit more permissive for now (even though the validation is only partly implemented)