Repository navigation
fix: apply default 'throw' behavior in normalizeWhereCriteria when options not set - #12594
Closed
sunchengrong wants to merge 1 commit into
Closed
sunchengrong wants to merge 1 commit into
sunchengrong wants to merge 1 commit into
Conversation
…tions not set Fixes typeorm#12578 When `invalidWhereValuesBehavior` is not configured in the DataSource, `OrmUtils.normalizeWhereCriteria()` was returning the criteria immediately without checking for undefined/null values. This contradicts the documented default behavior ('throw') and allows UPDATE queries to execute with buggy filters like `WHERE col = null`. The fix resolves the options parameter to a default of { undefined: 'throw', null: 'throw' } when not provided, matching the documented behavior.
Code Review by Qodo
1. normalizeWhereCriteria extra comments
|
This was referenced Jun 19, 2026
Closed
Closed
Closed
Member
|
Closing as this is a duplicate of #12579 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fix #12578 —
normalizeWhereCriteria()should default to 'throw' behaviorProblem
When
invalidWhereValuesBehavioris not configured in the DataSource options,OrmUtils.normalizeWhereCriteria()immediately returns the criteria without checking forundefined/nullvalues:This contradicts the documented default behavior, which states that
'throw'is the default. As a result, UPDATE queries can silently execute with buggy filters likeWHERE col = nullwithout any warning.Solution
When
optionsis not provided, resolve it to the documented defaults ({ undefined: "throw", null: "throw" }) instead of short-circuiting:All internal references to
optionsare updated to useresolvedOptions.Impact
invalidWhereValuesBehaviorconfigured: No change — existing behavior is preservedinvalidWhereValuesBehavior: Now correctly throws onundefined/nullvalues in where conditions, matching the documented defaultFiles changed
src/util/OrmUtils.ts— Resolveoptionsto documented defaults when not provided