We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
with git main branch(8ff4e72) code and dgraph verion 23.1.0. Conditional Upsert not work
data := []map[string]interface{}{ { "uid": "uid(v)", "email": "[email protected]", "name": "first name" }, }
userByEmailQuery := dqlx.Query(dqlx.EqFn("email", "[email protected]")). .Select(v as uid name)
v as uid name
condition := dqlx.Condition(dqlx.Eq("len(v)", "1"))
resp, err := db.Mutation(). Query(userByEmailQuery). Condition(condition). Set(data). Execute(ctx)
but i user dgo api, it works
query = `
query { user as var(func: eq(email, "[email protected]")) }mu := &api.Mutation{ Cond: @if(eq(len(user), 1)), // Only mutate if "[email protected]" belongs to single user. SetNquads: []byte(uid(user) "first name" .`), } req := &api.Request{ Query: query, Mutations: []*api.Mutation{mu}, CommitNow: true, }
mu := &api.Mutation{ Cond:
, // Only mutate if "[email protected]" belongs to single user. SetNquads: []byte(
// Update email only if exactly one matching uid is found. _, err = dg.NewTxn().Do(ctx, req)
This solves it, I don't know if it will introduce other problems
diff --git a/predicate.go b/predicate.go index 96cd546..97c9031 100644 --- a/predicate.go +++ b/predicate.go @@ -221,22 +221,22 @@ func EscapePredicate(field string) string { predicate, alias, directive = parsePredicate(predicate)
if alias != "" {
alias = fmt.Sprintf("<%s>:", alias)
alias = fmt.Sprintf("%s:", alias) }
return fmt.Sprintf("%s %s %s<%s>%s", varName, asKeyword, alias, predicate, directive)
return fmt.Sprintf("%s %s %s%s%s", varName, asKeyword, alias, predicate, directive) } field, alias, directive = parsePredicate(field) if alias != "" {
alias = fmt.Sprintf("%s:", alias) } if strings.HasPrefix(field, "expand(") { return fmt.Sprintf("%s%s%s", alias, field, directive) }
return fmt.Sprintf("%s<%s>%s", alias, field, directive)
return fmt.Sprintf("%s%s%s", alias, field, directive)
}
The text was updated successfully, but these errors were encountered:
No branches or pull requests
with git main branch(8ff4e72) code and dgraph verion 23.1.0.
Conditional Upsert not work
data := []map[string]interface{}{
{
"uid": "uid(v)",
"email": "[email protected]",
"name": "first name"
},
}
userByEmailQuery := dqlx.Query(dqlx.EqFn("email", "[email protected]")).
.Select(
v as uid name
)condition := dqlx.Condition(dqlx.Eq("len(v)", "1"))
resp, err := db.Mutation().
Query(userByEmailQuery).
Condition(condition).
Set(data).
Execute(ctx)
but i user dgo api, it works
query {
user as var(func: eq(email, "[email protected]"))
}
mu := &api.Mutation{ Cond:
@if(eq(len(user), 1)), // Only mutate if "[email protected]" belongs to single user. SetNquads: []byte(
uid(user) "first name" .`),}
req := &api.Request{
Query: query,
Mutations: []*api.Mutation{mu},
CommitNow: true,
}
This solves it, I don't know if it will introduce other problems
diff --git a/predicate.go b/predicate.go
index 96cd546..97c9031 100644
--- a/predicate.go
+++ b/predicate.go
@@ -221,22 +221,22 @@ func EscapePredicate(field string) string {
predicate, alias, directive = parsePredicate(predicate)
}
The text was updated successfully, but these errors were encountered: