File tree Expand file tree Collapse file tree 2 files changed +7
-2
lines changed
lib/active_record/relation Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -1909,8 +1909,6 @@ def build_with(arel)
1909
1909
return if with_values . empty?
1910
1910
1911
1911
with_statements = with_values . map do |with_value |
1912
- raise ArgumentError , "Unsupported argument type: #{ with_value } #{ with_value . class } " unless with_value . is_a? ( Hash )
1913
-
1914
1912
build_with_value_from_hash ( with_value )
1915
1913
end
1916
1914
@@ -2243,6 +2241,7 @@ def arel_column_aliases_from_hash(fields)
2243
2241
2244
2242
def process_with_args ( args )
2245
2243
args . flat_map do |arg |
2244
+ raise ArgumentError , "Unsupported argument type: #{ arg } #{ arg . class } " unless arg . is_a? ( Hash )
2246
2245
arg . map { |k , v | { k => v } }
2247
2246
end
2248
2247
end
Original file line number Diff line number Diff line change @@ -36,6 +36,12 @@ def test_with_when_hash_with_multiple_elements_of_different_type_is_passed_as_an
36
36
assert_equal POSTS_WITH_TAGS_AND_MULTIPLE_COMMENTS , relation . order ( :id ) . pluck ( :id )
37
37
end
38
38
39
+ def test_with_when_invalid_argument_is_passed
40
+ assert_raises ArgumentError , match : /\A Unsupported argument type: #<Post:0x[0-9a-f]+> Post\z / do
41
+ Post . with ( Post . where ( "tags_count > 0" ) )
42
+ end
43
+ end
44
+
39
45
def test_multiple_with_calls
40
46
relation = Post
41
47
. with ( posts_with_tags : Post . where ( "tags_count > 0" ) )
You can’t perform that action at this time.
0 commit comments