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

Add explicit typecasting for Booleans, Dates and DateTimes #9

Closed linozen closed 1 year ago

linozen commented 2 years ago

If this isn't done, it leads to errors with PostgreSQL:

sqlalchemy.exc.ProgrammingError: (psycopg2.errors.UndefinedFunction) function lower(boolean) does not exist
LINE 11: ...wer(person.language) ILIKE '%' || 'de' || '%' AND lower(pers...
                                                              ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
linozen commented 1 year ago

Hey @havok2063, I now added the same typecasting function for datetimes that I also added for boolean values. This should fix the errors one might encounter when using this package with SQLAlchemy and PostgreSQL as a database engine.

linozen commented 1 year ago

Ah, and I added tests to make sure the new typecasting functions work as expected. Let me know if you need anything else before merging this.

Many thanks for your work!