[BUG]: Count cannot be assigned to a value variable
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 21.8k
- Forks
- 1.6k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 9
Description
What version of Dgraph are you using?
Dgraph Cloud v21.03.0-92-g0c9f60156
Tell us a little more about your go-environment?
No response
Have you tried reproducing the issue with the latest release?
Yes
What is the hardware spec (RAM, CPU, OS)?
Tier: 2R
Storage: 32 GB
Dgraph Hosted: Yes
High Availability: No
SLA: 99.5%
Schema Mode: Flexible
This error can also be reproduced on a Shared Cluster (Free Tier) with a minimal schema.
What steps will reproduce the bug?
1. Deploy minimal schema
type Course {
id: ID!
title: String!
chapters: [Chapter!]!
}
type Chapter {
id: ID!
title: String!
sequence: Int
}
2. Perform initial DQL mutation
{
"set": {
"dgraph.type": "Course",
"Course.title": "Course 1",
"Course.chapters": [
{
"dgraph.type": "Chapter",
"Chapter.title": "Chapter 1",
"Chapter.sequence": 0
},
{
"dgraph.type": "Chapter",
"Chapter.title": "Chapter 2",
"Chapter.sequence": 1
}
]
}
}
3. Perform upsert DQL mutation
{
"query": "{ qTest(func: uid(0x1)) { u as uid c as count(Course.chapters) } }",
"mutations": [
{
"set": {
"uid": "uid(u)",
"Course.chapters": [
{
"dgraph.type": "Chapter",
"Chapter.title": "Test Chapter",
"Chapter.sequence": "val(c)"
}
]
}
}
]
}
Response
{
data: {
code: "Success"
message: "Done"
queries: {
qTest: [
0: {
uid:"0x1"
count(Course.chapters): 2
}
]
}
uids: {
dg.3162278161.22051:"0x1"
}
}
Expected behavior and actual result.
We would expect that Chapter.sequence of the new Chapter Test Chapter would equal 2 since count(Course.chapters) validates 2.
This behaviour is also documented in the official docs.
Additional information
Chapter.sequence of the newly created Chapter Test Chapter remains undefined.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source files or tests are named. Reproduce the issue with the minimal Course and Chapter schema, then run the shown DQL upsert and trace how count(Course.chapters) is assigned through val(c). Done means the new Chapter's Chapter.sequence is set to 2 rather than remaining undefined.
Written by the indexing model from the issue text.
Assessment
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100