Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 3 additions & 3 deletions diesel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ byteorder = "1.0"
diesel_derives = "~1.4.0"
chrono = { version = "0.4", optional = true }
libc = { version = "0.2.0", optional = true }
libsqlite3-sys = { version = ">=0.8.0, <0.13.0", optional = true, features = ["min_sqlite_version_3_7_16"] }
libsqlite3-sys = { version = ">=0.8.0, <0.17.0", optional = true, features = ["min_sqlite_version_3_7_16"] }
mysqlclient-sys = { version = ">=0.1.0, <0.3.0", optional = true }
pq-sys = { version = ">=0.3.0, <0.5.0", optional = true }
quickcheck = { version = "0.4", optional = true }
Expand All @@ -25,11 +25,11 @@ time = { version = "0.1", optional = true }
url = { version = "1.4.0", optional = true }
uuid = { version = ">=0.2.0, <0.7.0", optional = true, features = ["use_std"] }
uuidv07 = { version = "0.7.0", optional = true, package = "uuid"}
ipnetwork = { version = ">=0.12.2, <0.14.0", optional = true }
ipnetwork = { version = ">=0.12.2, <0.16.0", optional = true }
num-bigint = { version = ">=0.1.41, <0.3", optional = true }
num-traits = { version = "0.2", optional = true }
num-integer = { version = "0.1.32", optional = true }
bigdecimal = { version = ">= 0.0.10, < 0.0.15", optional = true }
bigdecimal = { version = ">= 0.0.10, <= 0.1.0", optional = true }
bitflags = { version = "1.0", optional = true }
r2d2 = { version = ">= 0.8, < 0.9", optional = true }

Expand Down
2 changes: 1 addition & 1 deletion diesel/src/deserialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use row::{NamedRow, Row};

/// A specialized result type representing the result of deserializing
/// a value from the database.
pub type Result<T> = result::Result<T, Box<Error + Send + Sync>>;
pub type Result<T> = result::Result<T, Box<dyn Error + Send + Sync>>;

/// Trait indicating that a record can be queried from the database.
///
Expand Down
2 changes: 1 addition & 1 deletion diesel/src/expression/functions/date_and_time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ sql_function! {
/// ```ignore
/// # #[macro_use] extern crate diesel;
/// # extern crate chrono;
/// # include!(\"../../doctest_setup.rs\");
/// # include!("../../doctest_setup.rs");
/// # use diesel::dsl::*;
/// #
/// # fn main() {
Expand Down
2 changes: 1 addition & 1 deletion diesel/src/expression/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ where
{
}

impl<'a, QS, ST, DB> QueryId for BoxableExpression<QS, DB, SqlType = ST> + 'a {
impl<'a, QS, ST, DB> QueryId for dyn BoxableExpression<QS, DB, SqlType = ST> + 'a {
type QueryId = ();

const HAS_STATIC_QUERY_ID: bool = false;
Expand Down
16 changes: 8 additions & 8 deletions diesel/src/migration/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,42 +11,42 @@ pub trait Migration {
/// Get the migration version
fn version(&self) -> &str;
/// Apply this migration
fn run(&self, conn: &SimpleConnection) -> Result<(), RunMigrationsError>;
fn run(&self, conn: &dyn SimpleConnection) -> Result<(), RunMigrationsError>;
/// Revert this migration
fn revert(&self, conn: &SimpleConnection) -> Result<(), RunMigrationsError>;
fn revert(&self, conn: &dyn SimpleConnection) -> Result<(), RunMigrationsError>;
/// Get the migration file path
fn file_path(&self) -> Option<&Path> {
None
}
}

impl Migration for Box<Migration> {
impl Migration for Box<dyn Migration> {
fn version(&self) -> &str {
(&**self).version()
}

fn run(&self, conn: &SimpleConnection) -> Result<(), RunMigrationsError> {
fn run(&self, conn: &dyn SimpleConnection) -> Result<(), RunMigrationsError> {
(&**self).run(conn)
}

fn revert(&self, conn: &SimpleConnection) -> Result<(), RunMigrationsError> {
fn revert(&self, conn: &dyn SimpleConnection) -> Result<(), RunMigrationsError> {
(&**self).revert(conn)
}
fn file_path(&self) -> Option<&Path> {
(&**self).file_path()
}
}

impl<'a> Migration for &'a Migration {
impl<'a> Migration for &'a dyn Migration {
fn version(&self) -> &str {
(&**self).version()
}

fn run(&self, conn: &SimpleConnection) -> Result<(), RunMigrationsError> {
fn run(&self, conn: &dyn SimpleConnection) -> Result<(), RunMigrationsError> {
(&**self).run(conn)
}

fn revert(&self, conn: &SimpleConnection) -> Result<(), RunMigrationsError> {
fn revert(&self, conn: &dyn SimpleConnection) -> Result<(), RunMigrationsError> {
(&**self).revert(conn)
}
fn file_path(&self) -> Option<&Path> {
Expand Down
4 changes: 2 additions & 2 deletions diesel/src/mysql/connection/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ extern crate mysqlclient_sys as ffi;
use std::ffi::CStr;
use std::os::raw as libc;
use std::ptr::{self, NonNull};
use std::sync::{Once, ONCE_INIT};
use std::sync::Once;

use super::stmt::Statement;
use super::url::ConnectionOptions;
Expand Down Expand Up @@ -195,7 +195,7 @@ impl Drop for RawConnection {
/// > any other client library call.
///
/// <https://dev.mysql.com/doc/refman/5.7/en/mysql-init.html>
static MYSQL_THREAD_UNSAFE_INIT: Once = ONCE_INIT;
static MYSQL_THREAD_UNSAFE_INIT: Once = Once::new();

fn perform_thread_unsafe_library_initialization() {
MYSQL_THREAD_UNSAFE_INIT.call_once(|| {
Expand Down
2 changes: 0 additions & 2 deletions diesel/src/pg/connection/cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ impl NamedCursor {
where
T: QueryableByName<Pg>,
{
use result::Error::DeserializationError;

(0..self.db_result.num_rows())
.map(|i| {
let row = PgNamedRow::new(&self, i);
Expand Down
1 change: 1 addition & 0 deletions diesel/src/pg/metadata_lookup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use prelude::*;

/// Determines the OID of types at runtime
#[allow(missing_debug_implementations)]
#[repr(transparent)]
pub struct PgMetadataLookup {
conn: PgConnection,
}
Expand Down
4 changes: 2 additions & 2 deletions diesel/src/pg/types/numeric.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ mod bigdecimal {

#[cfg(feature = "unstable")]
impl<'a> TryFrom<&'a PgNumeric> for BigDecimal {
type Error = Box<Error + Send + Sync>;
type Error = Box<dyn Error + Send + Sync>;

fn try_from(numeric: &'a PgNumeric) -> deserialize::Result<Self> {
pg_decimal_to_bigdecimal(numeric)
Expand All @@ -79,7 +79,7 @@ mod bigdecimal {

#[cfg(feature = "unstable")]
impl TryFrom<PgNumeric> for BigDecimal {
type Error = Box<Error + Send + Sync>;
type Error = Box<dyn Error + Send + Sync>;

fn try_from(numeric: PgNumeric) -> deserialize::Result<Self> {
(&numeric).try_into()
Expand Down
2 changes: 1 addition & 1 deletion diesel/src/query_builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ use result::QueryResult;
#[doc(hidden)]
pub type Binds = Vec<Option<Vec<u8>>>;
/// A specialized Result type used with the query builder.
pub type BuildQueryResult = Result<(), Box<Error + Send + Sync>>;
pub type BuildQueryResult = Result<(), Box<dyn Error + Send + Sync>>;

/// Constructs a SQL query from a Diesel AST.
///
Expand Down
8 changes: 4 additions & 4 deletions diesel/src/query_builder/order_clause.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
simple_clause!(NoOrderClause, OrderClause, " ORDER BY ");

impl<'a, DB, Expr> Into<Option<Box<QueryFragment<DB> + 'a>>> for OrderClause<Expr>
impl<'a, DB, Expr> Into<Option<Box<dyn QueryFragment<DB> + 'a>>> for OrderClause<Expr>
where
DB: Backend,
Expr: QueryFragment<DB> + 'a,
{
fn into(self) -> Option<Box<QueryFragment<DB> + 'a>> {
fn into(self) -> Option<Box<dyn QueryFragment<DB> + 'a>> {
Some(Box::new(self.0))
}
}

impl<'a, DB> Into<Option<Box<QueryFragment<DB> + 'a>>> for NoOrderClause
impl<'a, DB> Into<Option<Box<dyn QueryFragment<DB> + 'a>>> for NoOrderClause
where
DB: Backend,
{
fn into(self) -> Option<Box<QueryFragment<DB> + 'a>> {
fn into(self) -> Option<Box<dyn QueryFragment<DB> + 'a>> {
None
}
}
2 changes: 1 addition & 1 deletion diesel/src/query_builder/query_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl<'a, T: QueryId + ?Sized> QueryId for &'a T {
const HAS_STATIC_QUERY_ID: bool = T::HAS_STATIC_QUERY_ID;
}

impl<DB> QueryId for QueryFragment<DB> {
impl<DB> QueryId for dyn QueryFragment<DB> {
type QueryId = ();

const HAS_STATIC_QUERY_ID: bool = false;
Expand Down
24 changes: 12 additions & 12 deletions diesel/src/query_builder/select_statement/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,28 @@ use sql_types::{BigInt, Bool, NotNull, Nullable};

#[allow(missing_debug_implementations)]
pub struct BoxedSelectStatement<'a, ST, QS, DB> {
select: Box<QueryFragment<DB> + 'a>,
select: Box<dyn QueryFragment<DB> + 'a>,
from: QS,
distinct: Box<QueryFragment<DB> + 'a>,
distinct: Box<dyn QueryFragment<DB> + 'a>,
where_clause: BoxedWhereClause<'a, DB>,
order: Option<Box<QueryFragment<DB> + 'a>>,
limit: Box<QueryFragment<DB> + 'a>,
offset: Box<QueryFragment<DB> + 'a>,
group_by: Box<QueryFragment<DB> + 'a>,
order: Option<Box<dyn QueryFragment<DB> + 'a>>,
limit: Box<dyn QueryFragment<DB> + 'a>,
offset: Box<dyn QueryFragment<DB> + 'a>,
group_by: Box<dyn QueryFragment<DB> + 'a>,
_marker: PhantomData<ST>,
}

impl<'a, ST, QS, DB> BoxedSelectStatement<'a, ST, QS, DB> {
#[allow(clippy::too_many_arguments)]
pub fn new(
select: Box<QueryFragment<DB> + 'a>,
select: Box<dyn QueryFragment<DB> + 'a>,
from: QS,
distinct: Box<QueryFragment<DB> + 'a>,
distinct: Box<dyn QueryFragment<DB> + 'a>,
where_clause: BoxedWhereClause<'a, DB>,
order: Option<Box<QueryFragment<DB> + 'a>>,
limit: Box<QueryFragment<DB> + 'a>,
offset: Box<QueryFragment<DB> + 'a>,
group_by: Box<QueryFragment<DB> + 'a>,
order: Option<Box<dyn QueryFragment<DB> + 'a>>,
limit: Box<dyn QueryFragment<DB> + 'a>,
offset: Box<dyn QueryFragment<DB> + 'a>,
group_by: Box<dyn QueryFragment<DB> + 'a>,
) -> Self {
BoxedSelectStatement {
select: select,
Expand Down
4 changes: 2 additions & 2 deletions diesel/src/query_builder/select_statement/dsl_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ where
S: QueryFragment<DB> + SelectableExpression<F> + 'a,
D: QueryFragment<DB> + 'a,
W: Into<BoxedWhereClause<'a, DB>>,
O: Into<Option<Box<QueryFragment<DB> + 'a>>>,
O: Into<Option<Box<dyn QueryFragment<DB> + 'a>>>,
L: QueryFragment<DB> + 'a,
Of: QueryFragment<DB> + 'a,
G: QueryFragment<DB> + 'a,
Expand Down Expand Up @@ -377,7 +377,7 @@ where
F::DefaultSelection: QueryFragment<DB> + 'a,
D: QueryFragment<DB> + 'a,
W: Into<BoxedWhereClause<'a, DB>>,
O: Into<Option<Box<QueryFragment<DB> + 'a>>>,
O: Into<Option<Box<dyn QueryFragment<DB> + 'a>>>,
L: QueryFragment<DB> + 'a,
Of: QueryFragment<DB> + 'a,
G: QueryFragment<DB> + 'a,
Expand Down
3 changes: 1 addition & 2 deletions diesel/src/query_builder/where_clause.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ impl<QS, Expr> ValidWhereClause<QS> for WhereClause<Expr> where Expr: AppearsOnT

#[allow(missing_debug_implementations)] // We can't...
pub enum BoxedWhereClause<'a, DB> {
Where(Box<QueryFragment<DB> + 'a>),
Where(Box<dyn QueryFragment<DB> + 'a>),
None,
}

Expand Down Expand Up @@ -159,7 +159,6 @@ where

fn and(self, predicate: Predicate) -> Self::Output {
use self::BoxedWhereClause::Where;
use expression::operators::And;

match self {
Where(where_clause) => Where(Box::new(And::new(where_clause, predicate))),
Expand Down
14 changes: 7 additions & 7 deletions diesel/src/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub enum Error {
/// violation.
DatabaseError(
DatabaseErrorKind,
Box<DatabaseErrorInformation + Send + Sync>,
Box<dyn DatabaseErrorInformation + Send + Sync>,
),

/// No rows were returned by a query expected to return at least one row.
Expand All @@ -45,21 +45,21 @@ pub enum Error {
/// An example of when this error could occur is if you are attempting to
/// construct an update statement with no changes (e.g. all fields on the
/// struct are `None`).
QueryBuilderError(Box<StdError + Send + Sync>),
QueryBuilderError(Box<dyn StdError + Send + Sync>),

/// An error occurred deserializing the data being sent to the database.
///
/// Typically this error means that the stated type of the query is
/// incorrect. An example of when this error might occur in normal usage is
/// attempting to deserialize an infinite date into chrono.
DeserializationError(Box<StdError + Send + Sync>),
DeserializationError(Box<dyn StdError + Send + Sync>),

/// An error occurred serializing the data being sent to the database.
///
/// An example of when this error would be returned is if you attempted to
/// serialize a `chrono::NaiveDate` earlier than the earliest date supported
/// by PostgreSQL.
SerializationError(Box<StdError + Send + Sync>),
SerializationError(Box<dyn StdError + Send + Sync>),

/// Roll back the current transaction.
///
Expand Down Expand Up @@ -147,7 +147,7 @@ pub trait DatabaseErrorInformation {
fn constraint_name(&self) -> Option<&str>;
}

impl fmt::Debug for DatabaseErrorInformation + Send + Sync {
impl fmt::Debug for dyn DatabaseErrorInformation + Send + Sync {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Debug::fmt(&self.message(), f)
}
Expand Down Expand Up @@ -290,7 +290,7 @@ impl StdError for Error {
}
}

fn cause(&self) -> Option<&StdError> {
fn cause(&self) -> Option<&dyn StdError> {
match *self {
Error::InvalidCString(ref e) => Some(e),
Error::QueryBuilderError(ref e) => Some(&**e),
Expand Down Expand Up @@ -324,7 +324,7 @@ impl StdError for ConnectionError {
}
}

fn cause(&self) -> Option<&StdError> {
fn cause(&self) -> Option<&dyn StdError> {
match *self {
ConnectionError::InvalidCString(ref e) => Some(e),
ConnectionError::CouldntSetupConfiguration(ref e) => Some(e),
Expand Down
2 changes: 1 addition & 1 deletion diesel/src/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub use pg::serialize::*;

/// A specialized result type representing the result of serializing
/// a value for the database.
pub type Result = result::Result<IsNull, Box<Error + Send + Sync>>;
pub type Result = result::Result<IsNull, Box<dyn Error + Send + Sync>>;

#[derive(Debug, Copy, Clone, PartialEq, Eq)]
/// Tiny enum to make the return type of `ToSql` more descriptive
Expand Down
8 changes: 4 additions & 4 deletions diesel/src/type_impls/floats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ impl<DB: Backend<RawValue = [u8]>> FromSql<sql_types::Float, DB> for f32 {
);
bytes
.read_f32::<DB::ByteOrder>()
.map_err(|e| Box::new(e) as Box<Error + Send + Sync>)
.map_err(|e| Box::new(e) as Box<dyn Error + Send + Sync>)
}
}

impl<DB: Backend> ToSql<sql_types::Float, DB> for f32 {
fn to_sql<W: Write>(&self, out: &mut Output<W, DB>) -> serialize::Result {
out.write_f32::<DB::ByteOrder>(*self)
.map(|_| IsNull::No)
.map_err(|e| Box::new(e) as Box<Error + Send + Sync>)
.map_err(|e| Box::new(e) as Box<dyn Error + Send + Sync>)
}
}

Expand All @@ -39,14 +39,14 @@ impl<DB: Backend<RawValue = [u8]>> FromSql<sql_types::Double, DB> for f64 {
);
bytes
.read_f64::<DB::ByteOrder>()
.map_err(|e| Box::new(e) as Box<Error + Send + Sync>)
.map_err(|e| Box::new(e) as Box<dyn Error + Send + Sync>)
}
}

impl<DB: Backend> ToSql<sql_types::Double, DB> for f64 {
fn to_sql<W: Write>(&self, out: &mut Output<W, DB>) -> serialize::Result {
out.write_f64::<DB::ByteOrder>(*self)
.map(|_| IsNull::No)
.map_err(|e| Box::new(e) as Box<Error + Send + Sync>)
.map_err(|e| Box::new(e) as Box<dyn Error + Send + Sync>)
}
}
Loading