This project is archived and is in readonly mode.

#808 ✓stale
Jason Yuen

postgresql - all returned .find_by_sql attributes are string

Reported by Jason Yuen | August 12th, 2008 @ 08:23 PM | in 2.x

Copying ticket 6631 ( ) 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?

Comments and changes to this ticket

  • Jason Yuen

    Jason Yuen August 12th, 2008 @ 08:00 PM

    • Title changed from “[PATCH] postgresql - all returned .find_by_sql attributes are string” to “postgresql - all returned .find_by_sql attributes are string”
  • Tony Pitale

    Tony Pitale August 18th, 2008 @ 10:14 PM

    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.

  • Tarmo Tänav

    Tarmo Tänav August 22nd, 2008 @ 09:18 PM

    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).

  • josh

    josh November 25th, 2008 @ 04:09 PM

    • State changed from “new” to “stale”

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>