Skip to content

Commit

Permalink
Merge pull request #2420 from newrelic/sql-testing
Browse files Browse the repository at this point in the history
Update SQL obfuscation tests to include cases for Active Record Query Logs
  • Loading branch information
kaylareopelle authored Feb 2, 2024
2 parents 68b72f8 + c7e3d8b commit 3ebd85a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -674,5 +674,35 @@
"cassandra",
"mssql"
]
},
{
"name": "prepended_comments_with_quotes.postgres",
"sql": "/*application:Demo,controller:posts,action:update*/ UPDATE \"posts\" SET \"updated_at\" = '2023-11-01 19:02:34.795909' WHERE \"posts\".\"id\" = 3",
"obfuscated": [
"? UPDATE \"posts\" SET \"updated_at\" = ? WHERE \"posts\".\"id\" = ?"
],
"dialects": [
"postgres"
]
},
{
"name": "prepended_comments_with_quotes.mysql",
"sql": "/*action='show',application='TrilogyTest',controller='users'*/ SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 LIMIT 1",
"obfuscated": [
"? SELECT `users`.* FROM `users` WHERE `users`.`id` = ? LIMIT ?"
],
"dialects": [
"mysql"
]
},
{
"name": "prepended_multiline_comments_with_quotes.mysql",
"sql": "/*action='show',\napplication='TrilogyTest',controller='users'*/\nSELECT `users`.*\nFROM `users`\nWHERE `users`.`id` = 1 LIMIT 1",
"obfuscated": [
"?\nSELECT `users`.*\nFROM `users`\nWHERE `users`.`id` = ? LIMIT ?"
],
"dialects": [
"mysql"
]
}
]
3 changes: 2 additions & 1 deletion test/fixtures/cross_agent_tests/sql_parsing.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@
{"input":"SELECT * /* a */ FROM alpha", "operation":"select", "table":"alpha"},
{"input":"SELECT * FROM /* a */ alpha", "operation":"select", "table":"alpha"},
{"input":"/* X */ SELECT /* Y */ foo/**/ FROM /**/alpha/**/", "operation":"select", "table":"alpha"},

{"input":"/* insert */ SELECT * FROM alpha", "operation":"select", "table":"alpha"},

{"input":"mystoredprocedure'123'", "operation":"other", "table":null},
{"input":"mystoredprocedure\t'123'", "operation":"other", "table":null},
{"input":"mystoredprocedure\r'123'", "operation":"other", "table":null},
Expand Down

0 comments on commit 3ebd85a

Please sign in to comment.