fix(mysql): allow connection-level queries without database
This commit is contained in:
1 parent
79c682679d
commit
eb4abba713
5 files changed
+59
-10
No files matched your search
@@ -167,6 +167,13 @@ function isAllowedBootstrapPrelude(statement: string): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Connection-scoped SHOW (DATABASES, VARIABLES, PROCESSLIST, …) does not need a
|
||||
// selected schema. SHOW TABLES / SHOW COLUMNS still fail at the server when no
|
||||
// database is selected — matching Navicat-style query windows.
|
||||
if (normalized === "SHOW") {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (normalized !== "CREATE" && normalized !== "DROP") {
|
||||
return false;
|
||||
}
|
||||
@@ -175,12 +182,16 @@ function isAllowedBootstrapPrelude(statement: string): boolean {
|
||||
return !!next && isDatabaseKeyword(next[0]);
|
||||
}
|
||||
|
||||
export function supportsConnectionLevelDatabaseBootstrap(connection: BootstrapConnection | undefined): boolean {
|
||||
export function supportsConnectionLevelSqlExecution(connection: BootstrapConnection | undefined): boolean {
|
||||
if (!connection) return false;
|
||||
if (supportsCreateDatabaseCharset(connection.db_type, connection.driver_profile)) return true;
|
||||
return !!connection.driver_profile && MYSQL_BOOTSTRAP_EXTRA_PROFILES.has(connection.driver_profile.toLowerCase());
|
||||
}
|
||||
|
||||
export function supportsConnectionLevelDatabaseBootstrap(connection: BootstrapConnection | undefined): boolean {
|
||||
return supportsConnectionLevelSqlExecution(connection);
|
||||
}
|
||||
|
||||
export function canExecuteWithoutSelectedDatabase(connection: BootstrapConnection | undefined, sql: string): boolean {
|
||||
if (!supportsConnectionLevelDatabaseBootstrap(connection)) return false;
|
||||
|
||||
|
||||
Reference in new issue
Block a user