Sha256: 539f2f68caa09214eff89ee6b29380da8c6b307b3e65fe85da1f757bd0de9ae8

Contents?: true

Size: 887 Bytes

Versions: 10

Compression:

Stored size: 887 Bytes

Contents

$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
require 'active_record'
require 'active_support'
require 'relation_to_struct'
require 'active_record_helper/setup'
require 'pry-byebug'

def active_record_supports_arrays?
  if defined?(@active_record_supports_arrays)
    @active_record_supports_arrays
  else
    supports_arrays = false
    ActiveRecord::Base.transaction do
      Economist.create!(name: 'F.A. Hayek')
      Economist.create!(name: 'Ludwig von Mises')

      pluck_results = Economist.select('name').order('id').limit(1).pluck('array[name]') rescue nil
      if pluck_results
        raise StandardError, "Unexpected array query results" unless pluck_results == [['F.A. Hayek']] # Verify ActiveRecord interface.
        supports_arrays = true
      end

      raise ActiveRecord::Rollback
    end
    @active_record_supports_arrays = supports_arrays
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
relation_to_struct-1.6.0 spec/spec_helper.rb
relation_to_struct-1.5.1 spec/spec_helper.rb
relation_to_struct-1.5.0 spec/spec_helper.rb
relation_to_struct-1.4.1 spec/spec_helper.rb
relation_to_struct-1.4.0 spec/spec_helper.rb
relation_to_struct-1.3.0 spec/spec_helper.rb
relation_to_struct-1.2.2 spec/spec_helper.rb
relation_to_struct-1.2.1 spec/spec_helper.rb
relation_to_struct-1.2.0 spec/spec_helper.rb
relation_to_struct-1.1.0 spec/spec_helper.rb