Sha256: e628b34108399bb7bd1af78c83fa775fae7ce47cfc68bea0bf0448fc49067e32
Contents?: true
Size: 1.81 KB
Versions: 5
Compression:
Stored size: 1.81 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_or_with_many_values dep = Arel::Table.new(:departments) predicates = Array.new number_of_predicates = 30000 # This should really be big number_of_predicates.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_ungrouped = ((0...number_of_predicates).map { |i| "#{quoted} = #{i}" }).join(' OR ') expected = "(#{expected_ungrouped})" 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
5 entries across 5 versions & 1 rubygems