Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

fix(mongodb): skip SQL semantic diagnostics for MongoDB connections

t8y26a14b11efc6f
diff --git a/apps/desktop/src/components/editor/QueryEditor.vue b/apps/desktop/src/components/editor/QueryEditor.vue
index 7395ef23b1..aa31d33ad6 100644
--- a/apps/desktop/src/components/editor/QueryEditor.vue
+++ b/apps/desktop/src/components/editor/QueryEditor.vue
@@ -741,7 +741,7 @@ async function refreshSemanticDiagnostics() {
setSemanticDiagnostics([]);
return;
}
- if (props.databaseType === "elasticsearch") {
+ if (props.databaseType === "mongodb" || props.databaseType === "elasticsearch") {
setSemanticDiagnostics([]);
return;
}
diff --git a/apps/desktop/src/lib/sqlSemanticDiagnostics.ts b/apps/desktop/src/lib/sqlSemanticDiagnostics.ts
index c0dfa00648..a4fd2a553b 100644
--- a/apps/desktop/src/lib/sqlSemanticDiagnostics.ts
+++ b/apps/desktop/src/lib/sqlSemanticDiagnostics.ts
@@ -104,7 +104,7 @@ export function shouldRunSqlSemanticDiagnostics(
cursor: number,
options: { databaseType?: DatabaseType } = {},
): boolean {
- if (options.databaseType === "elasticsearch") return false;
+ if (options.databaseType === "mongodb" || options.databaseType === "elasticsearch") return false;
const context = getSqlCompletionContext(sql, cursor);
if (context.suggestTables || context.exclusiveTableSuggestions || context.exclusiveColumnSuggestions) return false;
if (context.qualifier) return false;
diff --git a/crates/dbx-core/src/models/connection.rs b/crates/dbx-core/src/models/connection.rs
index 6d4327e45e..9d7c9ff068 100644
--- a/crates/dbx-core/src/models/connection.rs
+++ b/crates/dbx-core/src/models/connection.rs
@@ -1685,7 +1685,7 @@ mod tests {
assert_eq!(
config.connection_url(),
- "mysql://root:[email protected]:4000/test?require_ssl=true&verify_ca=false&verify_identity=false&charset=utf8mb4"
+ "mysql://root:[email protected]:4000/test?require_ssl=true&charset=utf8mb4&verify_ca=false&verify_identity=false"
);
}
diff --git a/packages/app-tests/sqlSemanticDiagnostics.test.ts b/packages/app-tests/sqlSemanticDiagnostics.test.ts
index 5d314b00c6..62a58ee499 100644
--- a/packages/app-tests/sqlSemanticDiagnostics.test.ts
+++ b/packages/app-tests/sqlSemanticDiagnostics.test.ts
@@ -93,3 +93,24 @@ test("defers diagnostics while the cursor is in table completion context", () =>
assert.equal(shouldRunSqlSemanticDiagnostics("select u.", "select u.".length), false);
assert.equal(shouldRunSqlSemanticDiagnostics("select * from users where missing = 1", 42), true);
});
+
+test("skips diagnostics for MongoDB connections", () => {
+ assert.equal(
+ shouldRunSqlSemanticDiagnostics("db.my_collection.find({})", 0, { databaseType: "mongodb" }),
+ false,
+ );
+});
+
+test("skips diagnostics for Elasticsearch connections", () => {
+ assert.equal(
+ shouldRunSqlSemanticDiagnostics("db.my_collection.find({})", 0, { databaseType: "elasticsearch" }),
+ false,
+ );
+});
+
+test("still runs diagnostics for SQL connections", () => {
+ assert.equal(
+ shouldRunSqlSemanticDiagnostics("SELECT * FROM users WHERE id = 1", 42, { databaseType: "mysql" }),
+ true,
+ );
+});