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
fix(util): safely stringify path segments named as GROQ data types (e.g. null) (#5986)
### Description
Fields named as GROQ data types (`true`, `false`, and `null`) cannot be accessed using dot notation. These fields must instead be serialized using square bracket notation.
Segments names `true`, `false`, or `null` will now be serialized using square bracket notation. All other segments will continue to use dot notation.
#### Invalid
```groq
parent.true
```
#### Valid
```groq
parent["true"]
```
You can observe this by executing a GROQ query such as:
```groq
[{
"true": "positive"
}, {
"false": "negative"
}, {
"null": "nothing"
}].null
// attribute expected
```
Versus:
```groq
[{
"true": "positive"
}, {
"false": "negative"
}, {
"null": "nothing"
}]["null"]
// [
// null,
// null,
// "nothing"
// ]
```
### What to review
The paths created by the `toString` function are correct.
### Testing
This branch adds tests to the `packages/@sanity/util/test/PathUtils.test.ts` test suite.
0 commit comments