Skip to content

Commit

Permalink
Coerce test
Browse files Browse the repository at this point in the history
  • Loading branch information
aidanharan committed Oct 1, 2024
1 parent c25db90 commit 4838cd6
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/cases/coerced_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2484,6 +2484,25 @@ def test_sqlcommenter_format_value_string_coercible_coerced
end
end

# SQL requires double single-quotes.
coerce_tests! :test_sqlcommenter_format_allows_string_keys
def test_sqlcommenter_format_allows_string_keys_coerced
ActiveRecord::QueryLogs.update_formatter(:sqlcommenter)

ActiveRecord::QueryLogs.tags = [
:application,
{
"string" => "value",
tracestate: "congo=t61rcWkgMzE,rojo=00f067aa0ba902b7",
custom_proc: -> { "Joe's Shack" }
},
]

assert_queries_match(%r{custom_proc=''Joe%27s%20Shack'',string=''value'',tracestate=''congo%3Dt61rcWkgMzE%2Crojo%3D00f067aa0ba902b7''\*/}) do
Dashboard.first
end
end

# Invalid character encoding causes `ActiveRecord::StatementInvalid` error similar to Postgres.
coerce_tests! :test_invalid_encoding_query
def test_invalid_encoding_query_coerced
Expand Down

0 comments on commit 4838cd6

Please sign in to comment.