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

Keep column defaults in type cast form #15492

Merged
merged 1 commit into from
Jun 3, 2014

Conversation

sgrif
Copy link
Contributor

@sgrif sgrif commented Jun 3, 2014

The contract of _field_changed? assumes that the old value is always
type cast. That is not the case for the value in Column#default as
things are today. It appears there are other public methods that
assume that Column#default is type cast, as well. The reason for this
change originally was because the value gets put into @raw_attributes
in initialize. This reverts to the old behavior on Column, and updates
initialize to make sure that the values are in the right format.

The contract of `_field_changed?` assumes that the old value is always
type cast. That is not the case for the value in `Column#default` as
things are today. It appears there are other public methods that
assume that `Column#default` is type cast, as well. The reason for this
change originally was because the value gets put into `@raw_attributes`
in initialize. This reverts to the old behavior on `Column`, and updates
`initialize` to make sure that the values are in the right format.
sgrif referenced this pull request Jun 3, 2014
That data is internal to Active Record. What we care about is that
new records have the right default value.
senny added a commit that referenced this pull request Jun 3, 2014
…fault`."

Revert "test pg, remove unused column assignments. Follow up to 254cdf4"

Related to #15492

This reverts commit 254cdf4.
This reverts commit 4bcf902.

There are public methods that assume `Column#default` is type casted.
The return value of `Column#default` is publicly relevant and should not change.

/cc @sgrif
rafaelfranca added a commit that referenced this pull request Jun 3, 2014
Keep column defaults in type cast form
@rafaelfranca rafaelfranca merged commit a58dfea into rails:master Jun 3, 2014
@sgrif sgrif deleted the sg-dirty-defaults branch March 14, 2018 20:53
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

Successfully merging this pull request may close these issues.

2 participants