class ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Array::PG::TextEncoder::Array

Public Class Methods

new(name:, delimiter:) click to toggle source
# File lib/arjdbc/postgresql/base/array_encoder.rb, line 8
def initialize(name:, delimiter:)
  @type = if name == 'string[]'.freeze
            'text'.freeze
          else
            base_type = name.chomp('[]'.freeze).to_sym
            ActiveRecord::Base.connection.native_database_types[base_type][:name]
          end
end

Public Instance Methods

encode(values) click to toggle source
# File lib/arjdbc/postgresql/base/array_encoder.rb, line 17
def encode(values)
  ActiveRecord::Base.connection.jdbc_connection.create_array_of(@type, values.to_java).to_s
end