fix(query): fold unquoted postgresql table identities for grid saves
This commit is contained in:
1 parent
9540f51dce
commit
4949cce746
5 files changed
+306
-4
No files matched your search
@@ -56,9 +56,23 @@ export interface EditableQuerySource {
|
||||
alias?: string;
|
||||
}
|
||||
|
||||
const POSTGRES_FOLDED_IDENTIFIER_TYPES = new Set(["postgres", "redshift", "gaussdb", "highgo", "uxdb", "vastbase", "kwdb", "opengauss", "questdb"]);
|
||||
export const POSTGRES_FOLDED_IDENTIFIER_TYPES = new Set(["postgres", "redshift", "gaussdb", "highgo", "uxdb", "vastbase", "kwdb", "opengauss", "questdb"]);
|
||||
const ORACLE_FOLDED_IDENTIFIER_TYPES = new Set(["oracle", "dameng", "oceanbase-oracle"]);
|
||||
|
||||
/**
|
||||
* Fold a SQL source identifier the way the server resolved it when the
|
||||
* identifier was written unquoted: PostgreSQL-compatible engines store and
|
||||
* resolve it lower case, so the folded spelling — not the query's original
|
||||
* casing — is the only name that stays addressable when the identifier is
|
||||
* later quoted (grid saves, generated SQL). Quoted identifiers keep their
|
||||
* exact spelling. `undefined` passes through so callers can fall back to
|
||||
* other identity sources.
|
||||
*/
|
||||
export function foldUnquotedPostgresMetadataIdentifier(databaseType: string, identifier: string | undefined, quoted: boolean | undefined): string | undefined {
|
||||
if (!identifier || quoted || !POSTGRES_FOLDED_IDENTIFIER_TYPES.has(databaseType)) return identifier;
|
||||
return identifier.toLowerCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve a SQL source identifier to the canonical name returned by table
|
||||
* metadata. Quoted identifiers are always exact. PostgreSQL-compatible
|
||||
|
||||
Reference in new issue
Block a user