Skip to content

Commit

Permalink
Remove the Done trait
Browse files Browse the repository at this point in the history
  • Loading branch information
jplatte committed Jan 12, 2021
1 parent fd0101a commit b8aa0fb
Show file tree
Hide file tree
Showing 14 changed files with 18 additions and 51 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ 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]] Remove the `Done` trait. The `.rows_affected()` method is now available as an inherent
method on `PgDone`, `MySqlDone` and so on.

## 0.4.2 - 2020-12-19

- [[#908]] Fix `whoami` crash on FreeBSD platform [[@fundon]] [[@AldaronLau]]
Expand Down
1 change: 0 additions & 1 deletion examples/mysql/todos/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use sqlx::mysql::MySqlPool;
use sqlx::Done;
use std::env;
use structopt::StructOpt;

Expand Down
1 change: 0 additions & 1 deletion examples/postgres/mockable-todos/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use async_trait::async_trait;
use dotenv;
use sqlx::postgres::PgPool;
use sqlx::Done;
use std::{env, io::Write, sync::Arc};
use structopt::StructOpt;

Expand Down
1 change: 0 additions & 1 deletion examples/postgres/todos/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use sqlx::postgres::PgPool;
use sqlx::Done;
use std::env;
use structopt::StructOpt;

Expand Down
1 change: 0 additions & 1 deletion examples/sqlite/todos/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use sqlx::sqlite::SqlitePool;
use sqlx::Done;
use std::env;
use structopt::StructOpt;

Expand Down
13 changes: 4 additions & 9 deletions sqlx-core/src/any/done.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::any::Any;
use crate::done::Done;
use std::iter::{Extend, IntoIterator};

#[derive(Debug, Default)]
Expand All @@ -9,16 +8,12 @@ pub struct AnyDone {
}

impl AnyDone {
pub fn last_insert_id(&self) -> Option<i64> {
self.last_insert_id
pub fn rows_affected(&self) -> u64 {
self.rows_affected
}
}

impl Done for AnyDone {
type Database = Any;

fn rows_affected(&self) -> u64 {
self.rows_affected
pub fn last_insert_id(&self) -> Option<i64> {
self.last_insert_id
}
}

Expand Down
3 changes: 1 addition & 2 deletions sqlx-core/src/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ use std::fmt::Debug;
use crate::arguments::Arguments;
use crate::column::Column;
use crate::connection::Connection;
use crate::done::Done;
use crate::row::Row;
use crate::statement::Statement;
use crate::transaction::TransactionManager;
Expand Down Expand Up @@ -88,7 +87,7 @@ pub trait Database:
type Row: Row<Database = Self>;

/// The concrete `Done` implementation for this database.
type Done: Done<Database = Self>;
type Done;

/// The concrete `Column` implementation for this database.
type Column: Column<Database = Self>;
Expand Down
9 changes: 0 additions & 9 deletions sqlx-core/src/done.rs

This file was deleted.

1 change: 0 additions & 1 deletion sqlx-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ pub mod statement;
mod common;
pub mod database;
pub mod describe;
pub mod done;
pub mod executor;
pub mod from_row;
mod io;
Expand Down
7 changes: 2 additions & 5 deletions sqlx-core/src/mssql/done.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::done::Done;
use crate::mssql::Mssql;
use std::iter::{Extend, IntoIterator};

Expand All @@ -7,10 +6,8 @@ pub struct MssqlDone {
pub(super) rows_affected: u64,
}

impl Done for MssqlDone {
type Database = Mssql;

fn rows_affected(&self) -> u64 {
impl MssqlDone {
pub fn rows_affected(&self) -> u64 {
self.rows_affected
}
}
Expand Down
7 changes: 1 addition & 6 deletions sqlx-core/src/mysql/done.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::done::Done;
use crate::mysql::MySql;
use std::iter::{Extend, IntoIterator};

Expand All @@ -12,12 +11,8 @@ impl MySqlDone {
pub fn last_insert_id(&self) -> u64 {
self.last_insert_id
}
}

impl Done for MySqlDone {
type Database = MySql;

fn rows_affected(&self) -> u64 {
pub fn rows_affected(&self) -> u64 {
self.rows_affected
}
}
Expand Down
7 changes: 2 additions & 5 deletions sqlx-core/src/postgres/done.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::done::Done;
use crate::postgres::Postgres;
use std::iter::{Extend, IntoIterator};

Expand All @@ -7,10 +6,8 @@ pub struct PgDone {
pub(super) rows_affected: u64,
}

impl Done for PgDone {
type Database = Postgres;

fn rows_affected(&self) -> u64 {
impl PgDone {
pub fn rows_affected(&self) -> u64 {
self.rows_affected
}
}
Expand Down
13 changes: 4 additions & 9 deletions sqlx-core/src/sqlite/done.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::done::Done;
use crate::sqlite::Sqlite;
use std::iter::{Extend, IntoIterator};

Expand All @@ -9,16 +8,12 @@ pub struct SqliteDone {
}

impl SqliteDone {
pub fn last_insert_rowid(&self) -> i64 {
self.last_insert_rowid
pub fn rows_affected(&self) -> u64 {
self.changes
}
}

impl Done for SqliteDone {
type Database = Sqlite;

fn rows_affected(&self) -> u64 {
self.changes
pub fn last_insert_rowid(&self) -> i64 {
self.last_insert_rowid
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
///
/// | Number of Rows | Method to Call* | Returns | Notes |
/// |----------------| ----------------------------|-----------------------------------------------------|-------|
/// | None† | `.execute(...).await` | `sqlx::Result<impl Done>` | For `INSERT`/`UPDATE`/`DELETE` without `RETURNING`. See [`crate::Done`]. |
/// | None† | `.execute(...).await` | `sqlx::Result<DB::Done>` | 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. |
Expand Down

0 comments on commit b8aa0fb

Please sign in to comment.