Skip to content

Conversation

@mrj0
Copy link
Contributor

@mrj0 mrj0 commented Jul 26, 2025

Merging code that fixes jmoiron/sqlx#162

This is the upstream work from multiple authors in jmoiron/sqlx#950 which makes for a much improved and intuitive experience when scanning joined tables.

There is the possibility of slight breakage with this change if client code depended on the result of the scan being non-nil for embedded structs, but pointer members is not typical usage and the likelihood of breakage is small enough to not be a serious problem.

This behavior matches expectations set by other scanning behavior where struct members are made pointers for possibly null values. Extending that behavior to struct members increases consistency.

Alternatively, we could have used omitempty tags to opt into the behavior, but this is different than other struct members that don't need a tag.

@mrj0 mrj0 changed the title Mj/optional nested structs Optional nested structs Jul 26, 2025
@mrj0 mrj0 force-pushed the mj/optional-nested-structs branch from 4bcb74d to 1f123ff Compare July 27, 2025 04:51
@mrj0 mrj0 merged commit d755197 into main Jul 27, 2025
8 checks passed
@mrj0 mrj0 deleted the mj/optional-nested-structs branch July 27, 2025 05:08
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.

StructScan rows after outer join

3 participants