fix(jdbc): pass through JDBC identifiers unquoted in frontend

This commit is contained in:
t8y2 2026-06-17 01:40:06 +08:00
parent 29e7267d31
commit a052bcd2cd
1 changed files with 3 additions and 6 deletions

View File

@ -18,7 +18,9 @@ export interface BuildTableSelectSqlOptions {
export function quoteTableIdentifier(databaseType: DatabaseType | undefined, name: string): string {
if (databaseType === "iotdb") return name;
if (databaseType === "jdbc") return quoteJdbcIdentifier(name);
// JDBC connections use the driver-reported identifier quote string
// (DatabaseMetaData.getIdentifierQuoteString()) — pass through unquoted.
if (databaseType === "jdbc") return name;
if (databaseType === "mysql" || databaseType === "hive" || databaseType === "databend" || databaseType === "tdengine" || databaseType === "access") return `\`${name.replace(/`/g, "``")}\``;
if (databaseType === "informix" && /^[A-Za-z_][A-Za-z0-9_$]*$/.test(name)) return name;
if (databaseType === "neo4j") return quoteCypherIdentifier(name);
@ -30,11 +32,6 @@ function quoteCypherIdentifier(name: string): string {
return `\`${name.replace(/`/g, "``")}\``;
}
function quoteJdbcIdentifier(name: string): string {
if (/^[A-Za-z_][A-Za-z0-9_$]*$/.test(name)) return name;
return `\`${name.replace(/`/g, "``")}\``;
}
export function qualifiedTableName(options: Pick<BuildTableSelectSqlOptions, "databaseType" | "schema" | "tableName">): string {
const { databaseType, schema, tableName } = options;
if (databaseType === "iotdb") {