fix(sql): gate having alias visibility by dialect reject list
This commit is contained in:
1 parent
ac7fbaeb43
commit
1b6ff2ba54
5 files changed
+158
-13
No files matched your search
@@ -268,6 +268,50 @@ export function supportsTransaction(dbType?: string): boolean {
|
||||
return !!dbType && TRANSACTION_SUPPORTED_TYPES.includes(dbType);
|
||||
}
|
||||
|
||||
// Engines confirmed to reject SELECT projection aliases inside HAVING (they
|
||||
// resolve only source columns there): the PostgreSQL family (PostgreSQL,
|
||||
// Redshift, Kingbase, HighGo, UXDB, Vastbase, GaussDB, openGauss, KwDB), SQL
|
||||
// Server, DB2, the Oracle family (Oracle, OceanBase Oracle mode, Yashandb,
|
||||
// Dameng, Oscar, Xugu), Informix, Firebird, Exasol, Trino, and PrestoSQL.
|
||||
// Everything else — including Spark, Databricks, Hive-family engines, and
|
||||
// Snowflake, which all resolve SELECT aliases in HAVING — keeps the
|
||||
// permissive behavior, mirroring DBeaver's permissive-default
|
||||
// ProjectionAliasVisibilityScope with a deny list of known rejecters.
|
||||
const HAVING_ALIAS_REJECTED_DATABASE_TYPES: ReadonlySet<string> = new Set([
|
||||
"postgres",
|
||||
"redshift",
|
||||
"kingbase",
|
||||
"highgo",
|
||||
"uxdb",
|
||||
"vastbase",
|
||||
"gaussdb",
|
||||
"opengauss",
|
||||
"kwdb",
|
||||
"sqlserver",
|
||||
"db2",
|
||||
"oracle",
|
||||
"oceanbase-oracle",
|
||||
"yashandb",
|
||||
"dameng",
|
||||
"oscar",
|
||||
"xugu",
|
||||
"informix",
|
||||
"firebird",
|
||||
"exasol",
|
||||
"trino",
|
||||
"prestosql",
|
||||
]);
|
||||
|
||||
/**
|
||||
* Returns true when the engine rejects SELECT alias references from the
|
||||
* HAVING clause, so alias completion hides there and the "Unknown column"
|
||||
* diagnostic keeps flagging a projected alias used in HAVING. Unknown or
|
||||
* unlisted database types stay permissive.
|
||||
*/
|
||||
export function rejectsAliasReferenceInHaving(dbType?: string): boolean {
|
||||
return !!dbType && HAVING_ALIAS_REJECTED_DATABASE_TYPES.has(dbType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Default auto-commit mode when opening a query tab for the given database type.
|
||||
* Query tabs default to auto-commit; users can explicitly switch to manual transactions.
|
||||
|
||||
Reference in new issue
Block a user