Skip to content

Bug in query variables whe used with @cascade #4690

@vikram-ma

Description

@vikram-ma

I have a schema, where,

  • one person can own multiple accounts (account1, account2)
  • each account is is subscribed exactly one service (account1 -> service1, account2 -> service2)

For a user id say “1”, I want to get his “owns” predicate, which has subscribed to “service1”
Below query with @cascade works fine, and I get exactly one uid

{
  my_activities(func: eq(Id, 1)) @cascade {
    owns {
      uid
      subscribedTo @filter(eq(name, "service1"))
    }
  }
}

But when I use the same query in upsert, behavior is little bit strange. Even with cascade, I see multiple uid being returned

upsert{
  query{
    my_activities(func: eq(Id, 1)) @cascade {
      owns {
        subscribedTo @filter(eq(name, "Service1"))
	instance as uid
      }
  }
  mutation @if(eq(len(instance), 2) ) {
    # this block executes!!!
  }
  mutation @if(eq(len(instance), 1) ) {
     # this block DOESNOT execute. I was expecting this block to be executed.
  }
}

Note: See the discussion here https://discuss.dgraph.io/t/bug-in-cascade-directive/5896

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions