You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Mongo Binary fields lose their BSON subtype on a read and write back #30459
What a user sees. A MongoDB Binary field (mongo/binary@1) reads any stored BSON Binary as a plain Uint8Array and writes every Uint8Array as subtype 0. A document that stored a UUID (subtype 4), an MD5 (subtype 5) or a user-defined subtype comes back without its subtype, and writing the value back through the ORM stores it as subtype 0. The bytes survive; the subtype does not. Collections created by Prisma 6 or by other drivers can hold such values, and the Prisma 6 MongoDB schema reader maps Prisma 6 Bytes to this codec.
Where.binaryEncode and binaryDecode in packages/3-mongo-target/1-mongo-target/src/core/bson-scalar-helpers.ts (new Binary(value) on write, wire.value() on read).
Likely fix. Decide the rule and make it explicit. Two options: refuse a stored Binary whose subtype is not 0 or 2 on decode, naming the field, so nothing is silently rewritten; or add a codec (or a parameter on Binary) that keeps the subtype, and point users with UUID data at it. Users who need every subtype preserved today can type the field Bson, which returns the driver's Binary with its subtype.
Where it came from. Recorded when the Binary codec was added in #30396; relevant to the Prisma 6 reader in #30405.
Activity