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

read_attribute does not do the type cast with PostgreSQL #5607

Closed
maxime-menant opened this issue Mar 27, 2012 · 4 comments
Closed

read_attribute does not do the type cast with PostgreSQL #5607

maxime-menant opened this issue Mar 27, 2012 · 4 comments

Comments

@maxime-menant
Copy link

I am migrating from mysql to PostgreSQL, in my Event model I redefine the accessor of one attribute (a datetime field) using

def start_date
  # some business logic to set the time zone
  read_attribute(:start_date)
end

But when I call event.startdate I get "2012-02-06 07:00:00" #String instead of Mon, 06 Feb 2012 07:00:00 0000 # DateTime with the mysql adapter

I think that is the behavior of "read_attribute_before_type_cast" and not "read_attribute", no ?

Using Ruby 1.9.2 / Rails 3.2.2 and PostgreSQL 9.1.3

@rafaelfranca
Copy link
Member

Hey @maxime-menant. I think it was fixed in the master version, but it was not a trivial fix, so I think it will not be backported to the 3-2-stable branch. Could you check your code with the Rails master branch?

Thanks for reporting.

cc @tenderlove

@tenderlove
Copy link
Member

Hi @maxime-menant, I'm closing this because it's a duplicate of #5549. I've made a fix on master, but we're discussing how to fix this on 3-2-stable in #5549.

@maxime-menant
Copy link
Author

Hi, thanks for your help!

I will try the 3-2 stable branch on my project when you have found how to backport the fix from the master.

@maxime-menant
Copy link
Author

It works with the last version of the 3-2-stable branch! Thanks a lot for this quick fix

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

No branches or pull requests

3 participants