Conditional upsert mutation with quotes in the value is creating duplicates

Dgraph version: 21.12

We are trying to upsert some nodes using the upsert mutation block, the “primary key” of the node type can have double quotes inside the value. The mutation works as expected (with no duplicates) if the predicate does not have double quotes inside but creates duplicates when the value has duplicates.

dql schema

type software {
  name string
  last_seen
}

name: string @index(exact, trigram) @upsert .
last_seen: dateTime @index(hour)  .

e.g. Conditional upsert is always creating a new node even though the query matches an existing node.

upsert {
  query {
       var(func: eq(name, "xyz \"abc\" 123")) {
              s as uid
        }
  }
  mutation @if(eq(len(s), 1))  {
     set {
         uid(s) <update_time> "2021-12-12" .
     }
  }
  mutation @if(eq(len(s), 0))  {
     set {
         uid(s) <name>  "xyz \"abc\" 123" .
         uid(s) <update_time> "2021-12-12" .
     }
  }
}

Wonder if you need to double escape somewhere? I don’t have a better solution, just that thought.

@MichelDiz ever use quotes in strings like this before?

Are you sure about this? This is working fine in my env.

No matter how many times I hit Run, always get a single node. No duplicates at all.

1 Like