Spanner timestamp maps better to DateTime than Time#239
Spanner timestamp maps better to DateTime than Time#239Connorhd wants to merge 1 commit intogoogleapis:mainfrom
Conversation
Extending ActiveRecord::Type::Time means that string values get incorrectly coerced to have a date of 2000-01-01. See https://github.com/rails/rails/blob/main/activemodel/lib/active_model/type/time.rb#L14. This is because Time in activerecord is intended to store just the time value (and maps to a TIME type in other databases), unlike Time generally in ruby that represents a date and time.x
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
@Connorhd I agree with you that it would probably have been a better mapping, but this choice was made 3 years ago, and I'm afraid that changing it now could cause unwanted breakages in existing applications. Are you running into specific problems other than the default date of '2000-01-01' when using string values with this type? |
|
Yeah, that's the only problem I've seen so far. Definitely understand the hesitation and I'm not sure how to be confident there are not subtle issues caused that this. But, not making this change also seems quite risky, it seems pretty reasonable for activemodel (or anything built on top of it) to do strange things to the date component of these values as the type clearly only represents a time value. |
Extending ActiveRecord::Type::Time means that string values get incorrectly coerced to have a date of 2000-01-01. See https://github.com/rails/rails/blob/main/activemodel/lib/active_model/type/time.rb#L14. This is because Time in activerecord is intended to store just the time value (and maps to a TIME type in other databases), unlike Time generally in ruby that represents a date and time.