Repository navigation
fix(family-mongo): db schema prints a field with several BSON types as a | b - #30476
Conversation
Signed-off-by: Lazizbek Ergashev <[email protected]>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
…tests Signed-off-by: Lazizbek Ergashev <[email protected]>
|
@wmadden, please have a look when you have time |
main rewrote schema-to-view.ts to union each field's types across the validator's root models; the fix now applies to that join. The unit test passes the fromDatabase option MongoSchemaIR now requires. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…ests from main Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
@prisma/orm-extension-arktype-json
@prisma/orm-extension-middleware-cache
@prisma/orm-extension-paradedb
@prisma/orm-extension-pgvector
@prisma/orm-extension-postgis
@prisma/orm-extension-supabase
@prisma/orm-family-mongo
@prisma/orm-family-sql
@prisma/orm-framework
@prisma/orm-mariadb
@prisma/orm-mongo
@prisma/orm-mysql
@prisma/orm-postgres
@prisma/orm-postgres-contrib
@prisma/orm-sqlite
@prisma/orm-target-mariadb
@prisma/orm-target-mongo
@prisma/orm-target-mysql
@prisma/orm-target-postgres
@prisma/orm-target-sqlite
@prisma/orm-toolchain
commit: |
a | b
|
This is fixed. You can follow where this stands here: https://asks.prisma.cool/public/asks/01a13059-316f-7198-a2e1-edd2a3abdfec |
db schemaon MongoDB now joins the BSON types of a multi-type validator property with|.Why
A MongoDB
$jsonSchemaproperty can allow several BSON types: aJsonfield allows all of them, and a nullable field allows its type andnull.db schemaprinted that list joined with bare commas, which is hard to read and looks like a typo. The|form reads as "one of these", like a TypeScript union.The change
After merging
mainthis is a one-line change inschema-to-view.ts: the type list is joined with' | 'instead of','. Since this PR was opened,mainstarted collecting each field's types across all of a collection's root models. That list goes through the same join, so theanyOfcase is covered too. A property with a single type, and theanyfallback, print as before. The Postgres view has no multi-type case, because a Postgres column has exactly one type.Tests
test/integration/test/mongo/db-schema.test.tscreates a collection on mongodb-memory-server with a multi-type property and a nullable property, introspects it, and checks the printed labels. It fails onmainand passes here. 10 tests pass.packages/2-mongo-family/9-family/test/control.test.tscovers the same two properties.Alternatives considered
object, array, …with spaces. Easier on the eye than bare commas, but it doesn't say "one of these".Fixes #30470