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

is_valid() gives false negative with PostgreSQL limit clause

castagninojose opened this issue · comments

I found the following case which seems to me to be a false negative. According to PG's documentation, setting LIMIT to either NULL or ALL should result in fetching all available rows (and it does).

import sqlvalidator

first_query = 'SELECT * FROM "my_table" LIMIT 10'
second_query = 'SELECT * FROM "my_table" LIMIT NULL'

Both these queries work as expected when run. However

>>> sqlvalidator.parse(first_query).is_valid()
True
>>> sqlvalidator.parse(second_query).is_valid()
False

Let me know if there's any piece of information I might have missed. If this case was considered already or it falls outside the scope of this tool feel free to close this issue.

Cheers.