Open
Description
Describe the bug
Adding @unique
to a schema type results in failure to ingest strings that contain double quotes (even though the quotes are escaped).
Strings containing single quotes seem to work fine.
To Reproduce
Steps to reproduce the behavior:
- Run the docker image (
docker run --rm -it -p 8080:8080 -p 9080:9080 dgraph/standalone:v24.1.2
orv25.0.0-preview1
) - Create the following schema predicate
Example.name: string @unique @index(exact, term) .
- Execute the following mutations:
curl -q -H "Content-Type: application/json" -X POST "http://localhost:8080/mutate?commitNow=true" -d '
{
"set": {
"Example.name": "The \"problem\" is the quotes (json)"
}
}' | jq
curl -q -H "Content-Type: application/json" -X POST "http://localhost:8080/mutate?commitNow=true" -d '
{
"set": {
"Example.name": "but it is fine without the quotes (json)"
}
}' | jq
curl -q -H "Content-Type: application/rdf" -X POST "http://localhost:8080/mutate?commitNow=true" -d '
{
set {
_:v <Example.name> "The \"problem\" is the quotes (rdf)" .
}
}' | jq
curl -q -H "Content-Type: application/rdf" -X POST "http://localhost:8080/mutate?commitNow=true" -d '
{
set {
_:v <Example.name> "but it is fine without the quotes (rdf)" .
}
}' | jq
- See errors for mutations 1 and 3:
{
"errors": [
{
"message": "line 1 column 63: Expected comma or language but got: problem",
"extensions": {
"code": "ErrorInvalidRequest"
}
}
],
"data": null
}
- Drop all data, including schema and types.
- Create the following schema predicate, this time without
@unique
:
Example.name: string @index(exact, term) .
- The data is ingested without any problems
{
result (func: has(Example.name)) {
uid
Example.name
}
}
returns:
{
"data": {
"result": [
{
"uid": "0x19",
"Example.name": "The \"problem\" is the quotes (json)"
},
{
"uid": "0x1a",
"Example.name": "but it is fine without the quotes (json)"
},
{
"uid": "0x1b",
"Example.name": "The \"problem\" is the quotes (rdf)"
},
{
"uid": "0x1c",
"Example.name": "but it is fine without the quotes (rdf)"
}
]
}
}
Expected behavior
All these test queries should succeed.
For the data I'm trying to represent in Dgraph, quotes in Example.name
are an allowed character.
Environment
- OS: Docker images for both AMD64 and ARM64
- Version v24.1.2 and v25.0.0-preview1