fix(kingbase): quote MySQL-compatible identifiers
This commit is contained in:
39 files changed
+373
-23
No files matched your search
@@ -5,6 +5,7 @@ export const TABLE_DATA_EXPORT_PAGE_SIZE = 10_000;
|
||||
|
||||
export interface FetchTableDataForExportOptions {
|
||||
databaseType?: DatabaseType;
|
||||
identifierQuote?: string;
|
||||
schema?: string;
|
||||
tableName: string;
|
||||
tableType?: string;
|
||||
@@ -24,6 +25,7 @@ export async function fetchTableDataForExport(options: FetchTableDataForExportOp
|
||||
while (true) {
|
||||
const sql = await (options.buildPageSql ?? buildTableSelectSql)({
|
||||
databaseType: options.databaseType,
|
||||
identifierQuote: options.identifierQuote,
|
||||
schema: options.schema,
|
||||
tableName: options.tableName,
|
||||
tableType: options.tableType,
|
||||
|
||||
@@ -5,6 +5,7 @@ import { parseSqlServerLinkedSchema, sqlServerLinkedTableName } from "@/lib/data
|
||||
|
||||
export interface BuildTableSelectSqlOptions {
|
||||
databaseType?: DatabaseType;
|
||||
identifierQuote?: string;
|
||||
schema?: string;
|
||||
tableName: string;
|
||||
tableType?: string;
|
||||
@@ -32,6 +33,14 @@ export function quoteTableIdentifier(databaseType: DatabaseType | undefined, nam
|
||||
return `"${name.replace(/"/g, '""')}"`;
|
||||
}
|
||||
|
||||
export function quoteTableDataIdentifier(databaseType: DatabaseType | undefined, name: string, identifierQuote?: string): string {
|
||||
if (databaseType === "kingbase" && identifierQuote != null) {
|
||||
if (!identifierQuote) return name;
|
||||
return `${identifierQuote}${name.replaceAll(identifierQuote, identifierQuote + identifierQuote)}${identifierQuote}`;
|
||||
}
|
||||
return quoteTableIdentifier(databaseType, name);
|
||||
}
|
||||
|
||||
function quoteCypherIdentifier(name: string): string {
|
||||
return `\`${name.replace(/`/g, "``")}\``;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user