Skip to content

Commit 93f35a5

Browse files
committed
remove extra logic
Signed-off-by: Ihor Dykhta <dikhta.igor@gmail.com>
1 parent 761b0e8 commit 93f35a5

2 files changed

Lines changed: 20 additions & 16 deletions

File tree

src/duckdb/src/table/duckdb-table-utils.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -75,19 +75,12 @@ export function quoteTableName(columnName: string): string {
7575
return columnName;
7676
}
7777

78-
// If it contains dots and quotes, it might be a fully qualified name
78+
// If it contains both dots and quotes, assume it's a qualified name and return as-is
79+
// This avoids complex parsing that breaks with dots inside quotes like "my.schema"."table"
7980
if (columnName.includes('.') && columnName.includes('"')) {
80-
// Simple heuristic: if it looks like "part1"."part2" or "part1"."part2"."part3"
81-
// Split on dots and check if each part is quoted
82-
const parts = columnName.split('.');
83-
const allPartsQuoted = parts.every(
84-
part => part.trim().startsWith('"') && part.trim().endsWith('"') && part.trim().length > 2
85-
);
86-
87-
if (allPartsQuoted && parts.length >= 2) {
88-
return columnName;
89-
}
81+
return columnName;
9082
}
83+
9184
return `"${columnName.replace(/"/g, '""')}"`;
9285
}
9386

test/node/utils/duckdb-utils-test.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -514,19 +514,30 @@ test('duckdb-utils -> quoteTableName', t => {
514514
'should preserve qualified name with special chars'
515515
);
516516

517+
// Test qualified names with dots inside quotes (would break old parsing logic)
518+
t.equal(
519+
quoteTableName('"my.schema"."table.name"'),
520+
'"my.schema"."table.name"',
521+
'should preserve qualified name with dots inside quotes'
522+
);
523+
517524
// Test invalid fully qualified names (should get quoted)
518525
t.equal(quoteTableName('schema.table'), '"schema.table"', 'should quote unquoted qualified name');
519526
t.equal(
520527
quoteTableName('"schema".table'),
521-
'"""schema"".table"',
522-
'should quote partially quoted name'
528+
'"schema".table',
529+
'should preserve partially quoted name (trust user intent)'
523530
);
524531
t.equal(
525532
quoteTableName('schema."table"'),
526-
'"schema.""table"""',
527-
'should quote partially quoted name'
533+
'schema."table"',
534+
'should preserve partially quoted name (trust user intent)'
535+
);
536+
t.equal(
537+
quoteTableName('bad."format'),
538+
'bad."format',
539+
'should preserve name with dots and quotes (trust user intent)'
528540
);
529-
t.equal(quoteTableName('bad."format'), '"bad.""format"', 'should quote malformed qualified name');
530541

531542
// Test edge cases
532543
t.equal(quoteTableName(''), '""', 'should handle empty string');

0 commit comments

Comments
 (0)