Moved from GitHub dgraph/5281
Posted by dilipkumar2k6:
What version of Dgraph are you using?
dgraph:v20.03.0
Have you tried reproducing the issue with the latest release?
Already using latest version
What is the hardware spec (RAM, OS)?
MAC OS, 32GB RAM
Steps to reproduce the issue (command/config used to run Dgraph).
# Insert Node A with timestamp
{
set {
_:nodeA <dgraph.type> "NodeA" .
_:nodeA <nodeAId> "sb1" .
_:nodeA <timestamp> "2020-04-20T22:15:19.794Z" .
}
}
# Query nodeA too make sure it exist, use same query as upsert to test that its working
{
var(func: eq(nodeAId, "sb1")) {
existingTimestamp as timestamp
}
nodeA (func: le(val(existingTimestamp), "2020-04-20T22:15:19.794Z")) {
uid
timestamp
}
}
# Run upsert on NodeB
upsert {
query {
var(func: eq(nodeBId, "eb12")) {
nodeBId as uid
}
var(func: eq(nodeAId, "sb1")) {
existingTimestamp as timestamp
}
}
# create NodeB node if doesn't exist based on nodeA timestamp
mutation @if(le(val(existingTimestamp), "2020-04-20T22:15:19.794Z")) {
set {
uid(nodeBId) <createdAt> "2020-04-23T00:41:48.497Z" .
uid(nodeBId) <dgraph.type> "NodeB" .
}
}
}
Expected behaviour and actual result.
conditional upsert
should work find on field other than uid
.
Sample example given at following document is using uid
only. In my case, I want to apply val
on the predicate uid
and then compare with corresponding value, but its not working.
https://dgraph.io/docs/master/mutations/#example-of-multiple-mutation-blocks