havok2063 / boolean_parser

python package for parsing a string with boolean logic
https://boolean-parser.readthedocs.io/en/latest/index.html
BSD 3-Clause "New" or "Revised" License
14 stars 7 forks source link

`bindparam` leads to erronously repeated clause elements #11

Closed linozen closed 7 months ago

linozen commented 1 year ago

The bindparam function used to bind values when comparing strings with = or == leads to the following erroneous SQL queries being emitted to the database.

For example, the following clause

supporter_amount=10 and (zip=53* or zip=54*)

leads to the following SQL query (only WHERE clause is included):

...
WHERE person.supporter_amount = 10.0 
  AND (lower(person.zip) ILIKE '54%' 
  OR lower(person.zip) ILIKE '54%')

As you can see, the last element of the OR clause overwrites the first. This bug is fixed when removing the bindparam function in this code here.

havok2063 commented 7 months ago

Finally merging and closing this. Sorry for the long delay.