Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

breaking: fix name collision in FromRow, return Error::ColumnDecode for TryFrom errors #3356

Merged
merged 5 commits into from
Jul 20, 2024

Conversation

abonander
Copy link
Collaborator

fixes #3344

Breaking because #[sqlx(default)] on an individual field or the struct itself would have previously suppressed the error. This doesn't seem like good behavior as it could result in some potentially very difficult bugs.

Instead of using TryFrom for these fields, just implement From and apply the default explicitly.

abonander and others added 4 commits July 17, 2024 01:11
…sion fails in `FromRow`

Breaking because `#[sqlx(default)]` on an individual field or the struct itself would have previously suppressed the error. This doesn't seem like good behavior as it could result in some potentially very difficult bugs.

Instead of using `TryFrom` for these fields, just implement `From` and apply the default explicitly.
@abonander abonander merged commit 4fc5b30 into main Jul 20, 2024
65 checks passed
@abonander abonander deleted the issue-3344 branch July 20, 2024 06:03
jrasanen pushed a commit to jrasanen/sqlx that referenced this pull request Oct 14, 2024
…e` for `TryFrom` errors (launchbadge#3356)

* chore: create regression test for launchbadge#3344

* fix(derives): use a parameter name that's less likely to collide

* breaking(derives): emit `Error::ColumnDecode` when a `TryFrom` conversion fails in `FromRow`

Breaking because `#[sqlx(default)]` on an individual field or the struct itself would have previously suppressed the error. This doesn't seem like good behavior as it could result in some potentially very difficult bugs.

Instead of using `TryFrom` for these fields, just implement `From` and apply the default explicitly.

* fix: run `cargo fmt`

* fix: use correct field in `ColumnDecode`
jrasanen pushed a commit to jrasanen/sqlx that referenced this pull request Oct 14, 2024
…e` for `TryFrom` errors (launchbadge#3356)

* chore: create regression test for launchbadge#3344

* fix(derives): use a parameter name that's less likely to collide

* breaking(derives): emit `Error::ColumnDecode` when a `TryFrom` conversion fails in `FromRow`

Breaking because `#[sqlx(default)]` on an individual field or the struct itself would have previously suppressed the error. This doesn't seem like good behavior as it could result in some potentially very difficult bugs.

Instead of using `TryFrom` for these fields, just implement `From` and apply the default explicitly.

* fix: run `cargo fmt`

* fix: use correct field in `ColumnDecode`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FromRow macro can't be used on a struct contains a field named "row"
1 participant