Issue #121 wontfix

Read Attribute does not do typecasting as it should

lazarius
created an issue

I have an issue when I use 'read_attribute' on a timestamp attribute of my model, it return a String object instead of a DateTime object.

def start_date read_attribute(:start_date) end

event.startdate => "2012-02-06 07:00:00" #String

instead of Mon, 06 Feb 2012 07:00:00 0000 # DateTime

Using Rails 3.2.2 and Postgres 9.1

Comments (4)

  1. lazarius reporter

    I agree with the wiki that you need to provide a way to access to the "raw" data, but is not that the function of "read_attribute_before_type_cast" instead of "read_attribute" since it brake the model behavior if you use another driver (e.g. mysql2) ?

  2. Michael Granger repo owner

    That may be, but `read_attribute` is not implemented in the `pg` gem, it's implemented by whatever layer you're using on top of it. I'd guess ActiveRecord based on the fact that you're using Rails. You can't "use another driver" with `pg`, because it is the driver. Does that make sense?

    I suspect you really want to be filing a ticket with whoever maintains ActiveRecord's PostgreSQL adapter.

  3. Log in to comment