Skip to content

Commit

Permalink
Fix bound parameters in prepared statements.
Browse files Browse the repository at this point in the history
Rails 3.2+ supports prepared statements; this bypasses the current intercepts for turning arrays into the PG format. An example case: inserts (not updates) in ActiveRecord 3.2+.
  • Loading branch information
jcoleman committed Jul 4, 2012
1 parent 16ec308 commit 266a322
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/ar_pg_array/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,15 @@ def type_to_sql_with_postgresql_arrays(type, limit = nil, precision = nil, scale
end

alias_method_chain :type_to_sql, :postgresql_arrays

def type_cast_with_postgresql_arrays(value, column)
if Array === value && column && "#{column.type}" =~ /^(.+)_array$/
prepare_array_for_arel_by_base_type(value, $1)
else
type_cast_without_postgresql_arrays(value, column)
end
end
alias_method_chain :type_cast, :postgresql_arrays
end
end
end
Expand Down

0 comments on commit 266a322

Please sign in to comment.