Skip to content

Commit

Permalink
Add support for multiple mutations
Browse files Browse the repository at this point in the history
  • Loading branch information
mangalaman93 committed Nov 5, 2019
1 parent bacf65f commit 3a63c07
Show file tree
Hide file tree
Showing 7 changed files with 425 additions and 449 deletions.
55 changes: 1 addition & 54 deletions dgraph/cmd/alpha/upsert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func TestUpsertExampleJSON(t *testing.T) {

m1 := `
{
"query": "{ u as var(func: has(amount)) { amt as amount} me () { updated_amt as math(amt+1)}}",
"query": "{ u as var(func: has(amount)) { amt as amount \n updated_amt as math(amt+1)}}",
"set": [
{
"uid": "uid(u)",
Expand Down Expand Up @@ -270,38 +270,6 @@ func TestUpsertExample0JSON(t *testing.T) {
require.Contains(t, res, "Ashish")
}

func TestUpsertNoVarErr(t *testing.T) {
require.NoError(t, dropAll())
require.NoError(t, alterSchema(`
age: int @index(int) .
friend: uid @reverse .`))

m1 := `
upsert {
query {
me(func: eq(age, 34)) {
...fragmentA
friend {
...fragmentA
age
}
}
}
fragment fragmentA {
uid
}
mutation {
set {
_:user1 <age> "45" .
}
}
}`
_, err := mutationWithTs(m1, "application/rdf", false, true, 0)
require.Contains(t, err.Error(), "upsert query block has no variables")
}

func TestUpsertWithFragment(t *testing.T) {
require.NoError(t, dropAll())
require.NoError(t, alterSchema(`
Expand Down Expand Up @@ -340,23 +308,6 @@ upsert {
require.True(t, contains(mr.preds, "age"))
}

func TestUpsertInvalidErr(t *testing.T) {
require.NoError(t, dropAll())
require.NoError(t, alterSchema(`
age: int @index(int) .
name: string @index(exact) .
friend: uid @reverse .`))

m1 := `
{
set {
uid(variable) <age> "45" .
}
}`
_, err := mutationWithTs(m1, "application/rdf", false, true, 0)
require.Contains(t, err.Error(), "invalid syntax")
}

func TestUpsertUndefinedVarErr(t *testing.T) {
require.NoError(t, dropAll())
require.NoError(t, alterSchema(`
Expand Down Expand Up @@ -1743,8 +1694,6 @@ upsert {
query {
u as var(func: has(amount)) {
amt as amount
}
me() {
updated_amt as math(amt+1)
}
}
Expand Down Expand Up @@ -1815,8 +1764,6 @@ upsert {
query {
u as var(func: has(amount)) {
amt as amount
}
me () {
updated_amt as math(amt+1)
}
}
Expand Down
2 changes: 1 addition & 1 deletion edgraph/access_ee.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ func ResetAcl() {
},
}

_, err = (&Server{}).doMutate(context.Background(), req, NoAuthorize)
_, err = (&Server{}).doQuery(context.Background(), req, NoAuthorize)
if err != nil {
return err
}
Expand Down
Loading

0 comments on commit 3a63c07

Please sign in to comment.