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

[ActiveRecord] Fixes wrong time field's default day with timezone #51797

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

PedroAugustoRamalhoDuarte

Motivation / Background

This Pull Request has been created to fix #51679, a bug that appears when working with time field and timezones.

Basically, the bug occurs when ActiveRecord deserialized time field's day in other day but not the default one (01-01-2000), and it impacts validations and comparisons.

More details from the bug in the issue #51679.

Detail

This Pull Request changes the deserialized method TimeZoneConverter to always set the day for (01-01-2000) when we are working with the default time field.

Additional information

For alternative solutions, we have some options thanks to mkbehbehani #51679 (comment)

  • Using the ToD :time_only ActiveRecord attribute for Time of Day representation in application logic
  • In Postgres, using the time column type.
  • Timezone config for both Rails and Postgres set to UTC and performing changes into desired local timezone before read/write/comparison using .in_time_zone(location_timezone).

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one change. Unrelated changes should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug or add a feature.
  • CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.

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

Successfully merging this pull request may close these issues.

ActiveRecord time field issue with timezone
1 participant