dgraph-io/dgraph-docs

[BUG]: Double wildcard * * not working in delete of an upsert mutation

Closed this issue · 3 comments

What version of Dgraph are you using?

v23.0.1

Tell us a little more about your go-environment?

I'm using the dgraph/dgraph:latest image from dockerhub.

Have you tried reproducing the issue with the latest release?

Yes

What is the hardware spec (RAM, CPU, OS)?

Fedora 38 Host
Intel Core i7 CPU
32GB RAM

What steps will reproduce the bug?

  1. Run this mutation:
{
    set {
        _:1 <id> "1" .
        _:1 <pred1> _:2 .
        _:2 <pred2> "a" .
        _:2 <pred3> "b" .
    }
}
  1. Set predicate type to string and enable index, upset and hash on id in the schema.

  2. Run this query to see that pred2 and pred3 exist:

{
    test(func: has(pred2)) {
        uid
        pred2
        pred3
    }
}
  1. Run this upsert:
upsert {
    query {
        q0(func: eq(id, "1")) {
            pred1 {
                id1 as uid
            }
        }
    }
    mutation {
        delete {
            uid(id1) * * .
        }
    }
}
  1. Run this query again to see that pred2 and pred3 still exist:
{
    test(func: has(pred2)) {
        uid
        pred2
        pred3
    }
}
  1. Run this upsert:
upsert {
    query {
        q0(func: eq(id, "1")) {
            pred1 {
                id1 as uid
            }
        }
    }
    mutation {
        delete {
            uid(id1) <pred2> * .
            uid(id1) <pred3> * .
        }
    }
}
  1. Run this query again to see that pred2 and pred3 were deleted and the result is empty.
{
    test(func: has(pred2)) {
        uid
        pred2
        pred3
    }
}

Expected behavior and actual result.

When executing mutation from step 4 with a wildcard on the predicate, the predicates are not deleted. I would expect mutation from step 4 to have the same outcome as mutation from step 6 that uses explicit predicates as documented here.

Additional information

No response

uid(id1) * * . is only supposed to work if the UID has a dgraph.type associated with it. See this for more details https://dgraph.io/docs/dql/dql-schema/#when-to-use-node-types

That explains it. However, it would be great to add or reference this in the documentation about Deleting Data as well:
https://dgraph.io/tour/schema/8/

So will the wildcard then only delete the predicates that are defined for the type?

This issue has been stale for 60 days and will be closed automatically in 7 days. Comment to keep it open.