Repository navigation
Use correct precision. - #57
Merged
Merged
Conversation
alpaca-tc
force-pushed
the
use_correct_prescision
branch
2 times, most recently
from
July 7, 2020 15:16
18f4457 to
f676530
Compare
The expected result of `employee_deleted_at` is deleted record. However, whether or not the record is at the beginning of collection depends on the optimizer. Therefore, the rows should be filtered or ordered to return the same result.
alpaca-tc
force-pushed
the
use_correct_prescision
branch
from
July 7, 2020 15:16
f676530 to
da54ac3
Compare
wakasa51
approved these changes
Jul 9, 2020
wakasa51
left a comment
Member
There was a problem hiding this comment.
Thank you for this pull request!!
LGTM 👍
sugamasao
approved these changes
Jul 9, 2020
sugamasao
left a comment
Contributor
There was a problem hiding this comment.
Thanks for Great Pull Request 👍
LGTM 🎉
kamipo
added a commit
to kamipo/rails
that referenced
this pull request
Jul 13, 2020
```ruby
class Post < ActiveRecord::Base
attribute :written_at, default: -> { Time.now.utc }
end
# Rails 6.0
Post.type_for_attribute(:written_at) # => #<Type::Value ... precision: nil, ...>
# Rails 6.1
Post.type_for_attribute(:written_at) # => #<Type::DateTime ... precision: 6, ...>
```
This is an alternative of rails#39797.
Context rails#39797 (comment).
If people intend to override the existing type on the attribute, usually
an overriding type is explicitly specified, so I agree that the current
behavior (drop existing type information if type is omitted) is
practically quite useless, and it is almost like a bug in that there is
no way to override just the default.
So I'd like to change the current behavior on existing attributes
without a deprecation as a fix.
Closes rails#39797.
See also kufu/activerecord-bitemporal#57.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thank you for the great gem :)
ActiveRecord::Attributes.attributeoverrides the type of existing attributes. It isn't considered an expected behavior because database's subsecond precision is ignored by type caster.In default mysql, datetime should be rounded nsec because the default precision is 0.
Redefine the type in load_schema to use the correct precision dynamically fetched from the database.