I recently upgraded the rails version of my application from 6.1 to 7. After upgrading I found that sanitize_sql_array is now changing the integer values to string.
Below are the attributes that I am passing to the method:
updates = ["`bed_count` = `bed_count` + ?", "`operating_room_count` = `operating_room_count` + ?", "`updated_at` = ?"]
values = [3.14159, 1, "2022-09-17 18:15:05"]
Now when the run the method I get the following output:
>> ActiveRecord::Base.send(:sanitize_sql_array, [updates.join(','), *values])
=> "`bed_count` = `bed_count` + '3.14159',`operating_room_count` = `operating_room_count` + '1',`updated_at` = '2022-09-17 18:33:44'"
Notice that the 3.14159 and 1 is now changed to string even though I provided integer values.
When I ran the same code in Rails 6.1, I got the following output:
"`bed_count` = `bed_count` + 3.14159,`operating_room_count` = `operating_room_count` + 1,`updated_at` = '2022-09-17 18:33:44'"
Does anybody know how can I fix this ?
send? It's public method, you canActiveRecord::Base.sanitize_sql_array([updates.join(','), *values])ActiveRecord::Base.sanitize_sql_array([updates.join(','), *values])but still got the same output with string instead of numeric. "bed_count=bed_count+ '3.14159',operating_room_count=operating_room_count+ '1',updated_at= '2022-09-17 18:15:05'"