Skip to content

Wrong value for lteq_datetime predicate #61

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
aleksey-alt opened this issue Oct 14, 2019 · 5 comments
Closed

Wrong value for lteq_datetime predicate #61

aleksey-alt opened this issue Oct 14, 2019 · 5 comments

Comments

@aleksey-alt
Copy link

DateTimeRangeInput inherits from ActiveAdmin's DateRangeInput. So it uses lteq_datetime predicate. But definition of this predicate is correct if we use date part of the datetime/timestamp value rather than whole value
https://github.com/activeadmin/activeadmin/blob/v2.3.1/lib/ransack_ext.rb#L17

So now if end range field of the date_time_range filter is non-empty we always get incorrect request to DB.

For the whole value when lteq predicate is being converted to lt predicate then microseconds have to be increased by 1 (at least for Postgresql that stores timestamps with microsecond resolution) instead of days.

@workgena
Copy link
Contributor

workgena commented Oct 14, 2019

Oh, thank you for this finding. It is a shame we haven't noticed it by our-self's 🦀

And I'm afraid we have this bug for a long time.
I'll create PR with new failing specs pointing this issue. We'll try to fix this ASP 👷 🛠

workgena added a commit to workgena/active_admin_datetimepicker that referenced this issue Oct 14, 2019
@doridayan
Copy link

Hi @workgena, I work with @aleksey-alt, who reported this issue. Thanks so much for the fast fix!
Do you know when it's expected to be merged?

@workgena
Copy link
Contributor

workgena commented Oct 15, 2019

Current PR doesn't work correctly. It may take a few days for find working solution.

@workgena
Copy link
Contributor

@aleksey-alt @doridayan fix version 0.7.3 has been published.

But during test we found another issue(which won't be fixed soon). When submitting the form, the value(for example "2019-10-16 10:00") will be directly passed to SQL query. It may lead to User-Experience misunderstanding in case the server and user are located in different time-zones. Often database timestamp is UTC. Thus, user must understand that time hi selected is an UTC, not his timezone.

@doridayan
Copy link

@workgena Thank you! We only use UTC time anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants