Skip to content

bugfix: streamline and fix AnyQueryResult::last_insert_id() for SQLite#4205

Draft
migus-rs wants to merge 6 commits intolaunchbadge:mainfrom
migus-rs:any-rowid-fix
Draft

bugfix: streamline and fix AnyQueryResult::last_insert_id() for SQLite#4205
migus-rs wants to merge 6 commits intolaunchbadge:mainfrom
migus-rs:any-rowid-fix

Conversation

@migus-rs
Copy link
Copy Markdown

This PR is an alternative for #4178.

This patch series addresses the problem outlined in #2982 where AnyQueryResult::last_insert_id() always returns None for SQLite and PostgreSQL database backends.

  • Interestingly enough, an existing From<SqliteQueryResult> implementation for SQLite already has the correct behavior but is not used.
  • Judging from PgQueryResult sources, the feature is not supported at all for PostreSQL, but there is also two redundant implementations.
  • The MySQL code also has two different implementations for the same operation.

This PR therefore does the following things:

  1. Fix & update the SQLite backend to use the From<SqliteQueryResult> implementation and set last_insert_id correctly.
  2. Update the PostgreSQL backend to use the From<PgQueryResult> implementation.
  3. Update the MySQL backend to use the From<MySqlQueryResult> implementation.
  4. Move definitions of From<XQueryResult> for AnyQueryResult to the (appropriate) <db>/src/any.rs files together with the remainder of Any-specific code.
  5. Add test cases verifying the updated behavior.

Does your PR solve an issue?

Fixes #2982

Is this a breaking change?

No, as I believe the current behavior to be incorrect (and inconsistent) which should be considered a bug.

…nt & robust

- replaced custom map_result function with From<T> implementation
- replaced custom map_result function with From<T> implementation
…_insert_rowid

- replaced custom map_result function with From<T> implementation
- fixed bug causing AnyQueryResult.last_insert_id to always be None for Sqlite backend
- added test
- updated required-features
- added test
- updated required-features
- added test
- updated required-features
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.

AnyQueryResult does not map last_insert_id correct

1 participant