Skip to content

[@loopback/sequelize] Regression in query behavior when undefined values passed to "where" filter #10129

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

Closed
KalleV opened this issue Oct 24, 2023 · 0 comments · Fixed by #10128
Labels

Comments

@KalleV
Copy link
Contributor

KalleV commented Oct 24, 2023

Describe the bug

I noticed passing "undefined" to a where filter value will lead to a "NULL" query internally. This causes issues with backward compatibility for application business logic using optional values since the Juggler ORM omits "undefined" values from the internal SQL queries.

Original connector logic that skips over undefined can be found here: https://github.com/loopbackio/loopback-connector/blob/62a9fd10ddf896c874ca7a80a9fd4a472d303637/lib/sql.js#L1194-L1196

Example

With the Sequelize extension:

const userData = await userRepo.find({
  where: {name: user.name, email: user.email, password: undefined},
});

This leads to a query such as:

SELECT ... WHERE ..., password = NULL

Logs

No response

Additional information

No response

Reproduction

https://github.com/loopbackio/loopback-next/pull/10128/files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant