-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using near filter in where query cause toEntity(model) bug #1419
Using near filter in where query cause toEntity(model) bug #1419
Comments
Hi @hosiduy, could you please provide us with a sandbox to reproduce this issue? |
Hi @shimks, I did fix this problem by change the code in file: node_modules/dist8/src/repositories/legacy-juggler-bridge.js -> Before change: toEntity(model) {
return new this.entityClass(model.toObject());
} My change: toEntity(model) {
let check;
if (!model) return null;
if (typeof model.toObject === 'function') {
check = new this.entityClass(model.toObject());
} else {
check = new this.entityClass(model);
}
return check;
} Hope this help. |
I was able to reproduce this issue, thanks. Looks like we'll need to check whether the model we get back in Related to #1378. |
Okay @shimks , I will make a PR with the change I've made. |
@hosiduy Are you still interested / able to work on this issue. I know you forked the repo, once you have made the necessary changes you will have to Open a PR by clicking the |
Hi, any news? I'm getting the same issue. Cannot use near filter. |
Please refer to #1981 for updates discussions. |
Please note that this issue does not require |
@hosiduy @susannaHayrapetyan We've fixed this recently in juggler. Please try upgrading your dependencies so that you get |
Description
I have Address model:
Address extends Entity {
}
Current Behavior
I try this query:
let nearByAddressList = await this.addressRepo.find({
and the console show me the bug: model.toObject() is not a function on file node_modules/@loopback/repository/dist8/src/repositories/legacy-juggler-bridge.js:160
If I remove the where filter, the code run normally.
I checked the code and couldn't find near properties on Where filter class.
Can I use near in where filter on Lp4 now?
Expected Behavior
Query run normally with near in query.
See Reporting Issues for more tips on writing good issues
The text was updated successfully, but these errors were encountered: