Here’s the revised message with the data structure included for clarity:
Subject: Issue with Single-Field Queries After Upgrading to Dgraph 24.1.1
Hi,
I recently upgraded to Dgraph 24.1.1 and encountered a strange issue when querying a single field.
Data Structure:
Assume we have the following schema:
type User {
uid: String
Name: String
Address: [Address]
}
type Address {
uid: String
City: String
PostCode: String
}
Steps to Reproduce:
-
Create a new
User
with anAddress
:{ "uid": "_:user1", "Name": "John Doe", "Address": [ { "uid": "_:addr1", "City": "New York", "PostCode": "10001" } ] }
-
Update the
User
, but omit theuid
forAddress
:{ "uid": "0x123", "Name": "John Doe", "Address": [ { "City": "San Francisco", "PostCode": "94105" } ] }
-
Query for
User
, requesting only theCity
fromAddress
:{ getUser(func: eq(Name, "John Doe")) { uid Name Address { City } } }
Expected Behavior:
- The query should return the user with a single city value from the
Address
object.
Actual Behavior:
- Most of the time, the response contains an array of cities, instead of a single value.
- Occasionally, it returns only one city, as expected.
- If I modify the query to include a second field (e.g.,
uid
orPostCode
), the response is always correct, returning a singleCity
andPostCode
.
Additional Observations:
- I know that during the update, I am missing the
uid
forAddress
, which may cause unintended behavior. - However, this worked fine in Dgraph 24.0.
- Data created using Dgraph 24.0 does not exhibit this issue.
- Even after backing up (24.0 data) and restoring data into a fresh Dgraph 24.1.1 instance, this data works fine, only newly created data have this.
- the array is always of size two, independent of how many updates were made
This also affects cases where you query a User
and only request the Name
.
Any insights on why this is happening and how to resolve it would be appreciated.
Thanks!