Skip to content

Commit d9f1975

Browse files
committed
Update regex
1 parent 4af3e2c commit d9f1975

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
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|DROP|ALTER)\s+TABLE(?:\s+IF\s+(?:NOT\s+)?EXISTS)?))\s+["']?([\w.]+)["']?/i
18+
TABLE_NAME = /\b(?:(?:FROM|INTO|UPDATE)|(?:(?:CREATE|DROP|ALTER)\s+TABLE(?:\s+IF\s+(?:NOT\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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,9 @@
5050
{
5151
"name": "from_with_join",
5252
"sql": "SELECT columns FROM test_table JOIN table2 ON test_table.column = table2.column"
53+
},
54+
{
55+
"name": "table_name_with_double_quotes",
56+
"sql": "SELECT columns FROM \"test_table\""
5357
}
5458
]

0 commit comments

Comments
 (0)