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

Implement AnyQueryResult for Sqlite and MySQL #3608

Merged
merged 5 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sqlx-mysql/src/any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use either::Either;
use futures_core::future::BoxFuture;
use futures_core::stream::BoxStream;
use futures_util::{stream, StreamExt, TryFutureExt, TryStreamExt};
use sqlx_core::any::{
pub use sqlx_core::any::{
abonander marked this conversation as resolved.
Show resolved Hide resolved
Any, AnyArguments, AnyColumn, AnyConnectOptions, AnyConnectionBackend, AnyQueryResult, AnyRow,
AnyStatement, AnyTypeInfo, AnyTypeInfoKind,
};
Expand Down
11 changes: 11 additions & 0 deletions sqlx-mysql/src/query_result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,14 @@ impl Extend<MySqlQueryResult> for MySqlQueryResult {
}
}
}

#[cfg(feature = "any")]
/// This conversion lose the last insert id data.
impl From<MySqlQueryResult> for crate::any::AnyQueryResult {
fn from(done: MySqlQueryResult) -> Self {
crate::any::AnyQueryResult {
rows_affected: done.rows_affected(),
last_insert_id: None,
abonander marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
2 changes: 1 addition & 1 deletion sqlx-sqlite/src/any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use futures_core::future::BoxFuture;
use futures_core::stream::BoxStream;
use futures_util::{StreamExt, TryFutureExt, TryStreamExt};

use sqlx_core::any::{
pub use sqlx_core::any::{
abonander marked this conversation as resolved.
Show resolved Hide resolved
Any, AnyArguments, AnyColumn, AnyConnectOptions, AnyConnectionBackend, AnyQueryResult, AnyRow,
AnyStatement, AnyTypeInfo, AnyTypeInfoKind, AnyValueKind,
};
Expand Down
10 changes: 10 additions & 0 deletions sqlx-sqlite/src/query_result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,13 @@ impl Extend<SqliteQueryResult> for SqliteQueryResult {
}
}
}

#[cfg(feature = "any")]
impl From<SqliteQueryResult> for crate::any::AnyQueryResult {
fn from(done: SqliteQueryResult) -> Self {
crate::any::AnyQueryResult {
rows_affected: done.rows_affected(),
last_insert_id: Some(done.last_insert_rowid()),
abonander marked this conversation as resolved.
Show resolved Hide resolved
}
}
}