Skip to content

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

Merged
abonander merged 5 commits into
mainfrom
issue-3344
Jul 20, 2024
Merged

abonander merged 5 commits into
mainfrom
issue-3344

Conversation

@abonander

Copy link
Copy Markdown
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
@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 (transact-rs#3356)

* chore: create regression test for transact-rs#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 (transact-rs#3356)

* chore: create regression test for transact-rs#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