Skip to content

Add a possibility to identify a variable that has not been assigned yet. ("undefined") #4619

@koculu

Description

@koculu

What you wanted to do

I want to increment a scalar predicate with upsert operation.
If the counter predicate is missing in a record, upsert operation should be able to set initial value.
I cannot set initial value if predicate value is missing because there is no way to check if some variable is undefined.

What you actually did

upsert {
      query{
      	q(func: uid(0x4e22)){         	
          v as visit-count
          incrementedValue as math(cond(v > 0, v+1, 1))
        }
      }         
      mutation {
        set {            
          	<0x4e22> <visit-count> val(incrementedValue) .
        }
      }
}

Why that wasn't great, with examples

I am getting following exception.
Error: t: : Expected a value variable in cond but missing.
There is no way to check if some variable is missing.

There should be a function isMissing(variable) to check if a variable is missing.

Any external references to support your case

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/querylangIssues related to the query language specification and implementation.area/upsertIssues related to upsert operations.kind/enhancementSomething could be better.status/acceptedWe accept to investigate/work on it.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions