-
Notifications
You must be signed in to change notification settings - Fork 248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
qe: Fix nested objects with $type
key in JSON protocol
#4668
Conversation
WASM Size
|
CodSpeed Performance ReportMerging #4668 will not alter performanceComparing Summary
|
✅ WASM query-engine performance won't change substantially (0.985x)Full benchmark report
After changes in be1aa17 |
4aafb68
to
6f1eab4
Compare
Introduce another special value to JSON protocol, `"$type": "Raw"`. When encountered, no other nested `$type` keys would be interpreted as special and will be written to DB as is. Main usecase is JSON column values with user-provided `$type` keys. This is an alternative to #4668, that might look cleaner on the engine side. Part of the fix for prisma/prisma#21454, will require client adjustments as well.
Introduce another special value to JSON protocol, `"$type": "Raw"`. When encountered, no other nested `$type` keys would be interpreted as special and will be written to DB as is. Main usecase is JSON column values with user-provided `$type` keys. This is an alternative to #4668, that might look cleaner on the engine side. Part of the fix for prisma/prisma#21454, will require client adjustments as well.
Introduce another special value to JSON protocol, `"$type": "Raw"`. When encountered, no other nested `$type` keys would be interpreted as special and will be written to DB as is. Main usecase is JSON column values with user-provided `$type` keys. This is an alternative to #4668, that might look cleaner on the engine side. Part of the fix for prisma/prisma#21454, will require client adjustments as well.
Introduce another special value to JSON protocol, `"$type": "Raw"`. When encountered, no other nested `$type` keys would be interpreted as special and will be written to DB as is. Main usecase is JSON column values with user-provided `$type` keys. This is an alternative to #4668, that might look cleaner on the engine side. Part of the fix for prisma/prisma#21454, will require client adjustments as well.
In JSON protocol, we use `$type` key as a special marker for the types that can not be represented in JSON natively. We did not want to make `$type` identifier reserved, so we took some precautions: if during encoding, at any point, `$type` key would be seen in user's input we encode whole object as `{"$type": "Json", "value": [Serialized object] }`. Engine handled those cases correctly, when `$type: Json` is encountered at the top level, but not when it is nested. In that case, `ArgumentValue`-to-`JSON` serialization just picked `value` key and saved it as a string. Fixed by moving Json value into it's own kind of `ArgumentValue`, that are serialized to json as-is. Fix prisma/prisma#21454
dec953d
to
5619fe9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! It's a bit of a pity that this fix increases the Wasm size, though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sad but good work, lgtm 🙏
Introduce another special value to JSON protocol, `"$type": "Raw"`. When encountered, no other nested `$type` keys would be interpreted as special and will be written to DB as is. Main usecase is JSON column values with user-provided `$type` keys. This is an alternative to #4668, that might look cleaner on the engine side. Part of the fix for prisma/prisma#21454, will require client adjustments as well.
* qe: Fix nested objects with `$type` key in JSON protocol Introduce another special value to JSON protocol, `"$type": "Raw"`. When encountered, no other nested `$type` keys would be interpreted as special and will be written to DB as is. Main usecase is JSON column values with user-provided `$type` keys. This is an alternative to #4668, that might look cleaner on the engine side. Part of the fix for prisma/prisma#21454, will require client adjustments as well. * Fix & move the test
In JSON protocol, we use
$type
key as a special marker for the typesthat can not be represented in JSON natively. We did not want to make
$type
identifier reserved, so we took some precautions: if duringencoding, at any point,
$type
key would be seen in user's input weencode whole object as
{"$type": "Json", "value": [Serialized object] }
.Engine handled those cases correctly, when
$type: Json
is encounteredat the top level, but not when it is nested. In that case,
ArgumentValue
-to-JSON
serialization just pickedvalue
key andsaved it as a string.
Fixed by moving Json value into it's own kind of
ArgumentValue
, thatare serialized to json as-is.
Fix prisma/prisma#21454