Skip to content

Instantly share code, notes, and snippets.

@ETetzlaff
Forked from otobrglez/casting_types.rb
Last active August 29, 2015 14:24
Show Gist options
  • Select an option

  • Save ETetzlaff/b3e3b79ab14b8d2f125d to your computer and use it in GitHub Desktop.

Select an option

Save ETetzlaff/b3e3b79ab14b8d2f125d to your computer and use it in GitHub Desktop.

Revisions

  1. @otobrglez otobrglez created this gist Mar 12, 2015.
    13 changes: 13 additions & 0 deletions casting_types.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    #!/usr/bin/env ruby

    # If you get "unknown OID 705: failed to recognize type of '<field>'. It will be treated as String."
    # it probably means that type of column could not be identified when retriving records

    # Example
    User.where("'something' as something")

    # Will results in unknown OID. However doing this:

    User.where("'something'::text as something")

    # Will just work. Casting is important, dude!