loopbackio / loopbackio/loopback-next

optional string property in model does not work properly with "exists" where clause

Open
#7,598 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
5.1k
Forks
1.1k
Avg merge
2d 21h
Merged PRs (30d)
27

Description

Steps to reproduce

create a model with an optional string property i.e.
@property({ type: 'string', }) c_modelCode?: string;

when using "exists" on this property, doesn't return any data even when there is data.
"where" : { "c_modelCode": {"exists" : true} }

if the property is removed from the model definition, data is returned with the above where filter.

Current Behavior

no data returned with "exists" clause even though data exists

Expected Behavior

return all objects with c_modelCode propery.

Link to reproduction sandbox

Additional information

+-- @loopback/authentication@7.3.1
+-- @loopback/authorization@0.9.1
+-- @loopback/boot@3.4.1
+-- @loopback/context@3.17.0
+-- @loopback/core@2.16.1
+-- @loopback/openapi-v3@5.3.1
+-- @loopback/repository@3.7.0
+-- @loopback/rest@9.3.1
+-- @loopback/rest-explorer@3.3.1
+-- @loopback/service-proxy@3.2.1
+-- loopback-connector-mongodb@6.0.1

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 optional string property query against the listed loopback-connector-mongodb version, then trace how the repository handles the "exists" filter for declared model properties. Done means records containing c_modelCode are returned and a regression test covers the optional-property case.

Written by the indexing model from the issue text.

Assessment

Tech stack
mongodb, typescript
Domain
backend-api-design, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.