Sha256: bbadbd710e2a1d2dc8f56d37daa20065881f5d057b1e097f664cb23dfdeda18c

Contents?: true

Size: 1.16 KB

Versions: 2

Compression:

Stored size: 1.16 KB

Contents

require File.expand_path('../abstract_unit', __FILE__)

class TestEqual < ActiveSupport::TestCase
  fixtures :departments

  include CompositePrimaryKeys::Predicates

  def test_or
    dep = Arel::Table.new(:departments)

    predicates = Array.new

    3.times do |i|
      predicates << dep[:id].eq(i)
    end

    connection = ActiveRecord::Base.connection
    quoted = "#{connection.quote_table_name('departments')}.#{connection.quote_column_name('id')}"
    expected = "(#{quoted} = 0 OR #{quoted} = 1 OR #{quoted} = 2)"

    pred = cpk_or_predicate(predicates)
    assert_equal(with_quoted_identifiers(expected), pred.to_sql)
  end

  # def test_and
  #   dep = Arel::Table.new(:departments)
  #
  #   predicates = Array.new
  #
  #   3.times do |i|
  #     predicates << dep[:id].eq(i)
  #   end
  #
  #   connection = ActiveRecord::Base.connection
  #   quoted = "#{connection.quote_table_name('departments')}.#{connection.quote_column_name('id')}"
  #   expected = "#{quoted} = 0 AND #{quoted} = 1 AND #{quoted} = 2"
  #
  #   pred = cpk_and_predicate(predicates)
  #   assert_equal(with_quoted_identifiers(expected), pred.to_sql)
  # end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
composite_primary_keys-8.1.3 test/test_predicates.rb
composite_primary_keys-8.1.2 test/test_predicates.rb