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

Use txn.Get in addReverseMutation #3874

Merged
merged 2 commits into from
Aug 28, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions dgraph/cmd/alpha/upsert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1422,3 +1422,52 @@ upsert {
require.NotContains(t, res, "San Francisco")
require.NotContains(t, res, "Fuller Street, SF")
}

func TestDeleteCountIndex(t *testing.T) {
require.NoError(t, dropAll())
require.NoError(t, alterSchema(`
<game_answer>: uid @count @reverse .
<name>: int @index(int) .`))

m1 := `
{
set {
_:1 <game_answer> _:2 .
_:1 <name> "1" .
_:2 <game_answer> _:3 .
_:2 <name> "2" .
_:4 <game_answer> _:2 .
_:3 <name> "3" .
_:4 <name> "4" .
}
}`

_, _, _, err := mutationWithTs(m1, "application/rdf", false, true, 0)
require.NoError(t, err)

m2 := `
upsert {
query {
u3 as var(func: eq(name, "3"))
u2 as var(func: eq(name, "2"))
}
mutation {
delete {
uid(u2) <game_answer> uid(u3) .
}
}
}`
_, _, _, err = mutationWithTs(m2, "application/rdf", false, true, 0)
require.NoError(t, err)

q1 := `
{
me(func: eq(count(~game_answer), 1)) {
name
count(~game_answer)
}
}`
res, _, err := queryWithTs(q1, "application/graphql+-", "", 0)
require.NoError(t, err)
require.NotContains(t, res, "count(~game_answer)")
}
2 changes: 1 addition & 1 deletion posting/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func (txn *Txn) addReverseMutationHelper(ctx context.Context, plist *List,

func (txn *Txn) addReverseMutation(ctx context.Context, t *pb.DirectedEdge) error {
key := x.ReverseKey(t.Attr, t.ValueId)
plist, err := txn.cache.GetFromDelta(key)
plist, err := txn.Get(key)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be worth adding the comment from your description here in the code just to prevent someone from wondering if this can use GetFromDelta in the future?

if err != nil {
return err
}
Expand Down