diff --git a/apps/desktop/src/components/sql-file/SqlFileExecutionDialog.vue b/apps/desktop/src/components/sql-file/SqlFileExecutionDialog.vue index bff651096f..2da79970df 100644 --- a/apps/desktop/src/components/sql-file/SqlFileExecutionDialog.vue +++ b/apps/desktop/src/components/sql-file/SqlFileExecutionDialog.vue @@ -134,15 +134,24 @@ function resetPerFileState() { } const sqlConnections = computed(() => store.connections.filter((c) => !["redis", "mongodb", "elasticsearch", "easysearch", "meilisearch", "qdrant", "milvus", "weaviate", "chromadb", "etcd", "zookeeper", "consul", "mq", "nacos"].includes(c.db_type))); -// Mirrors the core executor gate (`supports_connection_level_database_bootstrap_target`): the -// MySQL-family types it runs for, so the constraint toggle appears wherever the backend honors it. +// Mirrors the core executor gate (`relational_constraint_bypass_kind` in +// sql_file_import.rs): MySQL-family types use the session-scoped +// FOREIGN_KEY_CHECKS toggle, PostgreSQL-family types use DISABLE/ENABLE +// TRIGGER ALL, and SQL Server uses NOCHECK/CHECK CONSTRAINT ALL. The toggle +// appears wherever the backend implements one of those mechanisms. const MYSQL_BOOTSTRAP_IMPORT_TYPES = new Set(["mysql", "doris", "starrocks", "goldendb"]); const MYSQL_BOOTSTRAP_IMPORT_PROFILES = new Set(["mariadb", "tidb", "oceanbase", "custom_mysql", "doris", "starrocks", "selectdb", "goldendb"]); +const POSTGRES_CONSTRAINT_BYPASS_TYPES = new Set(["postgres", "gaussdb", "opengauss"]); const isMysqlCompatibleTarget = computed(() => { const config = store.getConfig(connectionId.value); if (!config) return false; return MYSQL_BOOTSTRAP_IMPORT_TYPES.has(config.db_type) || (!!config.driver_profile && MYSQL_BOOTSTRAP_IMPORT_PROFILES.has(config.driver_profile.toLowerCase())); }); +const supportsRelationalConstraintBypass = computed(() => { + const config = store.getConfig(connectionId.value); + if (!config) return false; + return isMysqlCompatibleTarget.value || POSTGRES_CONSTRAINT_BYPASS_TYPES.has(config.db_type) || config.db_type === "sqlserver"; +}); const selectedConnection = computed(() => sqlConnections.value.find((c) => c.id === connectionId.value)); @@ -799,7 +808,7 @@ watch( {{ t("sqlFile.continueOnError") }} -