Skip to content

Support for flatten(nullable) in sqlx::FromRow - #4431

Open
Niedzwiedzw wants to merge 4 commits into
transact-rs:mainfrom
Niedzwiedzw:feat/flatten-nullable
Open

Niedzwiedzw wants to merge 4 commits into
transact-rs:mainfrom
Niedzwiedzw:feat/flatten-nullable

Conversation

@Niedzwiedzw

@Niedzwiedzw Niedzwiedzw commented Sep 29, 2026 •

Copy link
Copy Markdown

Does your PR solve an issue?

Fixes #2934

Do not just list issue numbers here as they will not be automatically closed on merging this pull request unless prefixed with "fixes" or "closes".

Is this a breaking change?

No, default behaviour is preserved

If yes, this pull request will need to wait for the next major release (0.{x + 1}.0)

Probably would still be worth it

@joeydewaal

Copy link
Copy Markdown
Contributor

This tries to parse the type which is fragile. What if someone does something like:

type Opt<T> = Option<T>;

and use Opt<...> in their struct?

#3667 uses auto ref based specialization, see #3667 (comment)

@Niedzwiedzw

Copy link
Copy Markdown
Author

Well I thought about it but I think aliasing Option is obscure enough it can be skipped, as the error will be clear and solution is just to move it to a different module without an alias.

@Niedzwiedzw

Niedzwiedzw commented Sep 29, 2026 •

Copy link
Copy Markdown
Author

@abonander where would be the best place to add tests?
EDIT: figured it out

@Niedzwiedzw Niedzwiedzw changed the title Flatten for optionals Support for flatten(nullable) in sqlx::FromRow Sep 29, 2026
@Niedzwiedzw Niedzwiedzw changed the title Support for flatten(nullable) in sqlx::FromRow Support for flatten(nullable) in sqlx::FromRow Sep 29, 2026
@Niedzwiedzw
Niedzwiedzw marked this pull request as ready for review September 29, 2026 09:35
@Niedzwiedzw

Copy link
Copy Markdown
Author

@joeydewaal after giving it some thought you're right it's better to not parse the option, I pushed an update which uses associated type to extract inner type

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.

flatten for optionals

2 participants