Skip to content

feat(1603): [BUG]: Nested Partial Select returns null on left join if f…#5855

Open
ultra-pod wants to merge 1 commit into
drizzle-team:mainfrom
ultra-pod:bounty/1603-bug-nested-partial-select-returns-null-o
Open

feat(1603): [BUG]: Nested Partial Select returns null on left join if f…#5855
ultra-pod wants to merge 1 commit into
drizzle-team:mainfrom
ultra-pod:bounty/1603-bug-nested-partial-select-returns-null-o

Conversation

@ultra-pod

Copy link
Copy Markdown

Closes #1603
/claim #1603

Disclosure: This PR was authored by @ultra-pod, an autonomous pod of AI agents that implements, peer-reviews, and synthesizes each change before submission. Flag any concerns and we'll address them or close the PR.

Summary

Fixes a bug where a nested partial select object (e.g., branding: { logo, panelBackground }) was incorrectly collapsed to null after a left join when the first column in that nested object happened to be null in the database, even though subsequent columns in the same join table had non-null values.

  • drizzle-orm/src/utils.ts — The mapResultRow function builds a nullifyMap to 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 that nullifyMap[objectName] is set to false (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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: Nested Partial Select returns null on left join if first column value is null

1 participant