Skip to content
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

Methods like by_week and by_month don't work on fields of Date type? #95

Open
neverhoodboy opened this issue Feb 26, 2023 · 0 comments
Open

Comments

@neverhoodboy
Copy link

neverhoodboy commented Feb 26, 2023

I'm on by_star version 4.0.1.

Suppose I'm at UTC-08:00 timezone and I have a config/application.rb like this:

class Application < Rails::Application
  config.time_zone = "Pacific Time (US & Canada)"
end

The following method call

ModelX.by_month(Date.today, field: :field_a)  # Today is 2023-02-26.

will generate a query like this:

SELECT `model_xs`.* FROM `model_xs` WHERE (field_a >= '2023-02-01 08:00:00' AND field_a <= '2023-03-01 07:59:59')

which is problematic because we cannot compare local date to UTC timestamp. Records with 2023-02-01 on field_a will not be included in the query result and records with 2023-03-01 on field_a will be.

I also came across this closed issue:
#49
According to this issue, the problem should be solved already. I'm not sure if I misunderstood the problem here.

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

No branches or pull requests

1 participant