Skip to content

Commit d68c566

Browse files
committed
Replace GREATEST with CASE
1 parent 23020a9 commit d68c566

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

test/cases/coerced_tests.rb

+8-2
Original file line numberDiff line numberDiff line change
@@ -2553,12 +2553,18 @@ def test_insert_with_type_casting_and_serialize_is_consistent_coerced
25532553
Book.lease_connection.add_index(:books, [:author_id, :name], unique: true)
25542554
end
25552555

2556-
# Same as original but using target.status for assignment and GREATEST for operator
2556+
# Same as original but using target.status for assignment and CASE instead of GREATEST for operator
25572557
coerce_tests! :test_upsert_all_updates_using_provided_sql
25582558
def test_upsert_all_updates_using_provided_sql_coerced
25592559
Book.upsert_all(
25602560
[{id: 1, status: 1}, {id: 2, status: 1}],
2561-
on_duplicate: Arel.sql("target.status = GREATEST(target.status, 1)")
2561+
on_duplicate: Arel.sql(<<~SQL
2562+
target.status = CASE
2563+
WHEN target.status > 1 THEN target.status
2564+
ELSE 1
2565+
END
2566+
SQL
2567+
)
25622568
)
25632569

25642570
assert_equal "published", Book.find(1).status

0 commit comments

Comments
 (0)