Skip to content

Commit

Permalink
Serialize value for lob columns
Browse files Browse the repository at this point in the history
  • Loading branch information
yahonda committed Jun 29, 2016
1 parent a5837e2 commit 75ed13e
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,9 @@ def write_lobs(table_name, klass, attributes, columns) #:nodoc:
value = attributes[col.name]
# changed sequence of next two lines - should check if value is nil before converting to yaml
next if value.nil? || (value == '')
if klass.attribute_types[col.name].is_a? ActiveRecord::Type::Serialized
value = klass.attribute_types[col.name].serialize(value)
end
uncached do
sql = is_with_cpk ? "SELECT #{quote_column_name(col.name)} FROM #{quote_table_name(table_name)} WHERE #{klass.composite_where_clause(id)} FOR UPDATE" :
"SELECT #{quote_column_name(col.name)} FROM #{quote_table_name(table_name)} WHERE #{quote_column_name(klass.primary_key)} = #{id} FOR UPDATE"
Expand Down

0 comments on commit 75ed13e

Please sign in to comment.