Skip to content

Commit

Permalink
Coerce test
Browse files Browse the repository at this point in the history
  • Loading branch information
aidanharan committed Sep 20, 2023
1 parent f354e98 commit 8c81e83
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions test/cases/coerced_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -870,14 +870,6 @@ class FinderTest < ActiveRecord::TestCase
coerce_tests! %r{doesn't have implicit ordering},
:test_find_doesnt_have_implicit_ordering

# Square brackets around column name
coerce_tests! :test_exists_does_not_select_columns_without_alias
def test_exists_does_not_select_columns_without_alias_coerced
assert_sql(/SELECT\s+1 AS one FROM \[topics\].*OFFSET 0 ROWS FETCH NEXT @0 ROWS ONLY.*@0 = 1/i) do
Topic.exists?
end
end

# Assert SQL Server limit implementation
coerce_tests! :test_take_and_first_and_last_with_integer_should_use_sql_limit
def test_take_and_first_and_last_with_integer_should_use_sql_limit_coerced
Expand Down Expand Up @@ -989,6 +981,15 @@ def test_implicit_order_for_model_without_primary_key_coerced
NonPrimaryKey.implicit_order_column = old_implicit_order_column
end

# Check for `FETCH NEXT x ROWS` rather then `LIMIT`.
coerce_tests! :test_member_on_unloaded_relation_with_composite_primary_key
def test_member_on_unloaded_relation_with_composite_primary_key_coerced
assert_sql(/1 AS one.* FETCH NEXT @(\d) ROWS ONLY.*@\1 = 1/) do
book = cpk_books(:cpk_great_author_first_book)
assert Cpk::Book.where(title: "The first book").member?(book)
end
end

# SQL Server is unable to use aliased SELECT in the HAVING clause.
coerce_tests! :test_include_on_unloaded_relation_with_having_referencing_aliased_select
end
Expand Down Expand Up @@ -1066,7 +1067,7 @@ def test_a_bad_type_column_coerced
def test_eager_load_belongs_to_primary_key_quoting_coerced
Account.connection
assert_sql(/\[companies\]\.\[id\] = @0.* @0 = 1/) do
Account.all.merge!(:includes => :firm).find(1)
Account.all.merge!(includes: :firm).find(1)
end
end
end
Expand Down

0 comments on commit 8c81e83

Please sign in to comment.