jfinkels / flask-restless

NO LONGER MAINTAINED - A Flask extension for creating simple ReSTful JSON APIs from SQLAlchemy models.
https://flask-restless.readthedocs.io
GNU Affero General Public License v3.0
1.02k stars 301 forks source link

filtering with date on datetime field using le #693

Open Dushyant7 opened 6 years ago

Dushyant7 commented 6 years ago

Name: Flask-Restless Version: 0.17.0

I am getting wrong results while filtering.

I have model defined like below:

class Session(Base):
    ...
    start_time = Column(DateTime, nullable=False, default=get_current_utc_datetime)
    end_time = Column(DateTime, onupdate=get_current_utc_datetime)
    ...

when I filter using simple date string api/session?q={"filters":[{"name":"start_time","op":"ge","val":"2018-10-19"},{"name":"end_time","op":"le","val":"2018-11-19"}]} I get 3 result. It does not include one result which has end_time "2018-11-19".

However when I filter using datetime iso string api/session?q={"filters":[{"name":"start_time","op":"ge","val":"2018-10-19"},{"name":"end_time","op":"le","val":"2018-11-19T23:59:59.000Z"}]} It returns 4 result which is correct.

It seems like edge case is not covered here when filtered using date.

Edit: I also tried api/session?q={"filters":[{"name":"start_time","op":"ge","val":"2018-10-19"},{"name":"end_time","op":"le","val":"2018-11-20"}]} It returns 4 results.