Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

postgresql - all returned .find_by_sql attributes are string

#808

Copying ticket 6631 ( http://dev.rubyonrails.org/ticke... ) over from Trac as I could not find this issue on Lighthouse.

Specifically, this problem seems to occur with Postgresql consistently whenever a column alias is used that does not match an AR attribute. Also I noticed that the patch attached to Trac ticket 6631 is not compatible with 2.1.2. so I'm assuming the workaround for now is to manually convert the results from find_by_sql?

Reported by Jason Yuen · August 12th, 2008 @ 08:23 PM

State: stale
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. Jason Yuen
    Jason Yuen
    • Title changed from [PATCH] postgresql - all returned .find_by_sql attributes are string to postgresql - all returned .find_by_sql attributes are string

    August 12th, 2008 @ 08:00 PM

  2. Tony Pitale
    Tony Pitale

    It seems the only type that is changed into another format by AR for postgresql is the Money type.

    See postgresql_adaptor.rb #select_raw, it may be of help fixing this.

    August 18th, 2008 @ 10:14 PM

  3. Tarmo Tänav
    Tarmo Tänav

    Looks like the newest postgresql gem, "pg", does not support translate_results, but it does implement "pgresult_ftype" which returns the OID of a column in a PGresult and would give us accurate information on the types of columns as known by postgresql.

    I'm not sure however if that could be misleading in certain cases. For example if AR expects a value for a string column, but we construct the query in a way that makes postgresql return an integer then it would be unclear if we should convert it to string or integer (the value is integer, but the column that it supposedly comes from is string).

    August 22nd, 2008 @ 09:18 PM

  4. josh
    josh
    • State changed from new to stale

    November 25th, 2008 @ 04:09 PM