fix(db-postgres): querying with in: []
returns empty result
#11011
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was an issue with relational databases where, when an empty array was used as a value for the IN operator, the constraint was being ignored. Fixes #10788
I investigated this issue and found that, in the past, Drizzle's inArray operator would throw an error when it received an empty array. Because of this behavior, the Payload server would crash when handling queries with in: []. To address this, the following commit was made: c4ac341.
However, this approach resulted in the constraint being ignored, which is not the ideal behavior. The Drizzle community discussed the expected behavior of the inArray operator (see: drizzle-team/drizzle-orm#1295), and the team decided to modify it to accept empty arrays instead of throwing an error.
With this change, simply removing the unnecessary check resolves the issue.
After making this fix, one of the tests failed because it was using the not_in operator. I also updated the test to reflect the new behavior.