Last active
December 12, 2015 03:28
-
-
Save AlexanderPavlenko/4706680 to your computer and use it in GitHub Desktop.
fix PostgreSQL comparison of string and number
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Arel::Visitors | |
class ToSql | |
alias :visit_Fixnum :quoted | |
alias :visit_Bignum :quoted | |
end | |
end | |
module ActiveRecord::ConnectionAdapters | |
class PostgreSQLAdapter | |
module FixNumberToStringComparison | |
def quote(value, column) | |
if value.is_a?(Numeric) && column.type == :string | |
"'#{value}'" | |
else | |
super | |
end | |
end | |
end | |
include FixNumberToStringComparison | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment