refactor: rename DbOutcome to DbQueryResult

This commit is contained in:
Ryan Leckey 2021-01-20 21:57:26 -08:00
parent 401554dd2a
commit d5e0f1b92b
No known key found for this signature in database
GPG Key ID: F8AA68C235AB08C9
30 changed files with 89 additions and 89 deletions

View File

@ -20,10 +20,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [[#940]] Rename the `#[sqlx(rename)]` attribute used to specify the type name on the database
side to `#[sqlx(type_name)]` [[@jplatte]].
- [[#976]] Rename the `DbDone` types to `DbOutcome`. [[@jplatte]]
- [[#976]] Rename the `DbDone` types to `DbQueryResult`. [[@jplatte]]
- [[#976]] Remove the `Done` trait. The `.rows_affected()` method is now available as an inherent
method on `PgOutcome`, `MySqlOutcome` and so on. [[@jplatte]]
method on `PgQueryResult`, `MySqlQueryResult` and so on. [[@jplatte]]
- [[#983]] Upgrade async runtime dependencies [[@seryl, @ant32, @jplatte]]

View File

@ -1,5 +1,5 @@
use crate::any::connection::AnyConnectionKind;
use crate::any::{Any, AnyColumn, AnyConnection, AnyOutcome, AnyRow, AnyStatement, AnyTypeInfo};
use crate::any::{Any, AnyColumn, AnyConnection, AnyQueryResult, AnyRow, AnyStatement, AnyTypeInfo};
use crate::database::Database;
use crate::describe::Describe;
use crate::error::Error;
@ -15,7 +15,7 @@ impl<'c> Executor<'c> for &'c mut AnyConnection {
fn fetch_many<'e, 'q: 'e, E: 'q>(
self,
mut query: E,
) -> BoxStream<'e, Result<Either<AnyOutcome, AnyRow>, Error>>
) -> BoxStream<'e, Result<Either<AnyQueryResult, AnyRow>, Error>>
where
'c: 'e,
E: Execute<'q, Self::Database>,

View File

@ -1,5 +1,5 @@
use crate::any::{
AnyArgumentBuffer, AnyArguments, AnyColumn, AnyConnection, AnyOutcome, AnyRow, AnyStatement,
AnyArgumentBuffer, AnyArguments, AnyColumn, AnyConnection, AnyQueryResult, AnyRow, AnyStatement,
AnyTransactionManager, AnyTypeInfo, AnyValue, AnyValueRef,
};
use crate::database::{Database, HasArguments, HasStatement, HasStatementCache, HasValueRef};
@ -16,7 +16,7 @@ impl Database for Any {
type Row = AnyRow;
type Outcome = AnyOutcome;
type QueryResult = AnyQueryResult;
type Column = AnyColumn;

View File

@ -15,7 +15,7 @@ mod connection;
mod database;
mod kind;
mod options;
mod outcome;
mod query_result;
pub(crate) mod row;
mod statement;
mod transaction;
@ -34,7 +34,7 @@ pub use decode::AnyDecode;
pub use encode::AnyEncode;
pub use kind::AnyKind;
pub use options::AnyConnectOptions;
pub use outcome::AnyOutcome;
pub use query_result::AnyQueryResult;
pub use r#type::AnyType;
pub use row::AnyRow;
pub use statement::AnyStatement;

View File

@ -1,12 +1,12 @@
use std::iter::{Extend, IntoIterator};
#[derive(Debug, Default)]
pub struct AnyOutcome {
pub struct AnyQueryResult {
pub(crate) rows_affected: u64,
pub(crate) last_insert_id: Option<i64>,
}
impl AnyOutcome {
impl AnyQueryResult {
pub fn rows_affected(&self) -> u64 {
self.rows_affected
}
@ -16,8 +16,8 @@ impl AnyOutcome {
}
}
impl Extend<AnyOutcome> for AnyOutcome {
fn extend<T: IntoIterator<Item = AnyOutcome>>(&mut self, iter: T) {
impl Extend<AnyQueryResult> for AnyQueryResult {
fn extend<T: IntoIterator<Item = AnyQueryResult>>(&mut self, iter: T) {
for elem in iter {
self.rows_affected += elem.rows_affected;
self.last_insert_id = elem.last_insert_id;

View File

@ -86,8 +86,8 @@ pub trait Database:
/// The concrete `Row` implementation for this database.
type Row: Row<Database = Self>;
/// The concrete `Outcome` implementation for this database.
type Outcome: 'static + Sized + Send + Sync + Default + Extend<Self::Outcome>;
/// The concrete `QueryResult` implementation for this database.
type QueryResult: 'static + Sized + Send + Sync + Default + Extend<Self::QueryResult>;
/// The concrete `Column` implementation for this database.
type Column: Column<Database = Self>;

View File

@ -29,7 +29,7 @@ pub trait Executor<'c>: Send + Debug + Sized {
fn execute<'e, 'q: 'e, E: 'q>(
self,
query: E,
) -> BoxFuture<'e, Result<<Self::Database as Database>::Outcome, Error>>
) -> BoxFuture<'e, Result<<Self::Database as Database>::QueryResult, Error>>
where
'c: 'e,
E: Execute<'q, Self::Database>,
@ -41,7 +41,7 @@ pub trait Executor<'c>: Send + Debug + Sized {
fn execute_many<'e, 'q: 'e, E: 'q>(
self,
query: E,
) -> BoxStream<'e, Result<<Self::Database as Database>::Outcome, Error>>
) -> BoxStream<'e, Result<<Self::Database as Database>::QueryResult, Error>>
where
'c: 'e,
E: Execute<'q, Self::Database>,
@ -83,7 +83,7 @@ pub trait Executor<'c>: Send + Debug + Sized {
) -> BoxStream<
'e,
Result<
Either<<Self::Database as Database>::Outcome, <Self::Database as Database>::Row>,
Either<<Self::Database as Database>::QueryResult, <Self::Database as Database>::Row>,
Error,
>,
>

View File

@ -10,7 +10,7 @@ use crate::mssql::protocol::packet::PacketType;
use crate::mssql::protocol::rpc::{OptionFlags, Procedure, RpcRequest};
use crate::mssql::protocol::sql_batch::SqlBatch;
use crate::mssql::{
Mssql, MssqlArguments, MssqlConnection, MssqlOutcome, MssqlRow, MssqlStatement, MssqlTypeInfo,
Mssql, MssqlArguments, MssqlConnection, MssqlQueryResult, MssqlRow, MssqlStatement, MssqlTypeInfo,
};
use either::Either;
use futures_core::future::BoxFuture;
@ -71,7 +71,7 @@ impl<'c> Executor<'c> for &'c mut MssqlConnection {
fn fetch_many<'e, 'q: 'e, E: 'q>(
self,
mut query: E,
) -> BoxStream<'e, Result<Either<MssqlOutcome, MssqlRow>, Error>>
) -> BoxStream<'e, Result<Either<MssqlQueryResult, MssqlRow>, Error>>
where
'c: 'e,
E: Execute<'q, Self::Database>,
@ -102,7 +102,7 @@ impl<'c> Executor<'c> for &'c mut MssqlConnection {
}
if done.status.contains(Status::DONE_COUNT) {
r#yield!(Either::Left(MssqlOutcome {
r#yield!(Either::Left(MssqlQueryResult {
rows_affected: done.affected_rows,
}));
}
@ -114,7 +114,7 @@ impl<'c> Executor<'c> for &'c mut MssqlConnection {
Message::DoneInProc(done) => {
if done.status.contains(Status::DONE_COUNT) {
r#yield!(Either::Left(MssqlOutcome {
r#yield!(Either::Left(MssqlQueryResult {
rows_affected: done.affected_rows,
}));
}

View File

@ -1,6 +1,6 @@
use crate::database::{Database, HasArguments, HasStatement, HasValueRef};
use crate::mssql::{
MssqlArguments, MssqlColumn, MssqlConnection, MssqlOutcome, MssqlRow, MssqlStatement,
MssqlArguments, MssqlColumn, MssqlConnection, MssqlQueryResult, MssqlRow, MssqlStatement,
MssqlTransactionManager, MssqlTypeInfo, MssqlValue, MssqlValueRef,
};
@ -15,7 +15,7 @@ impl Database for Mssql {
type Row = MssqlRow;
type Outcome = MssqlOutcome;
type QueryResult = MssqlQueryResult;
type Column = MssqlColumn;

View File

@ -7,7 +7,7 @@ mod database;
mod error;
mod io;
mod options;
mod outcome;
mod query_result;
mod protocol;
mod row;
mod statement;
@ -22,7 +22,7 @@ pub use connection::MssqlConnection;
pub use database::Mssql;
pub use error::MssqlDatabaseError;
pub use options::MssqlConnectOptions;
pub use outcome::MssqlOutcome;
pub use query_result::MssqlQueryResult;
pub use row::MssqlRow;
pub use statement::MssqlStatement;
pub use transaction::MssqlTransactionManager;

View File

@ -1,18 +1,18 @@
use std::iter::{Extend, IntoIterator};
#[derive(Debug, Default)]
pub struct PgOutcome {
pub struct MssqlQueryResult {
pub(super) rows_affected: u64,
}
impl PgOutcome {
impl MssqlQueryResult {
pub fn rows_affected(&self) -> u64 {
self.rows_affected
}
}
impl Extend<PgOutcome> for PgOutcome {
fn extend<T: IntoIterator<Item = PgOutcome>>(&mut self, iter: T) {
impl Extend<MssqlQueryResult> for MssqlQueryResult {
fn extend<T: IntoIterator<Item = MssqlQueryResult>>(&mut self, iter: T) {
for elem in iter {
self.rows_affected += elem.rows_affected;
}
@ -20,9 +20,9 @@ impl Extend<PgOutcome> for PgOutcome {
}
#[cfg(feature = "any")]
impl From<PgOutcome> for crate::any::AnyOutcome {
fn from(done: PgOutcome) -> Self {
crate::any::AnyOutcome {
impl From<MssqlQueryResult> for crate::any::AnyQueryResult {
fn from(done: MssqlQueryResult) -> Self {
crate::any::AnyQueryResult {
rows_affected: done.rows_affected,
last_insert_id: None,
}

View File

@ -13,7 +13,7 @@ use crate::mysql::protocol::statement::{
use crate::mysql::protocol::text::{ColumnDefinition, ColumnFlags, Query, TextRow};
use crate::mysql::statement::{MySqlStatement, MySqlStatementMetadata};
use crate::mysql::{
MySql, MySqlArguments, MySqlColumn, MySqlConnection, MySqlOutcome, MySqlRow, MySqlTypeInfo,
MySql, MySqlArguments, MySqlColumn, MySqlConnection, MySqlQueryResult, MySqlRow, MySqlTypeInfo,
MySqlValueFormat,
};
use crate::HashMap;
@ -88,7 +88,7 @@ impl MySqlConnection {
sql: &'q str,
arguments: Option<MySqlArguments>,
persistent: bool,
) -> Result<impl Stream<Item = Result<Either<MySqlOutcome, MySqlRow>, Error>> + 'e, Error> {
) -> Result<impl Stream<Item = Result<Either<MySqlQueryResult, MySqlRow>, Error>> + 'e, Error> {
let mut logger = QueryLogger::new(sql, self.log_settings.clone());
self.stream.wait_until_ready().await?;
@ -133,7 +133,7 @@ impl MySqlConnection {
// this indicates either a successful query with no rows at all or a failed query
let ok = packet.ok()?;
let done = MySqlOutcome {
let done = MySqlQueryResult {
rows_affected: ok.affected_rows,
last_insert_id: ok.last_insert_id,
};
@ -171,7 +171,7 @@ impl MySqlConnection {
if packet[0] == 0xfe && packet.len() < 9 {
let eof = packet.eof(self.stream.capabilities)?;
r#yield!(Either::Left(MySqlOutcome {
r#yield!(Either::Left(MySqlQueryResult {
rows_affected: 0,
last_insert_id: 0,
}));
@ -213,7 +213,7 @@ impl<'c> Executor<'c> for &'c mut MySqlConnection {
fn fetch_many<'e, 'q: 'e, E: 'q>(
self,
mut query: E,
) -> BoxStream<'e, Result<Either<MySqlOutcome, MySqlRow>, Error>>
) -> BoxStream<'e, Result<Either<MySqlQueryResult, MySqlRow>, Error>>
where
'c: 'e,
E: Execute<'q, Self::Database>,

View File

@ -1,7 +1,7 @@
use crate::database::{Database, HasArguments, HasStatement, HasStatementCache, HasValueRef};
use crate::mysql::value::{MySqlValue, MySqlValueRef};
use crate::mysql::{
MySqlArguments, MySqlColumn, MySqlConnection, MySqlOutcome, MySqlRow, MySqlStatement,
MySqlArguments, MySqlColumn, MySqlConnection, MySqlQueryResult, MySqlRow, MySqlStatement,
MySqlTransactionManager, MySqlTypeInfo,
};
@ -16,7 +16,7 @@ impl Database for MySql {
type Row = MySqlRow;
type Outcome = MySqlOutcome;
type QueryResult = MySqlQueryResult;
type Column = MySqlColumn;

View File

@ -8,7 +8,7 @@ mod database;
mod error;
mod io;
mod options;
mod outcome;
mod query_result;
mod protocol;
mod row;
mod statement;
@ -26,7 +26,7 @@ pub use connection::MySqlConnection;
pub use database::MySql;
pub use error::MySqlDatabaseError;
pub use options::{MySqlConnectOptions, MySqlSslMode};
pub use outcome::MySqlOutcome;
pub use query_result::MySqlQueryResult;
pub use row::MySqlRow;
pub use statement::MySqlStatement;
pub use transaction::MySqlTransactionManager;

View File

@ -1,12 +1,12 @@
use std::iter::{Extend, IntoIterator};
#[derive(Debug, Default)]
pub struct MySqlOutcome {
pub struct MySqlQueryResult {
pub(super) rows_affected: u64,
pub(super) last_insert_id: u64,
}
impl MySqlOutcome {
impl MySqlQueryResult {
pub fn last_insert_id(&self) -> u64 {
self.last_insert_id
}
@ -16,8 +16,8 @@ impl MySqlOutcome {
}
}
impl Extend<MySqlOutcome> for MySqlOutcome {
fn extend<T: IntoIterator<Item = MySqlOutcome>>(&mut self, iter: T) {
impl Extend<MySqlQueryResult> for MySqlQueryResult {
fn extend<T: IntoIterator<Item = MySqlQueryResult>>(&mut self, iter: T) {
for elem in iter {
self.rows_affected += elem.rows_affected;
self.last_insert_id = elem.last_insert_id;
@ -26,9 +26,9 @@ impl Extend<MySqlOutcome> for MySqlOutcome {
}
#[cfg(feature = "any")]
impl From<MySqlOutcome> for crate::any::AnyOutcome {
fn from(done: MySqlOutcome) -> Self {
crate::any::AnyOutcome {
impl From<MySqlQueryResult> for crate::any::AnyQueryResult {
fn from(done: MySqlQueryResult) -> Self {
crate::any::AnyQueryResult {
rows_affected: done.rows_affected,
last_insert_id: Some(done.last_insert_id as i64),
}

View File

@ -18,7 +18,7 @@ where
fn fetch_many<'e, 'q: 'e, E: 'q>(
self,
query: E,
) -> BoxStream<'e, Result<Either<DB::Outcome, DB::Row>, Error>>
) -> BoxStream<'e, Result<Either<DB::QueryResult, DB::Row>, Error>>
where
E: Execute<'q, Self::Database>,
{
@ -83,7 +83,7 @@ macro_rules! impl_executor_for_pool_connection {
) -> futures_core::stream::BoxStream<
'e,
Result<
either::Either<<$DB as crate::database::Database>::Outcome, $R>,
either::Either<<$DB as crate::database::Database>::QueryResult, $R>,
crate::error::Error,
>,
>

View File

@ -9,7 +9,7 @@ use crate::postgres::message::{
use crate::postgres::statement::PgStatementMetadata;
use crate::postgres::type_info::PgType;
use crate::postgres::{
statement::PgStatement, PgArguments, PgConnection, PgOutcome, PgRow, PgTypeInfo, PgValueFormat,
statement::PgStatement, PgArguments, PgConnection, PgQueryResult, PgRow, PgTypeInfo, PgValueFormat,
Postgres,
};
use either::Either;
@ -198,7 +198,7 @@ impl PgConnection {
limit: u8,
persistent: bool,
metadata_opt: Option<Arc<PgStatementMetadata>>,
) -> Result<impl Stream<Item = Result<Either<PgOutcome, PgRow>, Error>> + 'e, Error> {
) -> Result<impl Stream<Item = Result<Either<PgQueryResult, PgRow>, Error>> + 'e, Error> {
let mut logger = QueryLogger::new(query, self.log_settings.clone());
// before we continue, wait until we are "ready" to accept more queries
@ -274,7 +274,7 @@ impl PgConnection {
// a SQL command completed normally
let cc: CommandComplete = message.decode()?;
r#yield!(Either::Left(PgOutcome {
r#yield!(Either::Left(PgQueryResult {
rows_affected: cc.rows_affected(),
}));
}
@ -336,7 +336,7 @@ impl<'c> Executor<'c> for &'c mut PgConnection {
fn fetch_many<'e, 'q: 'e, E: 'q>(
self,
mut query: E,
) -> BoxStream<'e, Result<Either<PgOutcome, PgRow>, Error>>
) -> BoxStream<'e, Result<Either<PgQueryResult, PgRow>, Error>>
where
'c: 'e,
E: Execute<'q, Self::Database>,

View File

@ -2,7 +2,7 @@ use crate::database::{Database, HasArguments, HasStatement, HasStatementCache, H
use crate::postgres::arguments::PgArgumentBuffer;
use crate::postgres::value::{PgValue, PgValueRef};
use crate::postgres::{
PgArguments, PgColumn, PgConnection, PgOutcome, PgRow, PgStatement, PgTransactionManager,
PgArguments, PgColumn, PgConnection, PgQueryResult, PgRow, PgStatement, PgTransactionManager,
PgTypeInfo,
};
@ -17,7 +17,7 @@ impl Database for Postgres {
type Row = PgRow;
type Outcome = PgOutcome;
type QueryResult = PgQueryResult;
type Column = PgColumn;

View File

@ -4,7 +4,7 @@ use crate::executor::{Execute, Executor};
use crate::pool::PoolOptions;
use crate::pool::{Pool, PoolConnection};
use crate::postgres::message::{MessageFormat, Notification};
use crate::postgres::{PgConnection, PgOutcome, PgRow, PgStatement, PgTypeInfo, Postgres};
use crate::postgres::{PgConnection, PgQueryResult, PgRow, PgStatement, PgTypeInfo, Postgres};
use either::Either;
use futures_channel::mpsc;
use futures_core::future::BoxFuture;
@ -263,7 +263,7 @@ impl<'c> Executor<'c> for &'c mut PgListener {
fn fetch_many<'e, 'q: 'e, E: 'q>(
self,
query: E,
) -> BoxStream<'e, Result<Either<PgOutcome, PgRow>, Error>>
) -> BoxStream<'e, Result<Either<PgQueryResult, PgRow>, Error>>
where
'c: 'e,
E: Execute<'q, Self::Database>,

View File

@ -9,7 +9,7 @@ mod io;
mod listener;
mod message;
mod options;
mod outcome;
mod query_result;
mod row;
mod statement;
mod transaction;
@ -28,7 +28,7 @@ pub use error::{PgDatabaseError, PgErrorPosition};
pub use listener::{PgListener, PgNotification};
pub use message::PgSeverity;
pub use options::{PgConnectOptions, PgSslMode};
pub use outcome::PgOutcome;
pub use query_result::PgQueryResult;
pub use row::PgRow;
pub use statement::PgStatement;
pub use transaction::PgTransactionManager;

View File

@ -1,18 +1,18 @@
use std::iter::{Extend, IntoIterator};
#[derive(Debug, Default)]
pub struct MssqlOutcome {
pub struct PgQueryResult {
pub(super) rows_affected: u64,
}
impl MssqlOutcome {
impl PgQueryResult {
pub fn rows_affected(&self) -> u64 {
self.rows_affected
}
}
impl Extend<MssqlOutcome> for MssqlOutcome {
fn extend<T: IntoIterator<Item = MssqlOutcome>>(&mut self, iter: T) {
impl Extend<PgQueryResult> for PgQueryResult {
fn extend<T: IntoIterator<Item = PgQueryResult>>(&mut self, iter: T) {
for elem in iter {
self.rows_affected += elem.rows_affected;
}
@ -20,9 +20,9 @@ impl Extend<MssqlOutcome> for MssqlOutcome {
}
#[cfg(feature = "any")]
impl From<MssqlOutcome> for crate::any::AnyOutcome {
fn from(done: MssqlOutcome) -> Self {
crate::any::AnyOutcome {
impl From<PgQueryResult> for crate::any::AnyQueryResult {
fn from(done: PgQueryResult) -> Self {
crate::any::AnyQueryResult {
rows_affected: done.rows_affected,
last_insert_id: None,
}

View File

@ -144,7 +144,7 @@ where
/// Execute the query and return the total number of rows affected.
#[inline]
pub async fn execute<'e, 'c: 'e, E>(self, executor: E) -> Result<DB::Outcome, Error>
pub async fn execute<'e, 'c: 'e, E>(self, executor: E) -> Result<DB::QueryResult, Error>
where
'q: 'e,
A: 'e,
@ -158,7 +158,7 @@ where
pub async fn execute_many<'e, 'c: 'e, E>(
self,
executor: E,
) -> BoxStream<'e, Result<DB::Outcome, Error>>
) -> BoxStream<'e, Result<DB::QueryResult, Error>>
where
'q: 'e,
A: 'e,
@ -184,7 +184,7 @@ where
pub fn fetch_many<'e, 'c: 'e, E>(
self,
executor: E,
) -> BoxStream<'e, Result<Either<DB::Outcome, DB::Row>, Error>>
) -> BoxStream<'e, Result<Either<DB::QueryResult, DB::Row>, Error>>
where
'q: 'e,
A: 'e,
@ -322,7 +322,7 @@ where
pub fn fetch_many<'e, 'c: 'e, E>(
mut self,
executor: E,
) -> BoxStream<'e, Result<Either<DB::Outcome, O>, Error>>
) -> BoxStream<'e, Result<Either<DB::QueryResult, O>, Error>>
where
'q: 'e,
E: 'e + Executor<'c, Database = DB>,

View File

@ -84,7 +84,7 @@ where
pub fn fetch_many<'e, 'c: 'e, E>(
self,
executor: E,
) -> BoxStream<'e, Result<Either<DB::Outcome, O>, Error>>
) -> BoxStream<'e, Result<Either<DB::QueryResult, O>, Error>>
where
'q: 'e,
E: 'e + Executor<'c, Database = DB>,

View File

@ -82,7 +82,7 @@ where
pub fn fetch_many<'e, 'c: 'e, E>(
self,
executor: E,
) -> BoxStream<'e, Result<Either<DB::Outcome, O>, Error>>
) -> BoxStream<'e, Result<Either<DB::QueryResult, O>, Error>>
where
'q: 'e,
E: 'e + Executor<'c, Database = DB>,

View File

@ -6,7 +6,7 @@ use crate::logger::QueryLogger;
use crate::sqlite::connection::describe::describe;
use crate::sqlite::statement::{StatementHandle, VirtualStatement};
use crate::sqlite::{
Sqlite, SqliteArguments, SqliteConnection, SqliteOutcome, SqliteRow, SqliteStatement,
Sqlite, SqliteArguments, SqliteConnection, SqliteQueryResult, SqliteRow, SqliteStatement,
SqliteTypeInfo,
};
use either::Either;
@ -65,7 +65,7 @@ impl<'c> Executor<'c> for &'c mut SqliteConnection {
fn fetch_many<'e, 'q: 'e, E: 'q>(
self,
mut query: E,
) -> BoxStream<'e, Result<Either<SqliteOutcome, SqliteRow>, Error>>
) -> BoxStream<'e, Result<Either<SqliteQueryResult, SqliteRow>, Error>>
where
'c: 'e,
E: Execute<'q, Self::Database>,
@ -109,7 +109,7 @@ impl<'c> Executor<'c> for &'c mut SqliteConnection {
sqlite3_last_insert_rowid(conn.as_ptr())
};
let done = SqliteOutcome {
let done = SqliteQueryResult {
changes,
last_insert_rowid,
};

View File

@ -1,6 +1,6 @@
use crate::database::{Database, HasArguments, HasStatement, HasStatementCache, HasValueRef};
use crate::sqlite::{
SqliteArgumentValue, SqliteArguments, SqliteColumn, SqliteConnection, SqliteOutcome, SqliteRow,
SqliteArgumentValue, SqliteArguments, SqliteColumn, SqliteConnection, SqliteQueryResult, SqliteRow,
SqliteStatement, SqliteTransactionManager, SqliteTypeInfo, SqliteValue, SqliteValueRef,
};
@ -15,7 +15,7 @@ impl Database for Sqlite {
type Row = SqliteRow;
type Outcome = SqliteOutcome;
type QueryResult = SqliteQueryResult;
type Column = SqliteColumn;

View File

@ -11,7 +11,7 @@ mod connection;
mod database;
mod error;
mod options;
mod outcome;
mod query_result;
mod row;
mod statement;
mod transaction;
@ -28,7 +28,7 @@ pub use connection::SqliteConnection;
pub use database::Sqlite;
pub use error::SqliteError;
pub use options::{SqliteConnectOptions, SqliteJournalMode, SqliteSynchronous};
pub use outcome::SqliteOutcome;
pub use query_result::SqliteQueryResult;
pub use row::SqliteRow;
pub use statement::SqliteStatement;
pub use transaction::SqliteTransactionManager;

View File

@ -1,12 +1,12 @@
use std::iter::{Extend, IntoIterator};
#[derive(Debug, Default)]
pub struct SqliteOutcome {
pub struct SqliteQueryResult {
pub(super) changes: u64,
pub(super) last_insert_rowid: i64,
}
impl SqliteOutcome {
impl SqliteQueryResult {
pub fn rows_affected(&self) -> u64 {
self.changes
}
@ -16,8 +16,8 @@ impl SqliteOutcome {
}
}
impl Extend<SqliteOutcome> for SqliteOutcome {
fn extend<T: IntoIterator<Item = SqliteOutcome>>(&mut self, iter: T) {
impl Extend<SqliteQueryResult> for SqliteQueryResult {
fn extend<T: IntoIterator<Item = SqliteQueryResult>>(&mut self, iter: T) {
for elem in iter {
self.changes += elem.changes;
self.last_insert_rowid = elem.last_insert_rowid;
@ -26,9 +26,9 @@ impl Extend<SqliteOutcome> for SqliteOutcome {
}
#[cfg(feature = "any")]
impl From<SqliteOutcome> for crate::any::AnyOutcome {
fn from(done: SqliteOutcome) -> Self {
crate::any::AnyOutcome {
impl From<SqliteQueryResult> for crate::any::AnyQueryResult {
fn from(done: SqliteQueryResult) -> Self {
crate::any::AnyQueryResult {
rows_affected: done.changes,
last_insert_id: Some(done.last_insert_rowid),
}

View File

@ -109,7 +109,7 @@ macro_rules! impl_executor_for_transaction {
) -> futures_core::stream::BoxStream<
'e,
Result<
either::Either<<$DB as crate::database::Database>::Outcome, $Row>,
either::Either<<$DB as crate::database::Database>::QueryResult, $Row>,
crate::error::Error,
>,
>

View File

@ -32,7 +32,7 @@
///
/// | Number of Rows | Method to Call* | Returns | Notes |
/// |----------------| ----------------------------|-----------------------------------------------------|-------|
/// | None† | `.execute(...).await` | `sqlx::Result<DB::Outcome> | For `INSERT`/`UPDATE`/`DELETE` without `RETURNING`. |
/// | None† | `.execute(...).await` | `sqlx::Result<DB::QueryResult> | For `INSERT`/`UPDATE`/`DELETE` without `RETURNING`. |
/// | Zero or One | `.fetch_optional(...).await`| `sqlx::Result<Option<{adhoc struct}>>` | Extra rows are ignored. |
/// | Exactly One | `.fetch_one(...).await` | `sqlx::Result<{adhoc struct}>` | Errors if no rows were returned. Extra rows are ignored. Aggregate queries, use this. |
/// | At Least One | `.fetch(...)` | `impl Stream<Item = sqlx::Result<{adhoc struct}>>` | Call `.try_next().await` to get each row result. |