# Issue with Postgresql filtered queries on V7

**URL:** <https://community.forestadmin.com/t/issue-with-postgresql-filtered-queries-on-v7/2962>\
**Category:** Help me!\
**Created:** [July 22, 2021, 10:24am UTC](https://community.forestadmin.com/t/issue-with-postgresql-filtered-queries-on-v7/2962 "2021-07-22T10:24:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sergior](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/sergior/32/73_2.png) [@sergior](https://community.forestadmin.com/u/sergior)\
**Post date:** [July 22, 2021, 10:24am UTC](https://community.forestadmin.com/t/issue-with-postgresql-filtered-queries-on-v7/2962/1 "2021-07-22T10:24:58Z")

</div>

## Expected behavior

When performing a query with a filter that is not using the IN operator (e.g. `name IS NOT NULL`) the query is expected to succeed.

## Actual behavior

The query is failing because the SQL produced or the query is invalid (`name IS NOT (NULL)`), it surrounds the value with parentheses. Postgresql doesn’t consider this syntax valid.

## Failure Logs

```javascript
"name":"ForestLiana","message":"Records Index Count error: PG::SyntaxError: ERROR: syntax error at or near \"(\"
LINE 1: ...\".\"order_id\" WHERE ((\"order\".\"id\" IS NOT (NULL)))

```

## Context

Please provide any relevant information about your setup.

- Package Version: 7.0.0
- Rails Version: 6.1.4
- Database Dialect: Postgresql
- Database Version: 13.3
- Project Name: Back Office

I’ve created a [PR](https://github.com/ForestAdmin/forest-rails/pull/508) with a suggested solution for the problem.

---

<div class="post-metadata">

**Author:** ![anon39940173](https://avatars.discourse-cdn.com/v4/letter/a/8c91f0/32.png) [@anon39940173](https://community.forestadmin.com/u/anon39940173)\
**Post date:** [July 22, 2021, 10:43am UTC](https://community.forestadmin.com/t/issue-with-postgresql-filtered-queries-on-v7/2962/2 "2021-07-22T10:43:43Z")

</div>

Thank you very much for the PR!

IIRC those parenthesis were introduced to deal with a problem when escaping lists for the ‘IN’ operator, which in turn were needed when evaluating content restriction for scopes and smart actions.

(like in `table.id IN (1, 2, 3, 4)`)

I’ll ask one of the ruby devs to review your PR (and hopefully unit test it, so that we stop having regressions on those features).

---

<div class="post-metadata">

**Author:** ![anon39940173](https://avatars.discourse-cdn.com/v4/letter/a/8c91f0/32.png) [@anon39940173](https://community.forestadmin.com/u/anon39940173)\
**Post date:** [July 22, 2021, 2:58pm UTC](https://community.forestadmin.com/t/issue-with-postgresql-filtered-queries-on-v7/2962/3 "2021-07-22T14:58:23Z")

</div>

I’m closing this, we can continue the conversation in the PR comments
