sqlalchemy-filters icon indicating copy to clipboard operation
sqlalchemy-filters copied to clipboard

filter on DateTime and Time sqlalchemy column types

Open asabellico opened this issue 5 years ago • 2 comments

Hello!

I'm currently using this library but it seems like I'm not able to use operators gt and eq on sqlalchemy's Time column type.

I guess it is comparing using the value string representation of the information.. am I right? Is there a way to override the comparator for a particular column or at least override it globally?

Thank you

asabellico avatar Jun 07 '19 13:06 asabellico

Hi @asabellico , I'm glad you're using the library! Please let me take a look at it to see exactly what the behaviour is and how we could improve it.

juliotrigo avatar Jun 13 '19 17:06 juliotrigo

Hi @asabellico, I've taken a look at both datetime.time and datetime.datetime objects passed as filters to apply_filters and I can't see any problems with that on either MySQL or PostgreSQL.

Are you using a different DBMS (maybe SQLite)? If not, can you please provide an example of how you're trying to use it and how it fails (including the version of the DBMS you're using)?

You can see an example of datetime filters (passed as datetime objects) in the TestDateTimeFields class here https://github.com/juliotrigo/sqlalchemy-filters/blob/master/test/interface/test_filters.py#L760

I have also added some extra logic to test both datetime.time and datetime.datetime objects, also using isoformat ('03:05:09', '2016-07-14T03:05:09'): #38

juliotrigo avatar Jun 22 '19 16:06 juliotrigo