sqlvalidator icon indicating copy to clipboard operation
sqlvalidator copied to clipboard

Validation of bool for WHERE clause might be unnecessary

Open tatulea opened this issue 4 years ago • 1 comments

There are SQL queries that don't have a bool type in the where clause (e.g.: the usage of JSON_CONTAINS_PATH). https://github.com/David-Wobrock/sqlvalidator/blob/6b8732359e4c43c68d3550a10df5eea115417c1c/sqlvalidator/grammar/sql.py#L250 should be the place to change this.

tatulea avatar Sep 16 '20 06:09 tatulea

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)

David-Wobrock avatar Sep 23 '20 20:09 David-Wobrock