Skip to content

would like support of eq/le/lt/ge/gt in mutation conditional upsert other than existing len function only #5281

@dilipkumar2k6

Description

@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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/upsertIssues related to upsert operations.kind/enhancementSomething could be better.status/acceptedWe accept to investigate/work on it.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions