Skip to content

Commit 3db2017

Browse files
committed
Stop accepting table name in single quotes
1 parent f3b9dfb commit 3db2017

File tree

2 files changed

+1
-5
lines changed

2 files changed

+1
-5
lines changed

instrumentation/pg/lib/opentelemetry/instrumentation/pg/patches/connection.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module Patches
1515
# Module to prepend to PG::Connection for instrumentation
1616
module Connection # rubocop:disable Metrics/ModuleLength
1717
# Capture the first word (including letters, digits, underscores, & '.', ) that follows common table commands
18-
TABLE_NAME = /\b(?:FROM|INTO|UPDATE|CREATE\s+TABLE(?:\s+IF\s+NOT\s+EXISTS)?|DROP\s+TABLE(?:\s+IF\s+EXISTS)?|ALTER\s+TABLE(?:\s+IF\s+EXISTS)?)\s+["']?([\w\.]+)["']?/i
18+
TABLE_NAME = /\b(?:FROM|INTO|UPDATE|CREATE\s+TABLE(?:\s+IF\s+NOT\s+EXISTS)?|DROP\s+TABLE(?:\s+IF\s+EXISTS)?|ALTER\s+TABLE(?:\s+IF\s+EXISTS)?)\s+["]?([\w\.]+)["]?/i
1919

2020
PG::Constants::EXEC_ISH_METHODS.each do |method|
2121
define_method method do |*args, &block|

instrumentation/pg/test/fixtures/sql_table_name.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,6 @@
5151
"name": "from_with_join",
5252
"sql": "SELECT columns FROM test_table JOIN table2 ON test_table.column = table2.column"
5353
},
54-
{
55-
"name": "table_name_with_single_quotes",
56-
"sql": "SELECT columns FROM 'test_table'"
57-
},
5854
{
5955
"name": "table_name_with_double_quotes",
6056
"sql": "SELECT columns FROM \"test_table\""

0 commit comments

Comments
 (0)