lib/pg_serializable/visitors/json.rb in pg_serializable-2.1.0 vs lib/pg_serializable/visitors/json.rb in pg_serializable-2.1.1

- old
+ new

@@ -54,11 +54,11 @@ def visit_enum(subject, table_alias: nil) key = "\'#{subject.label}\'" enum_hash = subject.klass.defined_enums[subject.column_name.to_s] val = "CASE \"#{table_alias}\".\"#{subject.column_name}\" " + - enum_hash.map do |val, int| - "WHEN #{int} THEN \'#{subject.prc ? subject.prc.call(val) : val}\'" + enum_hash.map do |enum_key, enum_value| + "WHEN #{enum_value.is_a?(String) ? "'#{enum_value}'" : enum_value} THEN \'#{subject.prc ? subject.prc.call(enum_key) : enum_key}\'" end.join(' ') + " ELSE NULL END" "#{key}, #{val}" end def visit_association(subject, **kwargs)