# NOT filter doesn't work

**URL:** <https://discuss.dgraph.io/t/not-filter-doesnt-work/12200>\
**Category:** Dgraph\
**Tags:** kind:question, dgraph, area:querylang:vars\
**Created:** [January 6, 2021, 10:46am UTC](https://discuss.dgraph.io/t/not-filter-doesnt-work/12200 "2021-01-06T10:46:09Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![spinelsun](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/spinelsun/32/4596_2.png) [@spinelsun](https://discuss.dgraph.io/u/spinelsun)\
**Post date:** [January 6, 2021, 10:46am UTC](https://discuss.dgraph.io/t/not-filter-doesnt-work/12200/1 "2021-01-06T10:46:09Z")

</div>

## I Want to Do

Filter all branches that don’t have the name master and find their latest version.

## What I Did

```auto
var(func: uid($repoId)){
      Repository.branches @filter(NOT eq(Branch.name, "master")){
      Branch.versions {
        N as Version.number
      }
      LV as max(val(N))
    }
}

repo_branches(func: uid($repoId), first: 8) @normalize {
      Repository.branches(orderasc: Branch.name){
         branch_name: Branch.name
         Branch.versions @filter(eq(Version.number, val(LV))) {
           latest_version: Version.number
      }
    }
  }

```

## Error

```auto
"errors": [
    {
      "message": ": eq expects atleast 1 argument.",
      "extensions": {
        "code": "ErrorInvalidRequest"
      }
    }
  ]

```

Any idea for why does it happen?

Thanks,  
spinelsun

---

<div class="post-metadata">

**Author:** ![MichelDiz](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/micheldiz/32/11873_2.png) [@MichelDiz](https://discuss.dgraph.io/u/MichelDiz)\
**Post date:** [January 6, 2021, 3:28pm UTC](https://discuss.dgraph.io/t/not-filter-doesnt-work/12200/2 "2021-01-06T15:28:33Z")

</div>

Weird, it works just fine on my end. As it should, there is nothing wrong in that query.

---

<div class="post-metadata">

**Author:** ![spinelsun](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/spinelsun/32/4596_2.png) [@spinelsun](https://discuss.dgraph.io/u/spinelsun)\
**Post date:** [January 6, 2021, 4:10pm UTC](https://discuss.dgraph.io/t/not-filter-doesnt-work/12200/3 "2021-01-06T16:10:10Z")

</div>

It is part of this query maybe something is wrong in the larger scope:

```auto
  	var(func: uid($repoId)){
    Repository.branches @filter(eq(Branch.name, "master")){
      Branch.versions{
      NUM as Version.number
    }
      LATEST as max(val(NUM))
    }

  }
    
    var(func: uid($repoId)){
      Repository.branches @filter(NOT eq(Branch.name, "master")) {
      Branch.versions {
        N as Version.number
      }
      LV as max(val(N))
    }
    }
  
    get_repo(func: uid($repoId)) {
        name: Repository.name
        uname: Repository.unique_name
        description: Repository.description
        is_public: Repository.is_public
        last_update: Repository.last_updated
        created_at: Repository.created_at
        owner: Repository.owner {
            uid
            username: User.username
        }
        Repository.branches @filter(eq(Branch.name, "master")) {
            Branch.name
            Branch.versions @filter(eq(Version.number, val(LATEST))) {
                number: Version.number
                Version.artifacts (orderasc: Artifact.name) {
                    types: dgraph.type
                    name: Artifact.name
                    last_updated: Artifact.last_updated
                }
            }
        }
    }
          
    repo_branches(func: uid($repoId), first: 7) @normalize {
      Repository.branches(orderdesc: Branch.last_updated, orderasc: Branch.name){
     branch_name: Branch.name
      Branch.versions @filter(eq(Version.number, val(LV))) {
        latest_version: Version.number
      }
    }
    }
}

```

## Update

I tried it by it self and it didn’t work either.  
I am checking if it happens in a grater version of dgraph.  
I used `20.03.0` and upgrading know to the latest

---

<div class="post-metadata">

**Author:** ![spinelsun](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/spinelsun/32/4596_2.png) [@spinelsun](https://discuss.dgraph.io/u/spinelsun)\
**Post date:** [January 6, 2021, 4:50pm UTC](https://discuss.dgraph.io/t/not-filter-doesnt-work/12200/4 "2021-01-06T16:50:53Z")

</div>

@MichelDiz

Ok I figured it out 🙂  
The reason that it doesn’t work is that I don’t have branches that are not the `Master`.  
So no data reutrns from the var LV and as a result the eq function fails.

Any ideas how to bypass it?

---

<div class="post-metadata">

**Author:** ![MichelDiz](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/micheldiz/32/11873_2.png) [@MichelDiz](https://discuss.dgraph.io/u/MichelDiz)\
**Post date:** [January 6, 2021, 4:59pm UTC](https://discuss.dgraph.io/t/not-filter-doesnt-work/12200/5 "2021-01-06T16:59:00Z")

</div>

> [@spinelsun](#):
>
> Any ideas how to bypass it?

Nope, maybe a fake master with empty values?

This could fit [Custom Block - Discussion](http://discuss.hypermode.com/t/custom-block-discussion/4023) - As you could have a string value variable to avoid this problem.

Also, I think this error is bad, cuz it throws an erroneous error message that might confuse users who don’t have a full idea of their dataset. We should improve it. @dmai @hardik

In this case we should throw an error like “the value variable returned empty value”.

---

<div class="post-metadata">

**Author:** ![spinelsun](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/spinelsun/32/4596_2.png) [@spinelsun](https://discuss.dgraph.io/u/spinelsun)\
**Post date:** [January 6, 2021, 5:12pm UTC](https://discuss.dgraph.io/t/not-filter-doesnt-work/12200/6 "2021-01-06T17:12:56Z")

</div>

I used the following filter `@filter(Not eq(Branch.name, "master")` in the query so now the whole solution looks like this:

```auto
 var(func: uid($repoId)){
      Repository.branches @filter(NOT eq(Branch.name, "master")) {
      Branch.versions {
        N as Version.number
      }
      LV as max(val(N))
    }
 }

repo_branches(func: uid($repoId), first: 7) @normalize {
      Repository.branches(orderdesc: Branch.last_updated, orderasc: Branch.name) @filter(Not eq(Branch.name, "master")){
     branch_name: Branch.name
      Branch.versions @filter(eq(Version.number, val(LV))) {
        latest_version: Version.number
      }
    }
  }

```

What do you think

---

<div class="post-metadata">

**Author:** ![MichelDiz](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/micheldiz/32/11873_2.png) [@MichelDiz](https://discuss.dgraph.io/u/MichelDiz)\
**Post date:** [January 6, 2021, 5:37pm UTC](https://discuss.dgraph.io/t/not-filter-doesnt-work/12200/7 "2021-01-06T17:37:41Z")

</div>

Not sure what to look here. This looks pretty much the same to me.

---

<div class="post-metadata">

**Author:** ![spinelsun](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/spinelsun/32/4596_2.png) [@spinelsun](https://discuss.dgraph.io/u/spinelsun)\
**Post date:** [January 6, 2021, 5:47pm UTC](https://discuss.dgraph.io/t/not-filter-doesnt-work/12200/8 "2021-01-06T17:47:15Z")

</div>

I added another filter on the query itself on the Repository.branches predicate after the sorting block  
So now I don’t arrive to this equal function with an empty variable
