Skip to content

Commit d9694ab

Browse files
committed
Coerce test
1 parent f0f30fd commit d9694ab

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/cases/coerced_tests.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2883,6 +2883,23 @@ def test_with_recursive_coerced
28832883
assert_equal top_companies_and_children, relation.order(:id).pluck(:id)
28842884
assert_match "WITH ", relation.to_sql
28852885
end
2886+
2887+
# Use truthy condition instead of "WHERE true".
2888+
# https://github.com/rails/rails/pull/55938
2889+
coerce_tests! :test_with_when_hash_with_multiple_elements_of_different_type_is_passed_as_an_argument
2890+
def test_with_when_hash_with_multiple_elements_of_different_type_is_passed_as_an_argument_coerced
2891+
# standard:disable Style/HashSyntax
2892+
cte_options = {
2893+
posts_with_tags: Post.arel_table.project(Arel.star).where(Post.arel_table[:tags_count].gt(0)),
2894+
posts_with_tags_and_truthy: Arel.sql("SELECT * FROM posts_with_tags WHERE 1=1"),
2895+
posts_with_tags_and_comments: Arel.sql("SELECT * FROM posts_with_tags_and_truthy WHERE tags_count > ?", 0),
2896+
"posts_with_tags_and_multiple_comments" => Post.where("legacy_comments_count > 1").from("posts_with_tags_and_comments AS posts")
2897+
}
2898+
# standard:enable Style/HashSyntax
2899+
relation = Post.with(cte_options).from("posts_with_tags_and_multiple_comments AS posts")
2900+
2901+
assert_equal POSTS_WITH_TAGS_AND_MULTIPLE_COMMENTS, relation.order(:id).pluck(:id)
2902+
end
28862903
end
28872904
end
28882905

0 commit comments

Comments
 (0)