Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions test/cases/coerced_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,14 @@ def test_should_return_decimal_average_of_integer_field_coerced
def test_limit_is_kept_coerced
queries = capture_sql_ss { Account.limit(1).count }
assert_equal 1, queries.length
queries.first.must_match %r{ORDER BY \[accounts\]\.\[id\] ASC OFFSET 0 ROWS FETCH NEXT @0 ROWS ONLY.*@0 = 1}
_(queries.first).must_match %r{ORDER BY \[accounts\]\.\[id\] ASC OFFSET 0 ROWS FETCH NEXT @0 ROWS ONLY.*@0 = 1}
end

coerce_tests! :test_limit_with_offset_is_kept
def test_limit_with_offset_is_kept_coerced
queries = capture_sql_ss { Account.limit(1).offset(1).count }
assert_equal 1, queries.length
queries.first.must_match %r{ORDER BY \[accounts\]\.\[id\] ASC OFFSET @0 ROWS FETCH NEXT @1 ROWS ONLY.*@0 = 1, @1 = 1}
_(queries.first).must_match %r{ORDER BY \[accounts\]\.\[id\] ASC OFFSET @0 ROWS FETCH NEXT @1 ROWS ONLY.*@0 = 1, @1 = 1}
end

# SQL Server needs an alias for the calculated column
Expand Down Expand Up @@ -265,7 +265,7 @@ class ColumnAttributesTest < ActiveRecord::TestCase
def test_add_column_without_limit_coerced
add_column :test_models, :description, :string, limit: nil
TestModel.reset_column_information
TestModel.columns_hash["description"].limit.must_equal 4000
_(TestModel.columns_hash["description"].limit).must_equal 4000
end
end
end
Expand Down Expand Up @@ -615,14 +615,14 @@ class PersistenceTest < ActiveRecord::TestCase
coerce_tests! :test_update_all_doesnt_ignore_order
def test_update_all_doesnt_ignore_order_coerced
david, mary = authors(:david), authors(:mary)
david.id.must_equal 1
mary.id.must_equal 2
david.name.wont_equal mary.name
_(david.id).must_equal 1
_(mary.id).must_equal 2
_(david.name).wont_equal mary.name
assert_sql(/UPDATE.*\(SELECT \[authors\].\[id\] FROM \[authors\].*ORDER BY \[authors\].\[id\]/i) do
Author.where('[id] > 1').order(:id).update_all(name: 'Test')
end
david.reload.name.must_equal 'David'
mary.reload.name.must_equal 'Test'
_(david.reload.name).must_equal 'David'
_(mary.reload.name).must_equal 'Test'
end

# We can not UPDATE identity columns.
Expand Down