Skip to content

Commit e431850

Browse files
anandgupta42claude
andcommitted
feat: add MongoDB driver support
Add MongoDB as the 11th supported database driver, enabling document database operations via the existing `Connector` interface. - New driver at `packages/drivers/src/mongodb.ts` supporting: - Full MQL command set: find, aggregate, CRUD, indexes, collection mgmt - Cross-database queries via per-query `database` field - BSON type serialization (ObjectId, Decimal128, Long, UUID, Binary, Date) - Schema introspection via document sampling with field type inference - Connection string URI and host/port/user/password auth - `authorizedDatabases` fallback for restricted-privilege users - Registration in driver index, config normalizer (with `mongo`/`mongodb` aliases), and connection registry - CI: MongoDB 7.0 service in driver-e2e workflow with health checks - 90 E2E tests including: - CRUD operations, aggregation pipelines, schema introspection - Cross-database operations, index management, collection lifecycle - Adversarial tests: deeply nested docs, special characters, heterogeneous collections, concurrent operations, large documents, numeric edge cases Closes #480 Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
1 parent 91fe351 commit e431850

8 files changed

Lines changed: 2580 additions & 3 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ jobs:
4545
- 'packages/opencode/src/altimate/native/connections/**'
4646
- 'packages/opencode/test/altimate/drivers-e2e.test.ts'
4747
- 'packages/opencode/test/altimate/drivers-docker-e2e.test.ts'
48+
- 'packages/opencode/test/altimate/drivers-mongodb-e2e.test.ts'
4849
- 'packages/opencode/test/altimate/connections.test.ts'
4950
dbt-tools:
5051
- 'packages/dbt-tools/**'
@@ -155,6 +156,16 @@ jobs:
155156
--health-timeout 5s
156157
--health-retries 10
157158
159+
mongodb:
160+
image: mongo:7.0
161+
ports:
162+
- 27017:27017
163+
options: >-
164+
--health-cmd "mongosh --eval 'db.runCommand({ping:1})' --quiet"
165+
--health-interval 5s
166+
--health-timeout 5s
167+
--health-retries 10
168+
158169
steps:
159170
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
160171

@@ -195,6 +206,13 @@ jobs:
195206
TEST_REDSHIFT_PORT: "15439"
196207
TEST_REDSHIFT_PASSWORD: testpass123
197208

209+
- name: Run MongoDB driver E2E
210+
run: bun test test/altimate/drivers-mongodb-e2e.test.ts
211+
working-directory: packages/opencode
212+
env:
213+
TEST_MONGODB_HOST: 127.0.0.1
214+
TEST_MONGODB_PORT: "27017"
215+
198216
# Cloud tests NOT included — they require real credentials
199217
# Run locally with:
200218
# ALTIMATE_CODE_CONN_SNOWFLAKE_TEST='...' bun test test/altimate/drivers-snowflake-e2e.test.ts

‎bun.lock‎

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎packages/drivers/package.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"mysql2": "^3.0.0",
1717
"mssql": "^11.0.0",
1818
"oracledb": "^6.0.0",
19-
"duckdb": "^1.0.0"
19+
"duckdb": "^1.0.0",
20+
"mongodb": "^6.0.0"
2021
}
2122
}

‎packages/drivers/src/index.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ export { connect as connectSqlserver } from "./sqlserver"
1616
export { connect as connectOracle } from "./oracle"
1717
export { connect as connectDuckdb } from "./duckdb"
1818
export { connect as connectSqlite } from "./sqlite"
19+
export { connect as connectMongodb } from "./mongodb"

0 commit comments

Comments
 (0)