Sha256: 9846b099276090eecd2cd3e4e26766967da3238cbf7a547b127537a112319faa
Contents?: true
Size: 800 Bytes
Versions: 29
Compression:
Stored size: 800 Bytes
Contents
# frozen_string_literal: true # This implements a basic encoder to work around ActiveRecord's dependence on the pg gem module ActiveRecord::ConnectionAdapters::PostgreSQL::OID class Array < ActiveModel::Type::Value module PG module TextEncoder class Array def initialize(name:, delimiter:) @type = if name == 'string[]' 'text'.freeze else base_type = name.chomp('[]').to_sym ActiveRecord::Base.connection.native_database_types[base_type][:name] end end def encode(values) ActiveRecord::Base.connection.jdbc_connection.create_array_of(@type, values.to_java).to_s end end end end end end
Version data entries
29 entries across 29 versions & 2 rubygems