mirror of
https://github.com/launchbadge/sqlx.git
synced 2025-12-29 21:00:54 +00:00
Rename DbDone to DbOutcome
This commit is contained in:
parent
a1d562f04b
commit
08a76f45ae
@ -20,8 +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]] Remove the `Done` trait. The `.rows_affected()` method is now available as an inherent
|
||||
method on `PgDone`, `MySqlDone` and so on.
|
||||
method on `PgOutcome`, `MySqlOutcome` and so on. [[@jplatte]]
|
||||
|
||||
## 0.4.2 - 2020-12-19
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
use crate::any::connection::AnyConnectionKind;
|
||||
use crate::any::{Any, AnyColumn, AnyConnection, AnyDone, AnyRow, AnyStatement, AnyTypeInfo};
|
||||
use crate::any::{Any, AnyColumn, AnyConnection, AnyOutcome, 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<AnyDone, AnyRow>, Error>>
|
||||
) -> BoxStream<'e, Result<Either<AnyOutcome, AnyRow>, Error>>
|
||||
where
|
||||
'c: 'e,
|
||||
E: Execute<'q, Self::Database>,
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
use crate::any::{
|
||||
AnyArgumentBuffer, AnyArguments, AnyColumn, AnyConnection, AnyDone, AnyRow, AnyStatement,
|
||||
AnyArgumentBuffer, AnyArguments, AnyColumn, AnyConnection, AnyOutcome, 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 Done = AnyDone;
|
||||
type Outcome = AnyOutcome;
|
||||
|
||||
type Column = AnyColumn;
|
||||
|
||||
|
||||
@ -13,9 +13,9 @@ mod arguments;
|
||||
pub(crate) mod column;
|
||||
mod connection;
|
||||
mod database;
|
||||
mod done;
|
||||
mod kind;
|
||||
mod options;
|
||||
mod outcome;
|
||||
pub(crate) mod row;
|
||||
mod statement;
|
||||
mod transaction;
|
||||
@ -31,10 +31,10 @@ pub use column::{AnyColumn, AnyColumnIndex};
|
||||
pub use connection::AnyConnection;
|
||||
pub use database::Any;
|
||||
pub use decode::AnyDecode;
|
||||
pub use done::AnyDone;
|
||||
pub use encode::AnyEncode;
|
||||
pub use kind::AnyKind;
|
||||
pub use options::AnyConnectOptions;
|
||||
pub use outcome::AnyOutcome;
|
||||
pub use r#type::AnyType;
|
||||
pub use row::AnyRow;
|
||||
pub use statement::AnyStatement;
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
use std::iter::{Extend, IntoIterator};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct AnyDone {
|
||||
pub struct AnyOutcome {
|
||||
pub(crate) rows_affected: u64,
|
||||
pub(crate) last_insert_id: Option<i64>,
|
||||
}
|
||||
|
||||
impl AnyDone {
|
||||
impl AnyOutcome {
|
||||
pub fn rows_affected(&self) -> u64 {
|
||||
self.rows_affected
|
||||
}
|
||||
@ -16,8 +16,8 @@ impl AnyDone {
|
||||
}
|
||||
}
|
||||
|
||||
impl Extend<AnyDone> for AnyDone {
|
||||
fn extend<T: IntoIterator<Item = AnyDone>>(&mut self, iter: T) {
|
||||
impl Extend<AnyOutcome> for AnyOutcome {
|
||||
fn extend<T: IntoIterator<Item = AnyOutcome>>(&mut self, iter: T) {
|
||||
for elem in iter {
|
||||
self.rows_affected += elem.rows_affected;
|
||||
self.last_insert_id = elem.last_insert_id;
|
||||
@ -86,8 +86,8 @@ pub trait Database:
|
||||
/// The concrete `Row` implementation for this database.
|
||||
type Row: Row<Database = Self>;
|
||||
|
||||
/// The concrete `Done` implementation for this database.
|
||||
type Done: 'static + Sized + Send + Sync + Default + Extend<Self::Done>;
|
||||
/// The concrete `Outcome` implementation for this database.
|
||||
type Outcome: 'static + Sized + Send + Sync + Default + Extend<Self::Outcome>;
|
||||
|
||||
/// The concrete `Column` implementation for this database.
|
||||
type Column: Column<Database = Self>;
|
||||
|
||||
@ -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>::Done, Error>>
|
||||
) -> BoxFuture<'e, Result<<Self::Database as Database>::Outcome, 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>::Done, Error>>
|
||||
) -> BoxStream<'e, Result<<Self::Database as Database>::Outcome, 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>::Done, <Self::Database as Database>::Row>,
|
||||
Either<<Self::Database as Database>::Outcome, <Self::Database as Database>::Row>,
|
||||
Error,
|
||||
>,
|
||||
>
|
||||
|
||||
@ -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, MssqlDone, MssqlRow, MssqlStatement, MssqlTypeInfo,
|
||||
Mssql, MssqlArguments, MssqlConnection, MssqlOutcome, 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<MssqlDone, MssqlRow>, Error>>
|
||||
) -> BoxStream<'e, Result<Either<MssqlOutcome, 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(MssqlDone {
|
||||
r#yield!(Either::Left(MssqlOutcome {
|
||||
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(MssqlDone {
|
||||
r#yield!(Either::Left(MssqlOutcome {
|
||||
rows_affected: done.affected_rows,
|
||||
}));
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
use crate::database::{Database, HasArguments, HasStatement, HasValueRef};
|
||||
use crate::mssql::{
|
||||
MssqlArguments, MssqlColumn, MssqlConnection, MssqlDone, MssqlRow, MssqlStatement,
|
||||
MssqlArguments, MssqlColumn, MssqlConnection, MssqlOutcome, MssqlRow, MssqlStatement,
|
||||
MssqlTransactionManager, MssqlTypeInfo, MssqlValue, MssqlValueRef,
|
||||
};
|
||||
|
||||
@ -15,7 +15,7 @@ impl Database for Mssql {
|
||||
|
||||
type Row = MssqlRow;
|
||||
|
||||
type Done = MssqlDone;
|
||||
type Outcome = MssqlOutcome;
|
||||
|
||||
type Column = MssqlColumn;
|
||||
|
||||
|
||||
@ -4,10 +4,10 @@ mod arguments;
|
||||
mod column;
|
||||
mod connection;
|
||||
mod database;
|
||||
mod done;
|
||||
mod error;
|
||||
mod io;
|
||||
mod options;
|
||||
mod outcome;
|
||||
mod protocol;
|
||||
mod row;
|
||||
mod statement;
|
||||
@ -20,9 +20,9 @@ pub use arguments::MssqlArguments;
|
||||
pub use column::MssqlColumn;
|
||||
pub use connection::MssqlConnection;
|
||||
pub use database::Mssql;
|
||||
pub use done::MssqlDone;
|
||||
pub use error::MssqlDatabaseError;
|
||||
pub use options::MssqlConnectOptions;
|
||||
pub use outcome::MssqlOutcome;
|
||||
pub use row::MssqlRow;
|
||||
pub use statement::MssqlStatement;
|
||||
pub use transaction::MssqlTransactionManager;
|
||||
|
||||
@ -1,18 +1,18 @@
|
||||
use std::iter::{Extend, IntoIterator};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct PgDone {
|
||||
pub struct MssqlOutcome {
|
||||
pub(super) rows_affected: u64,
|
||||
}
|
||||
|
||||
impl PgDone {
|
||||
impl MssqlOutcome {
|
||||
pub fn rows_affected(&self) -> u64 {
|
||||
self.rows_affected
|
||||
}
|
||||
}
|
||||
|
||||
impl Extend<PgDone> for PgDone {
|
||||
fn extend<T: IntoIterator<Item = PgDone>>(&mut self, iter: T) {
|
||||
impl Extend<MssqlOutcome> for MssqlOutcome {
|
||||
fn extend<T: IntoIterator<Item = MssqlOutcome>>(&mut self, iter: T) {
|
||||
for elem in iter {
|
||||
self.rows_affected += elem.rows_affected;
|
||||
}
|
||||
@ -20,9 +20,9 @@ impl Extend<PgDone> for PgDone {
|
||||
}
|
||||
|
||||
#[cfg(feature = "any")]
|
||||
impl From<PgDone> for crate::any::AnyDone {
|
||||
fn from(done: PgDone) -> Self {
|
||||
crate::any::AnyDone {
|
||||
impl From<MssqlOutcome> for crate::any::AnyOutcome {
|
||||
fn from(done: MssqlOutcome) -> Self {
|
||||
crate::any::AnyOutcome {
|
||||
rows_affected: done.rows_affected,
|
||||
last_insert_id: None,
|
||||
}
|
||||
@ -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, MySqlDone, MySqlRow, MySqlTypeInfo,
|
||||
MySql, MySqlArguments, MySqlColumn, MySqlConnection, MySqlOutcome, 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<MySqlDone, MySqlRow>, Error>> + 'e, Error> {
|
||||
) -> Result<impl Stream<Item = Result<Either<MySqlOutcome, 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 = MySqlDone {
|
||||
let done = MySqlOutcome {
|
||||
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(MySqlDone {
|
||||
r#yield!(Either::Left(MySqlOutcome {
|
||||
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<MySqlDone, MySqlRow>, Error>>
|
||||
) -> BoxStream<'e, Result<Either<MySqlOutcome, MySqlRow>, Error>>
|
||||
where
|
||||
'c: 'e,
|
||||
E: Execute<'q, Self::Database>,
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
use crate::database::{Database, HasArguments, HasStatement, HasStatementCache, HasValueRef};
|
||||
use crate::mysql::value::{MySqlValue, MySqlValueRef};
|
||||
use crate::mysql::{
|
||||
MySqlArguments, MySqlColumn, MySqlConnection, MySqlDone, MySqlRow, MySqlStatement,
|
||||
MySqlArguments, MySqlColumn, MySqlConnection, MySqlOutcome, MySqlRow, MySqlStatement,
|
||||
MySqlTransactionManager, MySqlTypeInfo,
|
||||
};
|
||||
|
||||
@ -16,7 +16,7 @@ impl Database for MySql {
|
||||
|
||||
type Row = MySqlRow;
|
||||
|
||||
type Done = MySqlDone;
|
||||
type Outcome = MySqlOutcome;
|
||||
|
||||
type Column = MySqlColumn;
|
||||
|
||||
|
||||
@ -5,10 +5,10 @@ mod collation;
|
||||
mod column;
|
||||
mod connection;
|
||||
mod database;
|
||||
mod done;
|
||||
mod error;
|
||||
mod io;
|
||||
mod options;
|
||||
mod outcome;
|
||||
mod protocol;
|
||||
mod row;
|
||||
mod statement;
|
||||
@ -24,9 +24,9 @@ pub use arguments::MySqlArguments;
|
||||
pub use column::MySqlColumn;
|
||||
pub use connection::MySqlConnection;
|
||||
pub use database::MySql;
|
||||
pub use done::MySqlDone;
|
||||
pub use error::MySqlDatabaseError;
|
||||
pub use options::{MySqlConnectOptions, MySqlSslMode};
|
||||
pub use outcome::MySqlOutcome;
|
||||
pub use row::MySqlRow;
|
||||
pub use statement::MySqlStatement;
|
||||
pub use transaction::MySqlTransactionManager;
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
use std::iter::{Extend, IntoIterator};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct MySqlDone {
|
||||
pub struct MySqlOutcome {
|
||||
pub(super) rows_affected: u64,
|
||||
pub(super) last_insert_id: u64,
|
||||
}
|
||||
|
||||
impl MySqlDone {
|
||||
impl MySqlOutcome {
|
||||
pub fn last_insert_id(&self) -> u64 {
|
||||
self.last_insert_id
|
||||
}
|
||||
@ -16,8 +16,8 @@ impl MySqlDone {
|
||||
}
|
||||
}
|
||||
|
||||
impl Extend<MySqlDone> for MySqlDone {
|
||||
fn extend<T: IntoIterator<Item = MySqlDone>>(&mut self, iter: T) {
|
||||
impl Extend<MySqlOutcome> for MySqlOutcome {
|
||||
fn extend<T: IntoIterator<Item = MySqlOutcome>>(&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<MySqlDone> for MySqlDone {
|
||||
}
|
||||
|
||||
#[cfg(feature = "any")]
|
||||
impl From<MySqlDone> for crate::any::AnyDone {
|
||||
fn from(done: MySqlDone) -> Self {
|
||||
crate::any::AnyDone {
|
||||
impl From<MySqlOutcome> for crate::any::AnyOutcome {
|
||||
fn from(done: MySqlOutcome) -> Self {
|
||||
crate::any::AnyOutcome {
|
||||
rows_affected: done.rows_affected,
|
||||
last_insert_id: Some(done.last_insert_id as i64),
|
||||
}
|
||||
@ -18,7 +18,7 @@ where
|
||||
fn fetch_many<'e, 'q: 'e, E: 'q>(
|
||||
self,
|
||||
query: E,
|
||||
) -> BoxStream<'e, Result<Either<DB::Done, DB::Row>, Error>>
|
||||
) -> BoxStream<'e, Result<Either<DB::Outcome, 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>::Done, $R>,
|
||||
either::Either<<$DB as crate::database::Database>::Outcome, $R>,
|
||||
crate::error::Error,
|
||||
>,
|
||||
>
|
||||
|
||||
@ -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, PgDone, PgRow, PgTypeInfo, PgValueFormat,
|
||||
statement::PgStatement, PgArguments, PgConnection, PgOutcome, 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<PgDone, PgRow>, Error>> + 'e, Error> {
|
||||
) -> Result<impl Stream<Item = Result<Either<PgOutcome, 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(PgDone {
|
||||
r#yield!(Either::Left(PgOutcome {
|
||||
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<PgDone, PgRow>, Error>>
|
||||
) -> BoxStream<'e, Result<Either<PgOutcome, PgRow>, Error>>
|
||||
where
|
||||
'c: 'e,
|
||||
E: Execute<'q, Self::Database>,
|
||||
|
||||
@ -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, PgDone, PgRow, PgStatement, PgTransactionManager,
|
||||
PgArguments, PgColumn, PgConnection, PgOutcome, PgRow, PgStatement, PgTransactionManager,
|
||||
PgTypeInfo,
|
||||
};
|
||||
|
||||
@ -17,7 +17,7 @@ impl Database for Postgres {
|
||||
|
||||
type Row = PgRow;
|
||||
|
||||
type Done = PgDone;
|
||||
type Outcome = PgOutcome;
|
||||
|
||||
type Column = PgColumn;
|
||||
|
||||
|
||||
@ -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, PgDone, PgRow, PgStatement, PgTypeInfo, Postgres};
|
||||
use crate::postgres::{PgConnection, PgOutcome, 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<PgDone, PgRow>, Error>>
|
||||
) -> BoxStream<'e, Result<Either<PgOutcome, PgRow>, Error>>
|
||||
where
|
||||
'c: 'e,
|
||||
E: Execute<'q, Self::Database>,
|
||||
|
||||
@ -4,12 +4,12 @@ mod arguments;
|
||||
mod column;
|
||||
mod connection;
|
||||
mod database;
|
||||
mod done;
|
||||
mod error;
|
||||
mod io;
|
||||
mod listener;
|
||||
mod message;
|
||||
mod options;
|
||||
mod outcome;
|
||||
mod row;
|
||||
mod statement;
|
||||
mod transaction;
|
||||
@ -24,11 +24,11 @@ pub use arguments::{PgArgumentBuffer, PgArguments};
|
||||
pub use column::PgColumn;
|
||||
pub use connection::PgConnection;
|
||||
pub use database::Postgres;
|
||||
pub use done::PgDone;
|
||||
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 row::PgRow;
|
||||
pub use statement::PgStatement;
|
||||
pub use transaction::PgTransactionManager;
|
||||
|
||||
@ -1,18 +1,18 @@
|
||||
use std::iter::{Extend, IntoIterator};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct MssqlDone {
|
||||
pub struct PgOutcome {
|
||||
pub(super) rows_affected: u64,
|
||||
}
|
||||
|
||||
impl MssqlDone {
|
||||
impl PgOutcome {
|
||||
pub fn rows_affected(&self) -> u64 {
|
||||
self.rows_affected
|
||||
}
|
||||
}
|
||||
|
||||
impl Extend<MssqlDone> for MssqlDone {
|
||||
fn extend<T: IntoIterator<Item = MssqlDone>>(&mut self, iter: T) {
|
||||
impl Extend<PgOutcome> for PgOutcome {
|
||||
fn extend<T: IntoIterator<Item = PgOutcome>>(&mut self, iter: T) {
|
||||
for elem in iter {
|
||||
self.rows_affected += elem.rows_affected;
|
||||
}
|
||||
@ -20,9 +20,9 @@ impl Extend<MssqlDone> for MssqlDone {
|
||||
}
|
||||
|
||||
#[cfg(feature = "any")]
|
||||
impl From<MssqlDone> for crate::any::AnyDone {
|
||||
fn from(done: MssqlDone) -> Self {
|
||||
crate::any::AnyDone {
|
||||
impl From<PgOutcome> for crate::any::AnyOutcome {
|
||||
fn from(done: PgOutcome) -> Self {
|
||||
crate::any::AnyOutcome {
|
||||
rows_affected: done.rows_affected,
|
||||
last_insert_id: None,
|
||||
}
|
||||
@ -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::Done, Error>
|
||||
pub async fn execute<'e, 'c: 'e, E>(self, executor: E) -> Result<DB::Outcome, 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::Done, Error>>
|
||||
) -> BoxStream<'e, Result<DB::Outcome, 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::Done, DB::Row>, Error>>
|
||||
) -> BoxStream<'e, Result<Either<DB::Outcome, 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::Done, O>, Error>>
|
||||
) -> BoxStream<'e, Result<Either<DB::Outcome, O>, Error>>
|
||||
where
|
||||
'q: 'e,
|
||||
E: 'e + Executor<'c, Database = DB>,
|
||||
|
||||
@ -84,7 +84,7 @@ where
|
||||
pub fn fetch_many<'e, 'c: 'e, E>(
|
||||
self,
|
||||
executor: E,
|
||||
) -> BoxStream<'e, Result<Either<DB::Done, O>, Error>>
|
||||
) -> BoxStream<'e, Result<Either<DB::Outcome, O>, Error>>
|
||||
where
|
||||
'q: 'e,
|
||||
E: 'e + Executor<'c, Database = DB>,
|
||||
|
||||
@ -82,7 +82,7 @@ where
|
||||
pub fn fetch_many<'e, 'c: 'e, E>(
|
||||
self,
|
||||
executor: E,
|
||||
) -> BoxStream<'e, Result<Either<DB::Done, O>, Error>>
|
||||
) -> BoxStream<'e, Result<Either<DB::Outcome, O>, Error>>
|
||||
where
|
||||
'q: 'e,
|
||||
E: 'e + Executor<'c, Database = DB>,
|
||||
|
||||
@ -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, SqliteDone, SqliteRow, SqliteStatement,
|
||||
Sqlite, SqliteArguments, SqliteConnection, SqliteOutcome, 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<SqliteDone, SqliteRow>, Error>>
|
||||
) -> BoxStream<'e, Result<Either<SqliteOutcome, 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 = SqliteDone {
|
||||
let done = SqliteOutcome {
|
||||
changes,
|
||||
last_insert_rowid,
|
||||
};
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
use crate::database::{Database, HasArguments, HasStatement, HasStatementCache, HasValueRef};
|
||||
use crate::sqlite::{
|
||||
SqliteArgumentValue, SqliteArguments, SqliteColumn, SqliteConnection, SqliteDone, SqliteRow,
|
||||
SqliteArgumentValue, SqliteArguments, SqliteColumn, SqliteConnection, SqliteOutcome, SqliteRow,
|
||||
SqliteStatement, SqliteTransactionManager, SqliteTypeInfo, SqliteValue, SqliteValueRef,
|
||||
};
|
||||
|
||||
@ -15,7 +15,7 @@ impl Database for Sqlite {
|
||||
|
||||
type Row = SqliteRow;
|
||||
|
||||
type Done = SqliteDone;
|
||||
type Outcome = SqliteOutcome;
|
||||
|
||||
type Column = SqliteColumn;
|
||||
|
||||
|
||||
@ -9,9 +9,9 @@ mod arguments;
|
||||
mod column;
|
||||
mod connection;
|
||||
mod database;
|
||||
mod done;
|
||||
mod error;
|
||||
mod options;
|
||||
mod outcome;
|
||||
mod row;
|
||||
mod statement;
|
||||
mod transaction;
|
||||
@ -26,9 +26,9 @@ pub use arguments::{SqliteArgumentValue, SqliteArguments};
|
||||
pub use column::SqliteColumn;
|
||||
pub use connection::SqliteConnection;
|
||||
pub use database::Sqlite;
|
||||
pub use done::SqliteDone;
|
||||
pub use error::SqliteError;
|
||||
pub use options::{SqliteConnectOptions, SqliteJournalMode, SqliteSynchronous};
|
||||
pub use outcome::SqliteOutcome;
|
||||
pub use row::SqliteRow;
|
||||
pub use statement::SqliteStatement;
|
||||
pub use transaction::SqliteTransactionManager;
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
use std::iter::{Extend, IntoIterator};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct SqliteDone {
|
||||
pub struct SqliteOutcome {
|
||||
pub(super) changes: u64,
|
||||
pub(super) last_insert_rowid: i64,
|
||||
}
|
||||
|
||||
impl SqliteDone {
|
||||
impl SqliteOutcome {
|
||||
pub fn rows_affected(&self) -> u64 {
|
||||
self.changes
|
||||
}
|
||||
@ -16,8 +16,8 @@ impl SqliteDone {
|
||||
}
|
||||
}
|
||||
|
||||
impl Extend<SqliteDone> for SqliteDone {
|
||||
fn extend<T: IntoIterator<Item = SqliteDone>>(&mut self, iter: T) {
|
||||
impl Extend<SqliteOutcome> for SqliteOutcome {
|
||||
fn extend<T: IntoIterator<Item = SqliteOutcome>>(&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<SqliteDone> for SqliteDone {
|
||||
}
|
||||
|
||||
#[cfg(feature = "any")]
|
||||
impl From<SqliteDone> for crate::any::AnyDone {
|
||||
fn from(done: SqliteDone) -> Self {
|
||||
crate::any::AnyDone {
|
||||
impl From<SqliteOutcome> for crate::any::AnyOutcome {
|
||||
fn from(done: SqliteOutcome) -> Self {
|
||||
crate::any::AnyOutcome {
|
||||
rows_affected: done.changes,
|
||||
last_insert_id: Some(done.last_insert_rowid),
|
||||
}
|
||||
@ -109,7 +109,7 @@ macro_rules! impl_executor_for_transaction {
|
||||
) -> futures_core::stream::BoxStream<
|
||||
'e,
|
||||
Result<
|
||||
either::Either<<$DB as crate::database::Database>::Done, $Row>,
|
||||
either::Either<<$DB as crate::database::Database>::Outcome, $Row>,
|
||||
crate::error::Error,
|
||||
>,
|
||||
>
|
||||
|
||||
@ -32,12 +32,12 @@
|
||||
///
|
||||
/// | Number of Rows | Method to Call* | Returns | Notes |
|
||||
/// |----------------| ----------------------------|-----------------------------------------------------|-------|
|
||||
/// | None† | `.execute(...).await` | `sqlx::Result<DB::Done>` | For `INSERT`/`UPDATE`/`DELETE` without `RETURNING`. |
|
||||
/// | None† | `.execute(...).await` | `sqlx::Result<DB::Outcome> | 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. |
|
||||
///
|
||||
/// \* All methods accept one of `&mut {connection type}`, `&mut Transaction` or `&Pool`.
|
||||
/// \* All methods accept one of `&mut {connection type}`, `&mut Transaction` or `&Pool`.
|
||||
/// † Only callable if the query returns no columns; otherwise it's assumed the query *may* return at least one row.
|
||||
/// ## Requirements
|
||||
/// * The `DATABASE_URL` environment variable must be set at build-time to point to a database
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user