Skip to content

v0.17.0-dev.10

@StevenMcClankerton StevenMcClankerton tagged this 06 Aug 15:00
## Linked issue

n/a — no Linear ticket

## At a glance

```ts
const connectionUri = replSet.getUri(dbName);
await pushContract(connectionUri, options.contractJson);
client = new MongoClient(connectionUri);
```

Mongo Prisma-port suites now provision their emitted contract before
exercising runtime writes.

## Decision

This PR provisions every fresh Mongo Prisma-port database through Prisma
Next’s Mongo migration planner and runner before a test receives its
runtime handle. The resulting collection validator rejects `null` writes
to required composite objects and lists, so 24 required-composite
compatibility cases now pass instead of being expected failures.

## Summary

The Mongo test harness now validates the actual contract-to-migration
path rather than operating against an unvalidated memory-server
database.

## Reviewer notes

- `pushContract()` deliberately uses the Mongo control-plane planner and
runner rather than a test-only `createCollection()` call, so the suites
cover the product migration path that derives validators from contracts.
- The same database-specific replica-set URI is used for provisioning,
raw Mongo access, and the Prisma Next runtime; validators and test
operations therefore target the same database.
- The two remaining composite-suite expected failures are intentionally
unchanged: optional composite `unset()` removes the Mongo field instead
of returning Prisma-compatible `null`.

## How it fits together

1. The shared Mongo harness builds a control stack, deserializes each
emitted contract, introspects the empty database, and plans an additive
greenfield migration.
2. It executes that plan with the standard Mongo migration runner before
creating the raw client and runtime, which creates the contract-derived
collection validator.
3. Object and list composite create, createMany, update, updateMany, and
upsert tests now assert the server-side rejection of invalid
required-composite `null` writes.
4. The expected-failure ledger removes the resolved cases, and the Mongo
scorecard records the runtime guarantee as supported.

## Behavior changes & evidence

- **Mongo port suites install collection validators before runtime
operations.**
[`test/integration/test/ports/_harness/mongo.ts`](test/integration/test/ports/_harness/mongo.ts)
plans and applies the emitted contract through the production migration
interfaces. Required object and list create paths now demonstrate the
resulting rejection in
[`composites-object-create.test.ts`](test/integration/test/ports/prisma/functional/composites-object-create/composites-object-create.test.ts)
and
[`composites-list-create.test.ts`](test/integration/test/ports/prisma/functional/composites-list-create/composites-list-create.test.ts).
- **Required composite `null` writes are now passing compatibility
coverage.** Object and list create, createMany, update, updateMany, and
upsert suites promote 24 cases from `it.fails` to normal tests,
including
[`composites-object-update.test.ts`](test/integration/test/ports/prisma/functional/composites-object-update/composites-object-update.test.ts)
and
[`composites-list-upsert-update.test.ts`](test/integration/test/ports/prisma/functional/composites-list-upsert-update/composites-list-upsert-update.test.ts).
- **Compatibility documentation records the resolved gap.**
[`failing.md`](test/integration/test/ports/prisma/failing.md) retains
only the two optional-composite `unset()` differences, while
[`07-mongodb-query-and-orm.md`](scorecard/07-mongodb-query-and-orm.md)
marks required-composite `null` rejection as supported.

## Skill update

n/a — internal test harness and documentation only

## Testing performed

- `pnpm --filter integration-tests typecheck`
- `pnpm --filter integration-tests lint`
- `pnpm lint:deps`
- Mongo Prisma-port suites: 23 suites, 106 passed cases, and 2
intentional expected failures
- Commit hook: Biome format/check and focused dependency lint for the
staged TypeScript files

## Alternatives considered

- **Manually create Mongo collections in the test harness:** rejected
because it would bypass the contract, planner, and runner path that
produces the validator in real use.
- **Add a separate client-side nullability guard:** rejected because
these ports need to verify MongoDB’s contract-derived server-side
enforcement.

## Checklist

- [x] All commits are signed off (`git commit -s`) per the
[DCO](../CONTRIBUTING.md#developer-certificate-of-origin-dco). The DCO
status check will block merge if any commit is missing a
`Signed-off-by:` trailer.
- [x] I read [CONTRIBUTING.md](../CONTRIBUTING.md) and the change is
scoped to one logical concern.
- [x] Tests are updated (or `n/a` if the change is doc-only / refactor
with no behavioural delta).
- [ ] The PR title is in `TML-NNNN: <sentence-case title>` form (no
Linear ticket exists for this change).
- [x] The **Skill update** section above is filled in (or stated `n/a —
internal only`).


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Bug Fixes**
- MongoDB now consistently rejects `null` values written to required
composite fields and lists across create, update, bulk, and upsert
operations.
- Required composite validation behavior is now aligned across runtime
operations.

- **Tests**
- Expanded integration coverage for null-value rejection and
MongoDB-backed migration setup.
  - Updated expected outcomes for composite object and list operations.

- **Documentation**
- Updated the MongoDB support scorecard to reflect supported
required-composite null validation.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Signed-off-by: Steven McClankerton <tatarintsev@prisma.io>
Co-authored-by: Steven McClankerton <tatarintsev@prisma.io>
Assets 2
Loading