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

Backport 0f1d0b1 to 5-0-stable #27554

Conversation

sgrif
Copy link
Contributor

@sgrif sgrif commented Jan 3, 2017

This is a backport of 0f1d0b1

This is a backport of 0f1d0b1

In f1a0fa9 we moved backend specific timestamp behavior out of the type
and into the adapter. This was in line with our general attempt to
reduce the number of adapter specific type subclasses. However, on PG,
the array type performs all serialization, including database encoding
in its serialize method.

This means that we have converted the value into a string before
reaching the database, so no adapter specific logic can be applied (and
this also means that timestamp arrays were using the default `.to_s`
method on the given object, which likely meant timestamps were being
ignored in certain cases as well)

Ultimately I want to do a more in depth refactoring which separates
database serializer objects from the active model type objects, to give
us a less awkward API for introducing the attributes API onto Active
Model.

However, in the short term, we follow the solution we've applied
elsewhere for this. Move behavior off of the type and into the adapter,
and use a data object to allow the type to communicate information up
the stack.

Fixes rails#27514.
@sgrif sgrif self-assigned this Jan 3, 2017
@rails-bot
Copy link

warning Warning warning

  • Pull requests are usually filed against the master branch for this repo, but this one is against 5-0-stable. Please double check that you specified the right target!

@sgrif
Copy link
Contributor Author

sgrif commented Jan 3, 2017

Failures are from flaky tests, unrelated to this change.

@sgrif sgrif merged commit c070f40 into rails:5-0-stable Jan 3, 2017
@sgrif sgrif deleted the sg-backport-0f1d0b1b5254e3678abaabbebb3362a100c10262 branch January 3, 2017 18:08
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.

None yet

3 participants