Method: ActiveRecord::ConnectionAdapters::PostgreSQLColumn::Cast#array_to_string

Defined in:
lib/active_record/connection_adapters/postgresql/cast.rb

#array_to_string(value, column, adapter, should_be_quoted = false) ⇒ Object



70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/active_record/connection_adapters/postgresql/cast.rb', line 70

def array_to_string(value, column, adapter, should_be_quoted = false)
  casted_values = value.map do |val|
    if String === val
      if val == "NULL"
        "\"#{val}\""
      else
        quote_and_escape(adapter.type_cast(val, column, true))
      end
    else
      adapter.type_cast(val, column, true)
    end
  end
  "{#{casted_values.join(',')}}"
end