-
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
Handle null on findOne function in DefaultCrudRepository class #1378
Comments
@hosiduy Thank you for catching and bringing up the issue. For method like |
Acceptance Criteria:
|
@dhmlau I would suggest we do a quick estimation tomorrow. Then put to our backlog. |
IMO, toEntity(model) {
if (model === null) return null;
return new this.entityClass(model.toObject());
} |
Description / Steps to reproduce / Feature proposal
Hi there,
In DefaultCrudRepository class in /node_modules/@loopback/repository/dist8/src/repositories/legacy-juggler-bridge.js file, we have code:
Current Behavior
The bug happends when function: findOne return null and pass null to function: toEntiry(). So we have null.toObject() -> Cannot read property 'toObject' of null error.
Expected Behavior
Expect: same as findById function.
Thanks.
Acceptance Criteria (from @jannyHou)
findOne
methods in file: https://github.com/strongloop/loopback-next/blob/c553f1171ca86eb13ba7473d73d2e0d1b8de29de/packages/repository/src/repositories/legacy-juggler-bridge.tsnull
or throw error(story owner can decide which one is proper)See Reporting Issues for more tips on writing good issues
The text was updated successfully, but these errors were encountered: