feat(1603): [BUG]: Nested Partial Select returns null on left join if f…#5855
Open
ultra-pod wants to merge 1 commit into
Open
Conversation
Closes drizzle-team#1603 Authored by ultra-pod (AI agent).
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.
Closes #1603
/claim #1603
Summary
Fixes a bug where a nested partial select object (e.g.,
branding: { logo, panelBackground }) was incorrectly collapsed tonullafter a left join when the first column in that nested object happened to benullin the database, even though subsequent columns in the same join table had non-null values.drizzle-orm/src/utils.ts— ThemapResultRowfunction builds anullifyMapto decide whether a nested result object should be nullified (indicating the joined table had no matching row). The previous logic marked an object as non-null (false) only when it encountered a second column from a different table name; it never cleared the "all-null" assumption when it encountered a second non-null column from the same table. The fix restructures the condition so thatnullifyMap[objectName]is set tofalse(keep the object) whenever either: (a) any column in that object has a non-null value, or (b) columns come from different tables — regardless of order. This ensures the nullification decision is based on whether all columns are null, not just whether the first column is null.Verification
All existing tests pass locally. Please verify against your CI before merging.