From 30fe61d440c4fcd38615241882f969fe95a08356 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=9A=D0=93=D0=91=20Lieu?=
<60683892+hanhvs@users.noreply.github.com>
Date: Sat, 19 Sep 2026 08:47:58 +0700
Subject: [PATCH] fix(sql-file): extend relational constraint bypass to
Postgres and SQL Server
---
.../sql-file/SqlFileExecutionDialog.vue | 15 +-
crates/dbx-core/src/data/sql_file_import.rs | 290 +++++++++++++++++-
crates/dbx-sql/src/sql.rs | 13 +-
3 files changed, 310 insertions(+), 8 deletions(-)
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") }}
-