Skip to content

Commit

Permalink
Merge pull request #2247 from diesel-rs/sg-main-crate-2018
Browse files Browse the repository at this point in the history
Migrate the main crate to the 2018 edition.
  • Loading branch information
sgrif authored Dec 18, 2019
2 parents 4cf14ae + 528acdb commit c106100
Show file tree
Hide file tree
Showing 162 changed files with 947 additions and 924 deletions.
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ for Rust libraries in [RFC #1105](https://github.com/rust-lang/rfcs/blob/master/
### Added

* `NonAggregate` can now be derived for simple cases.

* `Connection` and `SimpleConnection` traits are implemented for a broader range
of `r2d2::PooledConnection<M>` types when the `r2d2` feature is enabled.

Expand All @@ -18,14 +19,13 @@ for Rust libraries in [RFC #1105](https://github.com/rust-lang/rfcs/blob/master/
* All expression methods can now be called on expressions of nullable types.

* Added `BoxedSqlQuery`. This allows users to do a variable amount of `.sql` or

`.bind` calls without changing the underlying type.

* Added `.sql` to `SqlQuery` and `UncheckedBind` to allow appending SQL code to

an existing query.


* The `MacAddr` SQL type can now be used without enabling the `network-address`
feature.

### Removed

Expand Down
1 change: 1 addition & 0 deletions diesel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ homepage = "https://diesel.rs"
repository = "https://github.com/diesel-rs/diesel"
keywords = ["orm", "database", "blockchain", "sql"]
categories = ["database"]
edition = "2018"

[dependencies]
byteorder = "1.0"
Expand Down
10 changes: 5 additions & 5 deletions diesel/src/associations/belongs_to.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use super::{HasTable, Identifiable};
use dsl::{Eq, EqAny, Filter, FindBy};
use expression::array_comparison::AsInExpression;
use expression::AsExpression;
use prelude::*;
use query_dsl::methods::FilterDsl;
use crate::dsl::{Eq, EqAny, Filter, FindBy};
use crate::expression::array_comparison::AsInExpression;
use crate::expression::AsExpression;
use crate::prelude::*;
use crate::query_dsl::methods::FilterDsl;

use std::borrow::Borrow;
use std::hash::Hash;
Expand Down
10 changes: 5 additions & 5 deletions diesel/src/associations/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
//! #
//! # fn run_test() -> QueryResult<()> {
//! # let connection = establish_connection();
//! # use users::dsl::*;
//! # use self::users::dsl::*;
//! let user = users.find(2).get_result::<User>(&connection)?;
//! let users_post = Post::belonging_to(&user)
//! .first(&connection)?;
Expand Down Expand Up @@ -118,7 +118,7 @@
//! # }
//! #
//! # fn main() {
//! # use users::dsl::*;
//! # use self::users::dsl::*;
//! # let connection = establish_connection();
//! #
//! let user = users.find(1).first::<User>(&connection).expect("Error loading user");
Expand Down Expand Up @@ -178,8 +178,8 @@
//! #
//! # fn run_test() -> QueryResult<()> {
//! # let connection = establish_connection();
//! # use users::dsl::*;
//! # use posts::dsl::{posts, title};
//! # use self::users::dsl::*;
//! # use self::posts::dsl::{posts, title};
//! let sean = users.filter(name.eq("Sean")).first::<User>(&connection)?;
//! let tess = users.filter(name.eq("Tess")).first::<User>(&connection)?;
//!
Expand Down Expand Up @@ -357,7 +357,7 @@ mod belongs_to;

use std::hash::Hash;

use query_source::Table;
use crate::query_source::Table;

pub use self::belongs_to::{BelongsTo, GroupedBy};

Expand Down
6 changes: 3 additions & 3 deletions diesel/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

use byteorder::ByteOrder;

use query_builder::bind_collector::BindCollector;
use query_builder::QueryBuilder;
use sql_types::{self, HasSqlType};
use crate::query_builder::bind_collector::BindCollector;
use crate::query_builder::QueryBuilder;
use crate::sql_types::{self, HasSqlType};

/// A database backend
///
Expand Down
10 changes: 5 additions & 5 deletions diesel/src/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ mod transaction_manager;

use std::fmt::Debug;

use backend::Backend;
use deserialize::{Queryable, QueryableByName};
use query_builder::{AsQuery, QueryFragment, QueryId};
use result::*;
use sql_types::HasSqlType;
use crate::backend::Backend;
use crate::deserialize::{Queryable, QueryableByName};
use crate::query_builder::{AsQuery, QueryFragment, QueryId};
use crate::result::*;
use crate::sql_types::HasSqlType;

#[doc(hidden)]
pub use self::statement_cache::{MaybeCached, StatementCache, StatementCacheKey};
Expand Down
6 changes: 3 additions & 3 deletions diesel/src/connection/statement_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ use std::collections::HashMap;
use std::hash::Hash;
use std::ops::{Deref, DerefMut};

use backend::Backend;
use query_builder::*;
use result::QueryResult;
use crate::backend::Backend;
use crate::query_builder::*;
use crate::result::QueryResult;

#[doc(hidden)]
#[allow(missing_debug_implementations)]
Expand Down
8 changes: 4 additions & 4 deletions diesel/src/connection/transaction_manager.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use backend::UsesAnsiSavepointSyntax;
use connection::{Connection, SimpleConnection};
use result::QueryResult;
use crate::backend::UsesAnsiSavepointSyntax;
use crate::connection::{Connection, SimpleConnection};
use crate::result::QueryResult;

/// Manages the internal transaction state for a connection.
///
Expand Down Expand Up @@ -68,7 +68,7 @@ impl AnsiTransactionManager {
where
Conn: SimpleConnection,
{
use result::Error::AlreadyInTransaction;
use crate::result::Error::AlreadyInTransaction;

if self.transaction_depth.get() == 0 {
self.change_transaction_depth(1, conn.batch_execute(sql))
Expand Down
2 changes: 1 addition & 1 deletion diesel/src/data_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
//! all backend specific data structures when compiled against that
//! backend.
#[cfg(feature = "postgres")]
pub use pg::data_types::*;
pub use crate::pg::data_types::*;
4 changes: 2 additions & 2 deletions diesel/src/deserialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
use std::error::Error;
use std::result;

use backend::{self, Backend};
use row::{NamedRow, Row};
use crate::backend::{self, Backend};
use crate::row::{NamedRow, Row};

/// A specialized result type representing the result of deserializing
/// a value from the database.
Expand Down
14 changes: 7 additions & 7 deletions diesel/src/expression/array_comparison.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use backend::Backend;
use expression::subselect::Subselect;
use expression::*;
use query_builder::*;
use result::QueryResult;
use sql_types::Bool;
use crate::backend::Backend;
use crate::expression::subselect::Subselect;
use crate::expression::*;
use crate::query_builder::*;
use crate::result::QueryResult;
use crate::sql_types::Bool;

#[derive(Debug, Copy, Clone, QueryId, NonAggregate)]
pub struct In<T, U> {
Expand Down Expand Up @@ -92,7 +92,7 @@ where
impl_selectable_expression!(In<T, U>);
impl_selectable_expression!(NotIn<T, U>);

use query_builder::{BoxedSelectStatement, SelectStatement};
use crate::query_builder::{BoxedSelectStatement, SelectStatement};

pub trait AsInExpression<T> {
type InExpression: MaybeEmpty + Expression<SqlType = T>;
Expand Down
10 changes: 5 additions & 5 deletions diesel/src/expression/bound.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use std::marker::PhantomData;

use super::*;
use backend::Backend;
use query_builder::*;
use result::QueryResult;
use serialize::ToSql;
use sql_types::HasSqlType;
use crate::backend::Backend;
use crate::query_builder::*;
use crate::result::QueryResult;
use crate::serialize::ToSql;
use crate::sql_types::HasSqlType;

#[derive(Debug, Clone, Copy, DieselNumericOps)]
pub struct Bound<T, U> {
Expand Down
8 changes: 4 additions & 4 deletions diesel/src/expression/coerce.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use std::marker::PhantomData;

use backend::Backend;
use expression::*;
use query_builder::*;
use result::QueryResult;
use crate::backend::Backend;
use crate::expression::*;
use crate::query_builder::*;
use crate::result::QueryResult;

#[derive(Debug, Copy, Clone, QueryId, DieselNumericOps)]
#[doc(hidden)]
Expand Down
8 changes: 4 additions & 4 deletions diesel/src/expression/count.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use super::Expression;
use backend::Backend;
use query_builder::*;
use result::QueryResult;
use sql_types::BigInt;
use crate::backend::Backend;
use crate::query_builder::*;
use crate::result::QueryResult;
use crate::sql_types::BigInt;

sql_function! {
/// Creates a SQL `COUNT` expression
Expand Down
12 changes: 6 additions & 6 deletions diesel/src/expression/exists.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use backend::Backend;
use expression::subselect::Subselect;
use expression::{AppearsOnTable, Expression, NonAggregate, SelectableExpression};
use query_builder::*;
use result::QueryResult;
use sql_types::Bool;
use crate::backend::Backend;
use crate::expression::subselect::Subselect;
use crate::expression::{AppearsOnTable, Expression, NonAggregate, SelectableExpression};
use crate::query_builder::*;
use crate::result::QueryResult;
use crate::sql_types::Bool;

/// Creates a SQL `EXISTS` expression.
///
Expand Down
4 changes: 2 additions & 2 deletions diesel/src/expression/functions/aggregate_folding.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use sql_types::Foldable;
use crate::sql_types::Foldable;

sql_function! {
/// Represents a SQL `SUM` function. This function can only take types which are
Expand Down Expand Up @@ -47,7 +47,7 @@ sql_function! {
/// # #[cfg(all(feature = "numeric", any(feature = "postgres", not(feature = "sqlite"))))]
/// # fn run_test() -> QueryResult<()> {
/// # use bigdecimal::BigDecimal;
/// # use numbers::dsl::*;
/// # use self::numbers::dsl::*;
/// # let conn = establish_connection();
/// # conn.execute("DROP TABLE IF EXISTS numbers")?;
/// # conn.execute("CREATE TABLE numbers (number INTEGER)")?;
Expand Down
2 changes: 1 addition & 1 deletion diesel/src/expression/functions/aggregate_ordering.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use sql_types::{IntoNullable, SqlOrd};
use crate::sql_types::{IntoNullable, SqlOrd};

sql_function! {
/// Represents a SQL `MAX` function. This function can only take types which are
Expand Down
12 changes: 6 additions & 6 deletions diesel/src/expression/functions/date_and_time.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use backend::Backend;
use expression::coerce::Coerce;
use expression::{AsExpression, Expression};
use query_builder::*;
use result::QueryResult;
use sql_types::*;
use crate::backend::Backend;
use crate::expression::coerce::Coerce;
use crate::expression::{AsExpression, Expression};
use crate::query_builder::*;
use crate::result::QueryResult;
use crate::sql_types::*;

/// Represents the SQL `CURRENT_TIMESTAMP` constant. This is equivalent to the
/// `NOW()` function on backends that support it.
Expand Down
8 changes: 4 additions & 4 deletions diesel/src/expression/functions/helper_types.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#![allow(non_camel_case_types)]

use dsl::{AsExprOf, SqlTypeOf};
use expression::grouped::Grouped;
use expression::operators;
use sql_types::Bool;
use crate::dsl::{AsExprOf, SqlTypeOf};
use crate::expression::grouped::Grouped;
use crate::expression::operators;
use crate::sql_types::Bool;

/// The return type of [`not(expr)`](../dsl/fn.not.html)
pub type not<Expr> = operators::Not<Grouped<AsExprOf<Expr, Bool>>>;
Expand Down
8 changes: 4 additions & 4 deletions diesel/src/expression/grouped.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use backend::Backend;
use expression::Expression;
use query_builder::*;
use result::QueryResult;
use crate::backend::Backend;
use crate::expression::Expression;
use crate::query_builder::*;
use crate::result::QueryResult;

#[derive(Debug, Copy, Clone, QueryId, Default, DieselNumericOps, NonAggregate)]
pub struct Grouped<T>(pub T);
Expand Down
2 changes: 1 addition & 1 deletion diesel/src/expression/helper_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use super::array_comparison::{AsInExpression, In, NotIn};
use super::grouped::Grouped;
use super::{AsExpression, Expression};
use sql_types;
use crate::sql_types;

/// The SQL type of an expression
pub type SqlTypeOf<Expr> = <Expr as Expression>::SqlType;
Expand Down
10 changes: 5 additions & 5 deletions diesel/src/expression/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub mod subselect;
#[doc(hidden)]
#[allow(non_camel_case_types)]
pub mod dsl {
use dsl::SqlTypeOf;
use crate::dsl::SqlTypeOf;

#[doc(inline)]
pub use super::count::*;
Expand All @@ -67,7 +67,7 @@ pub mod dsl {
pub use super::sql_literal::sql;

#[cfg(feature = "postgres")]
pub use pg::expression::dsl::*;
pub use crate::pg::expression::dsl::*;

/// The return type of [`count(expr)`](../dsl/fn.count.html)
pub type count<Expr> = super::count::count::HelperType<SqlTypeOf<Expr>, Expr>;
Expand All @@ -82,8 +82,8 @@ pub mod dsl {
#[doc(inline)]
pub use self::sql_literal::{SqlLiteral, UncheckedBind};

use backend::Backend;
use dsl::AsExprOf;
use crate::backend::Backend;
use crate::dsl::AsExprOf;

/// Represents a typed fragment of SQL.
///
Expand Down Expand Up @@ -291,7 +291,7 @@ impl<T: NonAggregate + ?Sized> NonAggregate for Box<T> {}

impl<'a, T: NonAggregate + ?Sized> NonAggregate for &'a T {}

use query_builder::{QueryFragment, QueryId};
use crate::query_builder::{QueryFragment, QueryId};

/// Helper trait used when boxing expressions.
///
Expand Down
8 changes: 4 additions & 4 deletions diesel/src/expression/not.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use expression::grouped::Grouped;
use expression::AsExpression;
use helper_types::not;
use sql_types::Bool;
use crate::expression::grouped::Grouped;
use crate::expression::AsExpression;
use crate::helper_types::not;
use crate::sql_types::Bool;

/// Creates a SQL `NOT` expression
///
Expand Down
12 changes: 6 additions & 6 deletions diesel/src/expression/nullable.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use backend::Backend;
use expression::*;
use query_builder::*;
use query_source::Table;
use result::QueryResult;
use sql_types::IntoNullable;
use crate::backend::Backend;
use crate::expression::*;
use crate::query_builder::*;
use crate::query_source::Table;
use crate::result::QueryResult;
use crate::sql_types::IntoNullable;

#[derive(Debug, Copy, Clone, DieselNumericOps, NonAggregate)]
pub struct Nullable<T>(T);
Expand Down
Loading

0 comments on commit c106100

Please sign in to comment.