[Bug] StringHashFilter of update mutation does not work correctly

The StringHashFilter of update mutations has unexpected behaviour when eq is set to a value and in is set to null:

schema:

type Foo {
 id: String! @id
 value: Int!
}

Add two (or more) foos:

mutation {
  addFoo(input: [
    {
      id: "1"
      value: 1
    }
    {
      id: "2"
      value: 2
    }
  ]) {
    foo {
      id
      value
    }
  }
}

Update one of them:

mutation {
  updateFoo(input: {
    filter: {
      id: {eq: "1" in: null}
    }
    set: {
      value: 1
    }
  }) {
    foo {
      id
    }
  }
}

Sometimes all foos are updated, sometimes only the expected object.

When I also set the in filter option, everything works. But this is obviously not expected behaviour.

mutation {
  updateFoo(input: {
    filter: {
      id: {eq: "1" in: ["1"]}
    }
    set: {
      value: 1
    }
  }) {
    foo {
      id
    }
  }
}

Using 20.11.

Hi @maaft, I reproduced it and this is surely a bug. Ideally, if we want to use multiple filters we should use and/or connectives.
I think we haven’t handled this case while query rewriting, and it’s generating dgraph queries in an indeterministic way. Thanks for reporting this edge case. We are accepting it and will fix it soon.

4 Likes

@JatinDevDG this bug just bit me too – I spent a bunch of time trying to figure it out before I narrowed in on the issue. Just wanted to bump this for visibility, running on the latest version of the dgraph docker container.

1 Like