loopbackio / loopbackio/loopback-connector-postgresql

neq in where filter does not include null values

Open
#340 13 comments 7 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug good first issue help wanted
Dominant language
JavaScript
Stars
118
Forks
184
Avg merge
1d 22h
Merged PRs (30d)
5

Description

Description/Steps to reproduce

  1. Create a model with String properties
  2. Insert instances with one of the string properties unset. (NULL in DB)
  3. Run a query for model {where: {stringProp: {neq: "value"}}}
  4. NULL entries are not included

Expected result

Null entries are not equal to value so should be included

Additional information

I notice that the output sql from the connector is !=, whereas IS DISTINCT FROM would work for NULL values. As far as I can tell, there is no operator that will invoke IS DISTINCT FROM. If this won't be fixed/is considered not an issue, having this at least documented somewhere would be useful.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the described where query in the PostgreSQL connector and inspect how the neq filter becomes SQL. Compare the generated != condition with PostgreSQL's NULL behavior; done means NULL entries are included as expected, or the limitation is documented if that behavior is not supported.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, postgresql
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.