loopbackio / loopbackio/loopback-datasource-juggler
model default scope with inq causes TypeError: Right-hand side of 'instanceof' is not callable
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 282
- Forks
- 366
- Avg merge
- 17h 4m
- Merged PRs (30d)
- 10
Description
## Steps to reproduce
1. Create a model including a property like:
```
"properties" : {
....
"list": {
"type": ["string"],
"index": true
}
...
}
```
2. Add "scope" to the model like:
```
"scope": {
"where": {
"list": {
"inq": ["1", "2"]
}
}
}
```
1. Add data which satisfies the scope. For example the values of list = ["2"]
2. Do a simple GET on the model via the REST API.
## Current Behavior
Exception thrown is: "TypeError: Right-hand side of 'instanceof' is not callable" in loopback-datasource-juggler\lib\utils.js on or about line 67. The offending code is this clause:
`val instanceof prop.type`
## Expected Behavior
No exception thrown and the data returned.
## Link to reproduction sandbox
reproduction sandbox forthcoming
## Additional information
If I put a try catch around the offending statement, everything works as expected.
win32 x64 12.18.3
+-- @loopback/eslint-config@8.0.4
+-- loopback@3.27.0
+-- loopback-boot@2.28.0
+-- loopback-component-explorer@6.5.1
+-- loopback-component-passport@3.12.0
+-- loopback-component-storage@3.7.0
+-- loopback-connector@4.11.1
+-- loopback-connector-postgresql@3.7.0
+-- loopback-datasource-juggler@4.24.0
## Related Issues
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in loopback-datasource-juggler/lib/utils.js around the val instanceof prop.type check and reproduce the model scope using an array-of-string property with an inq filter. Trace how the property type is represented during scope evaluation. Done means the GET returns matching data without the TypeError, with a regression test for this case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100