Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
faubulous opened this issue Aug 24, 2023 · 2 comments
Open

Comments

@faubulous
Copy link

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

@mangalaman93
Copy link
Contributor

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

@faubulous
Copy link
Author

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?

@mangalaman93 mangalaman93 transferred this issue from dgraph-io/dgraph Aug 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants