diff --git a/diesel/Cargo.toml b/diesel/Cargo.toml index 52e685379055..c4203c4b39c5 100644 --- a/diesel/Cargo.toml +++ b/diesel/Cargo.toml @@ -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 } @@ -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 } diff --git a/diesel/src/deserialize.rs b/diesel/src/deserialize.rs index 2aaf589cad4c..24f2cc9f1a4e 100644 --- a/diesel/src/deserialize.rs +++ b/diesel/src/deserialize.rs @@ -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 = result::Result>; +pub type Result = result::Result>; /// Trait indicating that a record can be queried from the database. /// diff --git a/diesel/src/expression/functions/date_and_time.rs b/diesel/src/expression/functions/date_and_time.rs index 077aea1a51c4..a0d68f41cb25 100644 --- a/diesel/src/expression/functions/date_and_time.rs +++ b/diesel/src/expression/functions/date_and_time.rs @@ -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() { diff --git a/diesel/src/expression/mod.rs b/diesel/src/expression/mod.rs index e76e40fba014..b6eba49d25f7 100644 --- a/diesel/src/expression/mod.rs +++ b/diesel/src/expression/mod.rs @@ -348,7 +348,7 @@ where { } -impl<'a, QS, ST, DB> QueryId for BoxableExpression + 'a { +impl<'a, QS, ST, DB> QueryId for dyn BoxableExpression + 'a { type QueryId = (); const HAS_STATIC_QUERY_ID: bool = false; diff --git a/diesel/src/migration/mod.rs b/diesel/src/migration/mod.rs index af117498aa2a..e78cfa2a51a5 100644 --- a/diesel/src/migration/mod.rs +++ b/diesel/src/migration/mod.rs @@ -11,25 +11,25 @@ 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 { +impl Migration for Box { 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> { @@ -37,16 +37,16 @@ impl Migration for Box { } } -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> { diff --git a/diesel/src/mysql/connection/raw.rs b/diesel/src/mysql/connection/raw.rs index c2072436019a..ab832a221454 100644 --- a/diesel/src/mysql/connection/raw.rs +++ b/diesel/src/mysql/connection/raw.rs @@ -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; @@ -195,7 +195,7 @@ impl Drop for RawConnection { /// > any other client library call. /// /// -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(|| { diff --git a/diesel/src/pg/connection/cursor.rs b/diesel/src/pg/connection/cursor.rs index 0e951beda814..be7b354e9481 100644 --- a/diesel/src/pg/connection/cursor.rs +++ b/diesel/src/pg/connection/cursor.rs @@ -59,8 +59,6 @@ impl NamedCursor { where T: QueryableByName, { - use result::Error::DeserializationError; - (0..self.db_result.num_rows()) .map(|i| { let row = PgNamedRow::new(&self, i); diff --git a/diesel/src/pg/metadata_lookup.rs b/diesel/src/pg/metadata_lookup.rs index 350f73c0643b..f4ed3fc2503f 100644 --- a/diesel/src/pg/metadata_lookup.rs +++ b/diesel/src/pg/metadata_lookup.rs @@ -3,6 +3,7 @@ use prelude::*; /// Determines the OID of types at runtime #[allow(missing_debug_implementations)] +#[repr(transparent)] pub struct PgMetadataLookup { conn: PgConnection, } diff --git a/diesel/src/pg/types/numeric.rs b/diesel/src/pg/types/numeric.rs index 3d260e025170..f34c418bc225 100644 --- a/diesel/src/pg/types/numeric.rs +++ b/diesel/src/pg/types/numeric.rs @@ -70,7 +70,7 @@ mod bigdecimal { #[cfg(feature = "unstable")] impl<'a> TryFrom<&'a PgNumeric> for BigDecimal { - type Error = Box; + type Error = Box; fn try_from(numeric: &'a PgNumeric) -> deserialize::Result { pg_decimal_to_bigdecimal(numeric) @@ -79,7 +79,7 @@ mod bigdecimal { #[cfg(feature = "unstable")] impl TryFrom for BigDecimal { - type Error = Box; + type Error = Box; fn try_from(numeric: PgNumeric) -> deserialize::Result { (&numeric).try_into() diff --git a/diesel/src/query_builder/mod.rs b/diesel/src/query_builder/mod.rs index e7690249cbd4..6a1fbb124f44 100644 --- a/diesel/src/query_builder/mod.rs +++ b/diesel/src/query_builder/mod.rs @@ -61,7 +61,7 @@ use result::QueryResult; #[doc(hidden)] pub type Binds = Vec>>; /// A specialized Result type used with the query builder. -pub type BuildQueryResult = Result<(), Box>; +pub type BuildQueryResult = Result<(), Box>; /// Constructs a SQL query from a Diesel AST. /// diff --git a/diesel/src/query_builder/order_clause.rs b/diesel/src/query_builder/order_clause.rs index 8d8674045f54..a6b298096f77 100644 --- a/diesel/src/query_builder/order_clause.rs +++ b/diesel/src/query_builder/order_clause.rs @@ -1,20 +1,20 @@ simple_clause!(NoOrderClause, OrderClause, " ORDER BY "); -impl<'a, DB, Expr> Into + 'a>>> for OrderClause +impl<'a, DB, Expr> Into + 'a>>> for OrderClause where DB: Backend, Expr: QueryFragment + 'a, { - fn into(self) -> Option + 'a>> { + fn into(self) -> Option + 'a>> { Some(Box::new(self.0)) } } -impl<'a, DB> Into + 'a>>> for NoOrderClause +impl<'a, DB> Into + 'a>>> for NoOrderClause where DB: Backend, { - fn into(self) -> Option + 'a>> { + fn into(self) -> Option + 'a>> { None } } diff --git a/diesel/src/query_builder/query_id.rs b/diesel/src/query_builder/query_id.rs index df23d40e84e8..aa7c761ed47e 100644 --- a/diesel/src/query_builder/query_id.rs +++ b/diesel/src/query_builder/query_id.rs @@ -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 QueryId for QueryFragment { +impl QueryId for dyn QueryFragment { type QueryId = (); const HAS_STATIC_QUERY_ID: bool = false; diff --git a/diesel/src/query_builder/select_statement/boxed.rs b/diesel/src/query_builder/select_statement/boxed.rs index 8f3415f60868..58cd5bd973ee 100644 --- a/diesel/src/query_builder/select_statement/boxed.rs +++ b/diesel/src/query_builder/select_statement/boxed.rs @@ -22,28 +22,28 @@ use sql_types::{BigInt, Bool, NotNull, Nullable}; #[allow(missing_debug_implementations)] pub struct BoxedSelectStatement<'a, ST, QS, DB> { - select: Box + 'a>, + select: Box + 'a>, from: QS, - distinct: Box + 'a>, + distinct: Box + 'a>, where_clause: BoxedWhereClause<'a, DB>, - order: Option + 'a>>, - limit: Box + 'a>, - offset: Box + 'a>, - group_by: Box + 'a>, + order: Option + 'a>>, + limit: Box + 'a>, + offset: Box + 'a>, + group_by: Box + 'a>, _marker: PhantomData, } impl<'a, ST, QS, DB> BoxedSelectStatement<'a, ST, QS, DB> { #[allow(clippy::too_many_arguments)] pub fn new( - select: Box + 'a>, + select: Box + 'a>, from: QS, - distinct: Box + 'a>, + distinct: Box + 'a>, where_clause: BoxedWhereClause<'a, DB>, - order: Option + 'a>>, - limit: Box + 'a>, - offset: Box + 'a>, - group_by: Box + 'a>, + order: Option + 'a>>, + limit: Box + 'a>, + offset: Box + 'a>, + group_by: Box + 'a>, ) -> Self { BoxedSelectStatement { select: select, diff --git a/diesel/src/query_builder/select_statement/dsl_impls.rs b/diesel/src/query_builder/select_statement/dsl_impls.rs index 4d0d23cb86c6..2c14ea0f9745 100644 --- a/diesel/src/query_builder/select_statement/dsl_impls.rs +++ b/diesel/src/query_builder/select_statement/dsl_impls.rs @@ -347,7 +347,7 @@ where S: QueryFragment + SelectableExpression + 'a, D: QueryFragment + 'a, W: Into>, - O: Into + 'a>>>, + O: Into + 'a>>>, L: QueryFragment + 'a, Of: QueryFragment + 'a, G: QueryFragment + 'a, @@ -377,7 +377,7 @@ where F::DefaultSelection: QueryFragment + 'a, D: QueryFragment + 'a, W: Into>, - O: Into + 'a>>>, + O: Into + 'a>>>, L: QueryFragment + 'a, Of: QueryFragment + 'a, G: QueryFragment + 'a, diff --git a/diesel/src/query_builder/where_clause.rs b/diesel/src/query_builder/where_clause.rs index 493070fc73b1..0f89c90f330e 100644 --- a/diesel/src/query_builder/where_clause.rs +++ b/diesel/src/query_builder/where_clause.rs @@ -125,7 +125,7 @@ impl ValidWhereClause for WhereClause where Expr: AppearsOnT #[allow(missing_debug_implementations)] // We can't... pub enum BoxedWhereClause<'a, DB> { - Where(Box + 'a>), + Where(Box + 'a>), None, } @@ -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))), diff --git a/diesel/src/result.rs b/diesel/src/result.rs index ce779b7d80ef..6d16ce7a33dc 100644 --- a/diesel/src/result.rs +++ b/diesel/src/result.rs @@ -25,7 +25,7 @@ pub enum Error { /// violation. DatabaseError( DatabaseErrorKind, - Box, + Box, ), /// No rows were returned by a query expected to return at least one row. @@ -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), + QueryBuilderError(Box), /// 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), + DeserializationError(Box), /// 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), + SerializationError(Box), /// Roll back the current transaction. /// @@ -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) } @@ -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), @@ -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), diff --git a/diesel/src/serialize.rs b/diesel/src/serialize.rs index e1574cb3dab0..6b71f79e120d 100644 --- a/diesel/src/serialize.rs +++ b/diesel/src/serialize.rs @@ -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>; +pub type Result = result::Result>; #[derive(Debug, Copy, Clone, PartialEq, Eq)] /// Tiny enum to make the return type of `ToSql` more descriptive diff --git a/diesel/src/type_impls/floats.rs b/diesel/src/type_impls/floats.rs index 19cd82455650..d37511626045 100644 --- a/diesel/src/type_impls/floats.rs +++ b/diesel/src/type_impls/floats.rs @@ -17,7 +17,7 @@ impl> FromSql for f32 { ); bytes .read_f32::() - .map_err(|e| Box::new(e) as Box) + .map_err(|e| Box::new(e) as Box) } } @@ -25,7 +25,7 @@ impl ToSql for f32 { fn to_sql(&self, out: &mut Output) -> serialize::Result { out.write_f32::(*self) .map(|_| IsNull::No) - .map_err(|e| Box::new(e) as Box) + .map_err(|e| Box::new(e) as Box) } } @@ -39,7 +39,7 @@ impl> FromSql for f64 { ); bytes .read_f64::() - .map_err(|e| Box::new(e) as Box) + .map_err(|e| Box::new(e) as Box) } } @@ -47,6 +47,6 @@ impl ToSql for f64 { fn to_sql(&self, out: &mut Output) -> serialize::Result { out.write_f64::(*self) .map(|_| IsNull::No) - .map_err(|e| Box::new(e) as Box) + .map_err(|e| Box::new(e) as Box) } } diff --git a/diesel/src/type_impls/integers.rs b/diesel/src/type_impls/integers.rs index b02b61360619..807bf8aba3a3 100644 --- a/diesel/src/type_impls/integers.rs +++ b/diesel/src/type_impls/integers.rs @@ -23,7 +23,7 @@ impl> FromSql for i16 { ); bytes .read_i16::() - .map_err(|e| Box::new(e) as Box) + .map_err(|e| Box::new(e) as Box) } } @@ -31,7 +31,7 @@ impl ToSql for i16 { fn to_sql(&self, out: &mut Output) -> serialize::Result { out.write_i16::(*self) .map(|_| IsNull::No) - .map_err(|e| Box::new(e) as Box) + .map_err(|e| Box::new(e) as Box) } } @@ -50,7 +50,7 @@ impl> FromSql for i32 { ); bytes .read_i32::() - .map_err(|e| Box::new(e) as Box) + .map_err(|e| Box::new(e) as Box) } } @@ -58,7 +58,7 @@ impl ToSql for i32 { fn to_sql(&self, out: &mut Output) -> serialize::Result { out.write_i32::(*self) .map(|_| IsNull::No) - .map_err(|e| Box::new(e) as Box) + .map_err(|e| Box::new(e) as Box) } } @@ -77,7 +77,7 @@ impl> FromSql for i64 { ); bytes .read_i64::() - .map_err(|e| Box::new(e) as Box) + .map_err(|e| Box::new(e) as Box) } } @@ -85,6 +85,6 @@ impl ToSql for i64 { fn to_sql(&self, out: &mut Output) -> serialize::Result { out.write_i64::(*self) .map(|_| IsNull::No) - .map_err(|e| Box::new(e) as Box) + .map_err(|e| Box::new(e) as Box) } } diff --git a/diesel/src/type_impls/primitives.rs b/diesel/src/type_impls/primitives.rs index 585c71c6f44b..1b868651f9ae 100644 --- a/diesel/src/type_impls/primitives.rs +++ b/diesel/src/type_impls/primitives.rs @@ -132,7 +132,7 @@ impl ToSql for str { fn to_sql(&self, out: &mut Output) -> serialize::Result { out.write_all(self.as_bytes()) .map(|_| IsNull::No) - .map_err(|e| Box::new(e) as Box) + .map_err(|e| Box::new(e) as Box) } } @@ -184,7 +184,7 @@ impl ToSql for [u8] { fn to_sql(&self, out: &mut Output) -> serialize::Result { out.write_all(self) .map(|_| IsNull::No) - .map_err(|e| Box::new(e) as Box) + .map_err(|e| Box::new(e) as Box) } } diff --git a/diesel/src/type_impls/tuples.rs b/diesel/src/type_impls/tuples.rs index 7718b7d29f0c..93c17d36190f 100644 --- a/diesel/src/type_impls/tuples.rs +++ b/diesel/src/type_impls/tuples.rs @@ -53,7 +53,7 @@ macro_rules! tuple_impls { { const FIELDS_NEEDED: usize = $($T::FIELDS_NEEDED +)+ 0; - fn build_from_row>(row: &mut RowT) -> Result> { + fn build_from_row>(row: &mut RowT) -> Result> { Ok(($($T::build_from_row(row)?,)+)) } } diff --git a/diesel_cli/Cargo.toml b/diesel_cli/Cargo.toml index ae3913c66ce4..85218045fc56 100644 --- a/diesel_cli/Cargo.toml +++ b/diesel_cli/Cargo.toml @@ -25,8 +25,8 @@ serde = { version = "1.0.0", features = ["derive"] } tempfile = "3.0.0" toml = "0.4.6" url = { version = "1.4.0", optional = true } -barrel = { version = "<= 0.2.0", optional = true, features = ["diesel-filled"] } -libsqlite3-sys = { version = ">=0.8.0, <0.13.0", optional = true, features = ["min_sqlite_version_3_7_16"] } +barrel = { version = ">= 0.5.0", optional = true, features = ["diesel"] } +libsqlite3-sys = { version = ">=0.8.0, <0.17.0", optional = true, features = ["min_sqlite_version_3_7_16"] } [dev-dependencies] difference = "1.0" diff --git a/diesel_cli/src/config.rs b/diesel_cli/src/config.rs index b3322de30632..7b659e5140eb 100644 --- a/diesel_cli/src/config.rs +++ b/diesel_cli/src/config.rs @@ -25,7 +25,7 @@ impl Config { .unwrap_or_else(|| find_project_root().unwrap_or_default().join("diesel.toml")) } - pub fn read(matches: &ArgMatches) -> Result> { + pub fn read(matches: &ArgMatches) -> Result> { let path = Self::file_path(matches); if path.exists() { diff --git a/diesel_cli/src/database.rs b/diesel_cli/src/database.rs index 5686db65ae70..02bba790b54f 100644 --- a/diesel_cli/src/database.rs +++ b/diesel_cli/src/database.rs @@ -234,12 +234,9 @@ fn drop_database(database_url: &str) -> DatabaseResult<()> { } #[cfg(feature = "sqlite")] Backend::Sqlite => { - use std::fs; - use std::path::Path; - if Path::new(database_url).exists() { println!("Dropping database: {}", database_url); - fs::remove_file(&database_url)?; + std::fs::remove_file(&database_url)?; } } #[cfg(feature = "mysql")] diff --git a/diesel_cli/src/infer_schema_internals/inference.rs b/diesel_cli/src/infer_schema_internals/inference.rs index b1ce38d41476..0a0fd35bbd11 100644 --- a/diesel_cli/src/infer_schema_internals/inference.rs +++ b/diesel_cli/src/infer_schema_internals/inference.rs @@ -17,7 +17,7 @@ static RESERVED_NAMES: &[&str] = &[ pub fn load_table_names( database_url: &str, schema_name: Option<&str>, -) -> Result, Box> { +) -> Result, Box> { let connection = InferConnection::establish(database_url)?; match connection { @@ -33,7 +33,7 @@ pub fn load_table_names( fn get_column_information( conn: &InferConnection, table: &TableName, -) -> Result, Box> { +) -> Result, Box> { let column_info = match *conn { #[cfg(feature = "sqlite")] InferConnection::Sqlite(ref c) => super::sqlite::get_table_data(c, table), @@ -52,7 +52,7 @@ fn get_column_information( fn determine_column_type( attr: &ColumnInformation, conn: &InferConnection, -) -> Result> { +) -> Result> { match *conn { #[cfg(feature = "sqlite")] InferConnection::Sqlite(_) => super::sqlite::determine_column_type(attr), @@ -66,7 +66,7 @@ fn determine_column_type( pub(crate) fn get_primary_keys( conn: &InferConnection, table: &TableName, -) -> Result, Box> { +) -> Result, Box> { let primary_keys: Vec = match *conn { #[cfg(feature = "sqlite")] InferConnection::Sqlite(ref c) => super::sqlite::get_primary_keys(c, table), @@ -90,7 +90,7 @@ pub(crate) fn get_primary_keys( pub fn load_foreign_key_constraints( database_url: &str, schema_name: Option<&str>, -) -> Result, Box> { +) -> Result, Box> { let connection = InferConnection::establish(database_url)?; let constraints = match connection { @@ -123,7 +123,7 @@ macro_rules! doc_comment { }; } -pub fn load_table_data(database_url: &str, name: TableName) -> Result> { +pub fn load_table_data(database_url: &str, name: TableName) -> Result> { let connection = InferConnection::establish(database_url)?; let docs = doc_comment!( "Representation of the `{}` table. @@ -169,7 +169,7 @@ pub fn load_table_data(database_url: &str, name: TableName) -> Result>>()?; + .collect::>>()?; Ok(TableData { name, diff --git a/diesel_cli/src/infer_schema_internals/information_schema.rs b/diesel_cli/src/infer_schema_internals/information_schema.rs index 932fe5cdff8f..80abfa7b59e0 100644 --- a/diesel_cli/src/infer_schema_internals/information_schema.rs +++ b/diesel_cli/src/infer_schema_internals/information_schema.rs @@ -167,7 +167,7 @@ where pub fn load_table_names( connection: &Conn, schema_name: Option<&str>, -) -> Result, Box> +) -> Result, Box> where Conn: Connection, Conn::Backend: UsesInformationSchema, diff --git a/diesel_cli/src/infer_schema_internals/mysql.rs b/diesel_cli/src/infer_schema_internals/mysql.rs index e9afb693b0c4..384a7271ce4a 100644 --- a/diesel_cli/src/infer_schema_internals/mysql.rs +++ b/diesel_cli/src/infer_schema_internals/mysql.rs @@ -79,7 +79,7 @@ pub fn load_foreign_key_constraints( Ok(constraints) } -pub fn determine_column_type(attr: &ColumnInformation) -> Result> { +pub fn determine_column_type(attr: &ColumnInformation) -> Result> { let tpe = determine_type_name(&attr.type_name)?; let unsigned = determine_unsigned(&attr.type_name); @@ -91,7 +91,7 @@ pub fn determine_column_type(attr: &ColumnInformation) -> Result Result> { +fn determine_type_name(sql_type_name: &str) -> Result> { let result = if sql_type_name == "tinyint(1)" { "bool" } else if sql_type_name.starts_with("int") { diff --git a/diesel_cli/src/infer_schema_internals/pg.rs b/diesel_cli/src/infer_schema_internals/pg.rs index d1d95b8bdcd0..de268a653cae 100644 --- a/diesel_cli/src/infer_schema_internals/pg.rs +++ b/diesel_cli/src/infer_schema_internals/pg.rs @@ -3,7 +3,7 @@ use std::io::{stderr, Write}; use super::data_structures::*; -pub fn determine_column_type(attr: &ColumnInformation) -> Result> { +pub fn determine_column_type(attr: &ColumnInformation) -> Result> { let is_array = attr.type_name.starts_with('_'); let tpe = if is_array { &attr.type_name[1..] diff --git a/diesel_cli/src/infer_schema_internals/sqlite.rs b/diesel_cli/src/infer_schema_internals/sqlite.rs index 426844e543b0..446f6e5da702 100644 --- a/diesel_cli/src/infer_schema_internals/sqlite.rs +++ b/diesel_cli/src/infer_schema_internals/sqlite.rs @@ -40,7 +40,7 @@ table! { pub fn load_table_names( connection: &SqliteConnection, schema_name: Option<&str>, -) -> Result, Box> { +) -> Result, Box> { use self::sqlite_master::dsl::*; if schema_name.is_some() { @@ -64,7 +64,7 @@ pub fn load_table_names( pub fn load_foreign_key_constraints( connection: &SqliteConnection, schema_name: Option<&str>, -) -> Result, Box> { +) -> Result, Box> { let tables = load_table_names(connection, schema_name)?; let rows = tables .into_iter() @@ -157,7 +157,7 @@ pub fn get_primary_keys(conn: &SqliteConnection, table: &TableName) -> QueryResu .collect()) } -pub fn determine_column_type(attr: &ColumnInformation) -> Result> { +pub fn determine_column_type(attr: &ColumnInformation) -> Result> { let type_name = attr.type_name.to_lowercase(); let path = if is_bool(&type_name) { String::from("Bool") diff --git a/diesel_cli/src/main.rs b/diesel_cli/src/main.rs index 741ca00360ac..dc8aec2927af 100644 --- a/diesel_cli/src/main.rs +++ b/diesel_cli/src/main.rs @@ -47,6 +47,7 @@ use clap::{ArgMatches, Shell}; use migrations_internals::{self as migrations, MigrationConnection}; use std::any::Any; use std::error::Error; +use std::fmt::Display; use std::io::stdout; use std::path::{Path, PathBuf}; use std::{env, fs}; @@ -74,7 +75,7 @@ fn main() { // https://github.com/rust-lang-nursery/rust-clippy/issues/2927#issuecomment-405705595 #[allow(clippy::similar_names)] -fn run_migration_command(matches: &ArgMatches) -> Result<(), Box> { +fn run_migration_command(matches: &ArgMatches) -> Result<(), Box> { match matches.subcommand() { ("run", Some(_)) => { let database_url = database::database_url(matches); @@ -170,11 +171,10 @@ fn generate_sql_migration(path: &PathBuf) { .unwrap(); } -use std::fmt::Display; -fn migration_version<'a>(matches: &'a ArgMatches) -> Box { +fn migration_version<'a>(matches: &'a ArgMatches) -> Box { matches .value_of("MIGRATION_VERSION") - .map(|s| Box::new(s) as Box) + .map(|s| Box::new(s) as Box) .unwrap_or_else(|| Box::new(Utc::now().format(TIMESTAMP_FORMAT))) } @@ -232,7 +232,7 @@ fn create_config_file(matches: &ArgMatches) -> DatabaseResult<()> { Ok(()) } -fn run_database_command(matches: &ArgMatches) -> Result<(), Box> { +fn run_database_command(matches: &ArgMatches) -> Result<(), Box> { match matches.subcommand() { ("setup", Some(args)) => { let migrations_dir = migrations_dir(args); @@ -314,12 +314,12 @@ where } #[cfg(feature = "mysql")] -fn should_redo_migration_in_transaction(t: &Any) -> bool { +fn should_redo_migration_in_transaction(t: &dyn Any) -> bool { !t.is::<::diesel::mysql::MysqlConnection>() } #[cfg(not(feature = "mysql"))] -fn should_redo_migration_in_transaction(_t: &Any) -> bool { +fn should_redo_migration_in_transaction(_t: &dyn Any) -> bool { true } @@ -345,7 +345,7 @@ fn convert_absolute_path_to_relative(target_path: &Path, mut current_path: &Path result.join(target_path.strip_prefix(current_path).unwrap()) } -fn run_infer_schema(matches: &ArgMatches) -> Result<(), Box> { +fn run_infer_schema(matches: &ArgMatches) -> Result<(), Box> { use infer_schema_internals::TableName; use print_schema::*; @@ -399,7 +399,7 @@ fn run_infer_schema(matches: &ArgMatches) -> Result<(), Box> { Ok(()) } -fn regenerate_schema_if_file_specified(matches: &ArgMatches) -> Result<(), Box> { +fn regenerate_schema_if_file_specified(matches: &ArgMatches) -> Result<(), Box> { use std::io::Read; let config = Config::read(matches)?; @@ -427,7 +427,7 @@ fn regenerate_schema_if_file_specified(matches: &ArgMatches) -> Result<(), Box( database_url: &str, config: &config::PrintSchema, output: &mut W, -) -> Result<(), Box> { +) -> Result<(), Box> { let tempfile = NamedTempFile::new()?; let file = tempfile.reopen()?; output_schema(database_url, config, file, tempfile.path())?; @@ -56,7 +56,7 @@ pub fn output_schema( config: &config::PrintSchema, mut out: File, out_path: &Path, -) -> Result<(), Box> { +) -> Result<(), Box> { let table_names = load_table_names(database_url, config.schema_name())? .into_iter() .filter(|t| !config.filter.should_ignore_table(t)) @@ -67,7 +67,7 @@ pub fn output_schema( let table_data = table_names .into_iter() .map(|t| load_table_data(database_url, t)) - .collect::>>()?; + .collect::>>()?; let definitions = TableDefinitions { tables: table_data, fk_constraints: foreign_keys, diff --git a/diesel_cli/tests/support/project_builder.rs b/diesel_cli/tests/support/project_builder.rs index 34a745f003f7..a494d1377dc5 100644 --- a/diesel_cli/tests/support/project_builder.rs +++ b/diesel_cli/tests/support/project_builder.rs @@ -161,7 +161,6 @@ impl Project { } pub fn create_migration_in_directory(&self, directory: &str, name: &str, up: &str, down: &str) { - use std::io::Write; let migration_path = self.directory.path().join(directory).join(name); fs::create_dir(&migration_path) .expect("Migrations folder must exist to create a migration"); diff --git a/diesel_compile_tests/tests/ui/as_changeset_bad_options.stderr b/diesel_compile_tests/tests/ui/as_changeset_bad_options.stderr index 48e6c0293532..8e400aae3bfd 100644 --- a/diesel_compile_tests/tests/ui/as_changeset_bad_options.stderr +++ b/diesel_compile_tests/tests/ui/as_changeset_bad_options.stderr @@ -2,7 +2,7 @@ error: `treat_none_as_null` must be in the form `treat_none_as_null = "true"` --> $DIR/as_changeset_bad_options.rs:13:21 | 13 | #[changeset_options(treat_none_as_null("true"))] - | ^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `treat_none_as_null` must be in the form `treat_none_as_null = "true"` --> $DIR/as_changeset_bad_options.rs:21:21 @@ -14,19 +14,19 @@ error: `treat_none_as_null` must be in the form `treat_none_as_null = "true"` --> $DIR/as_changeset_bad_options.rs:29:21 | 29 | #[changeset_options(treat_none_as_null = "foo")] - | ^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Missing required option `treat_none_as_null` --> $DIR/as_changeset_bad_options.rs:37:3 | 37 | #[changeset_options()] - | ^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^ error: `changeset_options` must be in the form `changeset_options(...)` --> $DIR/as_changeset_bad_options.rs:45:3 | 45 | #[changeset_options = "treat_none_as_null"] - | ^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `changeset_options` must be in the form `changeset_options(...)` --> $DIR/as_changeset_bad_options.rs:53:3 diff --git a/diesel_compile_tests/tests/ui/as_changeset_bad_primary_key_syntax.stderr b/diesel_compile_tests/tests/ui/as_changeset_bad_primary_key_syntax.stderr index ace74baa0630..e42c9d8d69c8 100644 --- a/diesel_compile_tests/tests/ui/as_changeset_bad_primary_key_syntax.stderr +++ b/diesel_compile_tests/tests/ui/as_changeset_bad_primary_key_syntax.stderr @@ -2,13 +2,13 @@ error: Expected `bar` found `bar = "baz"` --> $DIR/as_changeset_bad_primary_key_syntax.rs:12:19 | 12 | #[primary_key(id, bar = "baz", qux(id))] - | ^^^ + | ^^^^^^^^^^^ error: Expected `qux` found `qux ( id )` --> $DIR/as_changeset_bad_primary_key_syntax.rs:12:32 | 12 | #[primary_key(id, bar = "baz", qux(id))] - | ^^^ + | ^^^^^^^ error: aborting due to 2 previous errors diff --git a/diesel_compile_tests/tests/ui/as_changeset_deprecated_column_name.stderr b/diesel_compile_tests/tests/ui/as_changeset_deprecated_column_name.stderr index 91d5f5faab08..18c0bb96744d 100644 --- a/diesel_compile_tests/tests/ui/as_changeset_deprecated_column_name.stderr +++ b/diesel_compile_tests/tests/ui/as_changeset_deprecated_column_name.stderr @@ -2,11 +2,11 @@ warning: The form `table_name(value)` is deprecated. Use `table_name = "value"` --> $DIR/as_changeset_deprecated_column_name.rs:12:3 | 12 | #[table_name(users)] - | ^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^ warning: The form `column_name(value)` is deprecated. Use `column_name = "value"` instead --> $DIR/as_changeset_deprecated_column_name.rs:15:7 | 15 | #[column_name(name)] - | ^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^ diff --git a/diesel_compile_tests/tests/ui/as_expression_bad_sql_type.stderr b/diesel_compile_tests/tests/ui/as_expression_bad_sql_type.stderr index f929df8958d7..b1d03b9a037c 100644 --- a/diesel_compile_tests/tests/ui/as_expression_bad_sql_type.stderr +++ b/diesel_compile_tests/tests/ui/as_expression_bad_sql_type.stderr @@ -2,7 +2,7 @@ error: `sql_type` must be in the form `sql_type = "value"` --> $DIR/as_expression_bad_sql_type.rs:5:3 | 5 | #[sql_type(Foo)] - | ^^^^^^^^ + | ^^^^^^^^^^^^^ error: `sql_type` must be in the form `sql_type = "value"` --> $DIR/as_expression_bad_sql_type.rs:6:3 diff --git a/diesel_compile_tests/tests/ui/belongs_to_invalid_option_syntax.stderr b/diesel_compile_tests/tests/ui/belongs_to_invalid_option_syntax.stderr index 4de25629101c..a34adbb85d1d 100644 --- a/diesel_compile_tests/tests/ui/belongs_to_invalid_option_syntax.stderr +++ b/diesel_compile_tests/tests/ui/belongs_to_invalid_option_syntax.stderr @@ -8,13 +8,13 @@ error: `belongs_to` must be in the form `belongs_to(...)` --> $DIR/belongs_to_invalid_option_syntax.rs:24:3 | 24 | #[belongs_to = "Bar"] - | ^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^ error: Expected a struct name --> $DIR/belongs_to_invalid_option_syntax.rs:25:3 | 25 | #[belongs_to()] - | ^^^^^^^^^^ + | ^^^^^^^^^^^^ | = help: e.g. `#[belongs_to(User)]` or `#[belongs_to(parent = "User<'_>")] @@ -22,7 +22,7 @@ error: Expected a struct name --> $DIR/belongs_to_invalid_option_syntax.rs:26:3 | 26 | #[belongs_to(foreign_key = "bar_id")] - | ^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: e.g. `#[belongs_to(User)]` or `#[belongs_to(parent = "User<'_>")] @@ -36,7 +36,7 @@ warning: The form `foreign_key(value)` is deprecated. Use `foreign_key = "value" --> $DIR/belongs_to_invalid_option_syntax.rs:28:19 | 28 | #[belongs_to(Bar, foreign_key(bar_id))] - | ^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^ warning: Unrecognized option random_option --> $DIR/belongs_to_invalid_option_syntax.rs:29:43 diff --git a/diesel_compile_tests/tests/ui/queryable_by_name_requires_table_name_or_sql_type_annotation.stderr b/diesel_compile_tests/tests/ui/queryable_by_name_requires_table_name_or_sql_type_annotation.stderr index 9197218fdd09..f800624d2f43 100644 --- a/diesel_compile_tests/tests/ui/queryable_by_name_requires_table_name_or_sql_type_annotation.stderr +++ b/diesel_compile_tests/tests/ui/queryable_by_name_requires_table_name_or_sql_type_annotation.stderr @@ -2,7 +2,7 @@ error: Cannot determine the SQL type of foo --> $DIR/queryable_by_name_requires_table_name_or_sql_type_annotation.rs:5:5 | 5 | foo: i32, - | ^^^ + | ^^^^^^^^ | = help: Your struct must either be annotated with `#[table_name = "foo"]` or have all of its fields annotated with `#[sql_type = "Integer"]` @@ -10,7 +10,7 @@ error: Cannot determine the SQL type of bar --> $DIR/queryable_by_name_requires_table_name_or_sql_type_annotation.rs:6:5 | 6 | bar: String, - | ^^^ + | ^^^^^^^^^^^ | = help: Your struct must either be annotated with `#[table_name = "foo"]` or have all of its fields annotated with `#[sql_type = "Integer"]` diff --git a/diesel_compile_tests/tests/ui/sql_type_bad_options.stderr b/diesel_compile_tests/tests/ui/sql_type_bad_options.stderr index f8701596979d..fb0eb88d91d2 100644 --- a/diesel_compile_tests/tests/ui/sql_type_bad_options.stderr +++ b/diesel_compile_tests/tests/ui/sql_type_bad_options.stderr @@ -8,19 +8,19 @@ warning: Option oid has no effect --> $DIR/sql_type_bad_options.rs:9:31 | 9 | #[postgres(type_name = "foo", oid = "2", array_oid = "3")] - | ^^^ + | ^^^^^^^^^ warning: Option array_oid has no effect --> $DIR/sql_type_bad_options.rs:9:42 | 9 | #[postgres(type_name = "foo", oid = "2", array_oid = "3")] - | ^^^^^^^^^ + | ^^^^^^^^^^^^^^^ error: Missing required option `array_oid` --> $DIR/sql_type_bad_options.rs:13:3 | 13 | #[postgres(oid = "2")] - | ^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^ error: Expected a number --> $DIR/sql_type_bad_options.rs:17:18 @@ -32,19 +32,19 @@ warning: Option ary_oid has no effect --> $DIR/sql_type_bad_options.rs:21:25 | 21 | #[postgres(oid = "NaN", ary_oid = "1")] - | ^^^^^^^ + | ^^^^^^^^^^^^^ error: Missing required option `array_oid` --> $DIR/sql_type_bad_options.rs:21:3 | 21 | #[postgres(oid = "NaN", ary_oid = "1")] - | ^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `postgres` must be in the form `postgres(...)` --> $DIR/sql_type_bad_options.rs:25:3 | 25 | #[postgres = "foo"] - | ^^^^^^^^ + | ^^^^^^^^^^^^^^^^ error: aborting due to 5 previous errors diff --git a/diesel_derives/Cargo.toml b/diesel_derives/Cargo.toml index a872ac1f31a3..e460ae074f5d 100644 --- a/diesel_derives/Cargo.toml +++ b/diesel_derives/Cargo.toml @@ -10,9 +10,9 @@ repository = "https://github.com/diesel-rs/diesel/tree/master/diesel_derives" autotests = false [dependencies] -syn = { version = "0.15.0", features = ["full", "fold"] } -quote = "0.6.0" -proc-macro2 = "0.4.0" +syn = { version = "1", features = ["full", "fold"] } +quote = "1" +proc-macro2 = "1" [dev-dependencies] cfg-if = "0.1.0" diff --git a/diesel_derives/src/associations.rs b/diesel_derives/src/associations.rs index dc1d0a841920..5fa0fc24cc88 100644 --- a/diesel_derives/src/associations.rs +++ b/diesel_derives/src/associations.rs @@ -115,10 +115,10 @@ impl AssociationOptions { fn from_meta(meta: MetaItem) -> Result { let parent_struct = meta .nested()? - .find(|m| m.word().is_ok() || m.name() == "parent") + .find(|m| m.path().is_ok() || m.name().is_ident("parent")) .ok_or_else(|| meta.span()) .and_then(|m| { - m.word() + m.path() .map(|i| parse_quote!(#i)) .or_else(|_| m.ty_value()) .map_err(|_| m.span()) @@ -136,18 +136,23 @@ impl AssociationOptions { .path .segments .last() - .expect("paths always have at least one segment") - .into_value(); + .expect("paths always have at least one segment"); meta.nested_item("foreign_key")? .map(|i| i.ident_value()) .unwrap_or_else(|| Ok(infer_foreign_key(&parent_struct_name.ident)))? }; - let unrecognized_options = meta.nested()?.skip(1).filter(|n| n.name() != "foreign_key"); + let unrecognized_options = meta + .nested()? + .skip(1) + .filter(|n| !n.name().is_ident("foreign_key")); for ignored in unrecognized_options { ignored .span() - .warning(format!("Unrecognized option {}", ignored.name())) + .warning(format!( + "Unrecognized option {}", + path_to_string(&ignored.name()) + )) .emit(); } diff --git a/diesel_derives/src/meta.rs b/diesel_derives/src/meta.rs index 39830831f00f..8f685a04022e 100644 --- a/diesel_derives/src/meta.rs +++ b/diesel_derives/src/meta.rs @@ -10,15 +10,24 @@ pub struct MetaItem { meta: syn::Meta, } +pub(crate) fn path_to_string(path: &syn::Path) -> String { + path.segments + .iter() + .map(|s| s.ident.to_string()) + .collect::>() + .join("::") +} + impl MetaItem { pub fn all_with_name(attrs: &[syn::Attribute], name: &str) -> Vec { attrs .iter() .filter_map(|attr| { - attr.interpret_meta() + attr.parse_meta() + .ok() .map(|m| FixSpan(attr.pound_token.spans[0]).fold_meta(m)) }) - .filter(|m| m.name() == name) + .filter(|m| m.path().is_ident(name)) .map(|meta| Self { meta }) .collect() } @@ -30,7 +39,7 @@ impl MetaItem { pub fn empty(name: &str) -> Self { Self { meta: syn::Meta::List(syn::MetaList { - ident: Ident::new(name, Span::call_site()), + path: syn::Path::from(Ident::new(name, Span::call_site())), paren_token: Default::default(), nested: Default::default(), }), @@ -38,7 +47,8 @@ impl MetaItem { } pub fn nested_item(&self, name: &str) -> Result, Diagnostic> { - self.nested().map(|mut i| i.find(|n| n.name() == name)) + self.nested() + .map(|mut i| i.find(|n| n.name().is_ident(name))) } pub fn required_nested_item(&self, name: &str) -> Result { @@ -56,7 +66,7 @@ impl MetaItem { self.span() .error(format!( "`{0}` must be in the form `{0} = \"true\"`", - self.name() + path_to_string(&self.name()) )) .emit(); false @@ -67,22 +77,22 @@ impl MetaItem { pub fn expect_ident_value(&self) -> syn::Ident { self.ident_value().unwrap_or_else(|e| { e.emit(); - self.name() + self.name().segments.first().unwrap().ident.clone() }) } pub fn ident_value(&self) -> Result { let maybe_attr = self.nested().ok().and_then(|mut n| n.nth(0)); - let maybe_word = maybe_attr.as_ref().and_then(|m| m.word().ok()); - match maybe_word { + let maybe_path = maybe_attr.as_ref().and_then(|m| m.path().ok()); + match maybe_path { Some(x) => { self.span() .warning(format!( "The form `{0}(value)` is deprecated. Use `{0} = \"value\"` instead", - self.name(), + path_to_string(&self.name()), )) .emit(); - Ok(x) + Ok(x.segments.first().unwrap().ident.clone()) } _ => Ok(syn::Ident::new( &self.str_value()?, @@ -91,23 +101,23 @@ impl MetaItem { } } - pub fn expect_word(&self) -> syn::Ident { - self.word().unwrap_or_else(|e| { + pub fn expect_path(&self) -> syn::Path { + self.path().unwrap_or_else(|e| { e.emit(); self.name() }) } - pub fn word(&self) -> Result { + pub fn path(&self) -> Result { use syn::Meta::*; match self.meta { - Word(ref x) => Ok(x.clone()), + Path(ref x) => Ok(x.clone()), _ => { let meta = &self.meta; Err(self.span().error(format!( "Expected `{}` found `{}`", - self.name(), + path_to_string(&self.name()), quote!(#meta) ))) } @@ -119,21 +129,22 @@ impl MetaItem { match self.meta { List(ref list) => Ok(Nested(list.nested.iter())), - _ => Err(self - .span() - .error(format!("`{0}` must be in the form `{0}(...)`", self.name()))), + _ => Err(self.span().error(format!( + "`{0}` must be in the form `{0}(...)`", + path_to_string(&self.name()) + ))), } } - pub fn name(&self) -> syn::Ident { - self.meta.name() + pub fn name(&self) -> syn::Path { + self.meta.path().clone() } pub fn has_flag(&self, flag: &str) -> bool { self.nested() .map(|mut n| { - n.any(|m| match m.word() { - Ok(word) => word == flag, + n.any(|m| match m.path() { + Ok(word) => word.is_ident(flag), Err(_) => false, }) }) @@ -152,7 +163,7 @@ impl MetaItem { pub fn expect_str_value(&self) -> String { self.str_value().unwrap_or_else(|e| { e.emit(); - self.name().to_string() + path_to_string(&self.name()) }) } @@ -167,7 +178,7 @@ impl MetaItem { Str(ref s) => Ok(s), _ => Err(self.span().error(format!( "`{0}` must be in the form `{0} = \"value\"`", - self.name() + path_to_string(&self.name()) ))), } } @@ -183,7 +194,7 @@ impl MetaItem { match *self.lit_value()? { Str(ref s) => s.value().parse().map_err(|_| error), - Int(ref i) => Ok(i.value()), + Int(ref i) => i.base10_parse().map_err(|_| error), _ => Err(error), } } @@ -195,7 +206,7 @@ impl MetaItem { NameValue(ref name_value) => Ok(&name_value.lit), _ => Err(self.span().error(format!( "`{0}` must be in the form `{0} = \"value\"`", - self.name() + path_to_string(&self.name()) ))), } } @@ -205,11 +216,15 @@ impl MetaItem { Ok(x) => x, Err(_) => return, }; - let unrecognized_options = nested.filter(|n| !options.iter().any(|&o| n.name() == o)); + let unrecognized_options = + nested.filter(|n| !options.iter().any(|&o| n.name().is_ident(o))); for ignored in unrecognized_options { ignored .span() - .warning(format!("Option {} has no effect", ignored.name())) + .warning(format!( + "Option {} has no effect", + path_to_string(&ignored.name()) + )) .emit(); } } @@ -218,7 +233,7 @@ impl MetaItem { use syn::Meta::*; match self.meta { - Word(ref ident) => ident.span(), + Path(ref path) => path.span(), List(ref meta) => meta.nested.span(), NameValue(ref meta) => meta.lit.span(), } diff --git a/diesel_derives/src/model.rs b/diesel_derives/src/model.rs index 25722a8103c3..8661583aa9a9 100644 --- a/diesel_derives/src/model.rs +++ b/diesel_derives/src/model.rs @@ -18,7 +18,11 @@ impl Model { let table_name_from_attribute = MetaItem::with_name(&item.attrs, "table_name").map(|m| m.expect_ident_value()); let primary_key_names = MetaItem::with_name(&item.attrs, "primary_key") - .map(|m| Ok(m.nested()?.map(|m| m.expect_word()).collect())) + .map(|m| { + Ok(m.nested()? + .map(|m| m.expect_path().segments.first().unwrap().ident.clone()) + .collect()) + }) .unwrap_or_else(|| Ok(vec![Ident::new("id", Span::call_site())]))?; let fields = fields_from_item_data(&item.data)?; Ok(Self { diff --git a/diesel_migrations/migrations_internals/Cargo.toml b/diesel_migrations/migrations_internals/Cargo.toml index ffed370f660e..b227f262182f 100644 --- a/diesel_migrations/migrations_internals/Cargo.toml +++ b/diesel_migrations/migrations_internals/Cargo.toml @@ -8,7 +8,7 @@ homepage = "http://diesel.rs" [dependencies] diesel = { version = "~1.4.0", default-features = false } -barrel = { version = "<= 0.2.0", optional = true, features = ["diesel-filled"] } +barrel = { version = ">= 0.5.0", optional = true, features = ["diesel"] } [dev-dependencies] tempdir = "0.3.4" diff --git a/diesel_migrations/migrations_internals/src/lib.rs b/diesel_migrations/migrations_internals/src/lib.rs index 933e21a8ba83..8fa0cbaa1b6f 100644 --- a/diesel_migrations/migrations_internals/src/lib.rs +++ b/diesel_migrations/migrations_internals/src/lib.rs @@ -138,7 +138,7 @@ where pub fn run_pending_migrations_in_directory( conn: &Conn, migrations_dir: &Path, - output: &mut Write, + output: &mut dyn Write, ) -> Result<(), RunMigrationsError> where Conn: MigrationConnection, @@ -152,7 +152,7 @@ where pub fn mark_migrations_in_directory( conn: &Conn, migrations_dir: &Path, -) -> Result, bool)>, RunMigrationsError> +) -> Result, bool)>, RunMigrationsError> where Conn: MigrationConnection, { @@ -222,7 +222,7 @@ pub fn revert_migration_with_version( conn: &Conn, migrations_dir: &Path, ver: &str, - output: &mut Write, + output: &mut dyn Write, ) -> Result<(), RunMigrationsError> { migration_with_version(migrations_dir, ver) .map_err(|e| e.into()) @@ -234,7 +234,7 @@ pub fn run_migration_with_version( conn: &Conn, migrations_dir: &Path, ver: &str, - output: &mut Write, + output: &mut dyn Write, ) -> Result<(), RunMigrationsError> where Conn: MigrationConnection, @@ -247,7 +247,7 @@ where fn migration_with_version( migrations_dir: &Path, ver: &str, -) -> Result, MigrationError> { +) -> Result, MigrationError> { let all_migrations = migrations_in_directory(migrations_dir)?; let migration = all_migrations.into_iter().find(|m| m.version() == ver); match migration { @@ -287,9 +287,7 @@ pub fn migration_paths_in_directory(path: &Path) -> Result, Migrat .collect() } -fn migrations_in_directory(path: &Path) -> Result>, MigrationError> { - use self::migration::migration_from; - +fn migrations_in_directory(path: &Path) -> Result>, MigrationError> { migration_paths_in_directory(path)? .iter() .map(|e| migration_from(e.path())) @@ -301,7 +299,7 @@ fn migrations_in_directory(path: &Path) -> Result>, Migration pub fn run_migrations( conn: &Conn, migrations: List, - output: &mut Write, + output: &mut dyn Write, ) -> Result<(), RunMigrationsError> where Conn: MigrationConnection, @@ -324,8 +322,8 @@ where fn run_migration( conn: &Conn, - migration: &Migration, - output: &mut Write, + migration: &dyn Migration, + output: &mut dyn Write, ) -> Result<(), RunMigrationsError> where Conn: MigrationConnection, @@ -349,8 +347,8 @@ where fn revert_migration( conn: &Conn, - migration: &Migration, - output: &mut Write, + migration: &dyn Migration, + output: &mut dyn Write, ) -> Result<(), RunMigrationsError> { conn.transaction(|| { writeln!(output, "Rolling back migration {}", name(&migration))?; diff --git a/diesel_migrations/migrations_internals/src/migration.rs b/diesel_migrations/migrations_internals/src/migration.rs index 1bdb73ae1bff..fad2ec8c2904 100644 --- a/diesel_migrations/migrations_internals/src/migration.rs +++ b/diesel_migrations/migrations_internals/src/migration.rs @@ -7,10 +7,10 @@ use std::path::{Path, PathBuf}; #[allow(missing_debug_implementations)] #[derive(Clone, Copy)] pub struct MigrationName<'a> { - pub migration: &'a Migration, + pub migration: &'a dyn Migration, } -pub fn name(migration: &Migration) -> MigrationName { +pub fn name(migration: &dyn Migration) -> MigrationName { MigrationName { migration } } @@ -33,11 +33,11 @@ impl<'a> fmt::Display for MigrationName<'a> { #[allow(missing_debug_implementations)] #[derive(Clone, Copy)] pub struct MigrationFileName<'a> { - pub migration: &'a Migration, + pub migration: &'a dyn Migration, pub sql_file: &'a str, } -pub fn file_name<'a>(migration: &'a Migration, sql_file: &'a str) -> MigrationFileName<'a> { +pub fn file_name<'a>(migration: &'a dyn Migration, sql_file: &'a str) -> MigrationFileName<'a> { MigrationFileName { migration, sql_file, @@ -55,7 +55,7 @@ impl<'a> fmt::Display for MigrationFileName<'a> { } } -pub fn migration_from(path: PathBuf) -> Result, MigrationError> { +pub fn migration_from(path: PathBuf) -> Result, MigrationError> { #[cfg(feature = "barrel")] match ::barrel::integrations::diesel::migration_from(&path) { Some(migration) => return Ok(migration), @@ -122,16 +122,16 @@ impl Migration for SqlFileMigration { &self.1 } - fn run(&self, conn: &SimpleConnection) -> Result<(), RunMigrationsError> { + fn run(&self, conn: &dyn SimpleConnection) -> Result<(), RunMigrationsError> { run_sql_from_file(conn, &self.0.join("up.sql")) } - fn revert(&self, conn: &SimpleConnection) -> Result<(), RunMigrationsError> { + fn revert(&self, conn: &dyn SimpleConnection) -> Result<(), RunMigrationsError> { run_sql_from_file(conn, &self.0.join("down.sql")) } } -fn run_sql_from_file(conn: &SimpleConnection, path: &Path) -> Result<(), RunMigrationsError> { +fn run_sql_from_file(conn: &dyn SimpleConnection, path: &Path) -> Result<(), RunMigrationsError> { let mut sql = String::new(); let mut file = File::open(path)?; file.read_to_string(&mut sql)?; diff --git a/diesel_migrations/migrations_macros/Cargo.toml b/diesel_migrations/migrations_macros/Cargo.toml index 007d518d5bd2..ea35299b978f 100644 --- a/diesel_migrations/migrations_macros/Cargo.toml +++ b/diesel_migrations/migrations_macros/Cargo.toml @@ -9,8 +9,9 @@ homepage = "http://diesel.rs" [dependencies] migrations_internals = "~1.4.0" -syn = { version = "0.11.4", features = ["aster"] } -quote = "0.3.12" +syn = { version = "1", features = ["extra-traits"] } +quote = "1" +proc-macro2 = "1" [dev-dependencies] tempdir = "0.3.4" diff --git a/diesel_migrations/migrations_macros/src/embed_migrations.rs b/diesel_migrations/migrations_macros/src/embed_migrations.rs index 82541361618e..4dc2a7f9cfe1 100644 --- a/diesel_migrations/migrations_macros/src/embed_migrations.rs +++ b/diesel_migrations/migrations_macros/src/embed_migrations.rs @@ -1,4 +1,4 @@ -use quote; +use proc_macro2; use syn; use migrations::migration_directory_from_given_path; @@ -8,7 +8,7 @@ use std::path::Path; use util::{get_option, get_options_from_input}; -pub fn derive_embed_migrations(input: &syn::DeriveInput) -> quote::Tokens { +pub fn derive_embed_migrations(input: &syn::DeriveInput) -> proc_macro2::TokenStream { fn bug() -> ! { panic!( "This is a bug. Please open a Github issue \ @@ -16,12 +16,14 @@ pub fn derive_embed_migrations(input: &syn::DeriveInput) -> quote::Tokens { ); } - let options = get_options_from_input("embed_migrations_options", &input.attrs, bug); + let options = + get_options_from_input(&parse_quote!(embed_migrations_options), &input.attrs, bug); let migrations_path_opt = options .as_ref() .map(|o| get_option(o, "migrations_path", bug)); - let migrations_expr = migration_directory_from_given_path(migrations_path_opt) - .and_then(|path| migration_literals_from_path(&path)); + let migrations_expr = + migration_directory_from_given_path(migrations_path_opt.as_ref().map(String::as_str)) + .and_then(|path| migration_literals_from_path(&path)); let migrations_expr = match migrations_expr { Ok(v) => v, Err(e) => panic!("Error reading migrations: {}", e), @@ -78,7 +80,7 @@ pub fn derive_embed_migrations(input: &syn::DeriveInput) -> quote::Tokens { } } -fn migration_literals_from_path(path: &Path) -> Result, Box> { +fn migration_literals_from_path(path: &Path) -> Result, Box> { let mut migrations = migration_paths_in_directory(path)?; migrations.sort_by_key(|a| a.path()); @@ -89,7 +91,7 @@ fn migration_literals_from_path(path: &Path) -> Result, Box Result> { +fn migration_literal_from_path(path: &Path) -> Result> { let version = version_from_path(path)?; let sql_file = path.join("up.sql"); let sql_file_path = sql_file.to_str(); diff --git a/diesel_migrations/migrations_macros/src/lib.rs b/diesel_migrations/migrations_macros/src/lib.rs index 0a83234ea5a4..b8f3bfc9e898 100644 --- a/diesel_migrations/migrations_macros/src/lib.rs +++ b/diesel_migrations/migrations_macros/src/lib.rs @@ -23,8 +23,10 @@ #![cfg_attr(test, allow(clippy::option_unwrap_used, clippy::result_unwrap_used))] extern crate migrations_internals; extern crate proc_macro; +extern crate proc_macro2; #[macro_use] extern crate quote; +#[macro_use] extern crate syn; mod embed_migrations; @@ -32,11 +34,11 @@ mod migrations; mod util; use proc_macro::TokenStream; -use syn::parse_derive_input; +use syn::DeriveInput; #[proc_macro_derive(EmbedMigrations, attributes(embed_migrations_options))] pub fn derive_embed_migrations(input: TokenStream) -> TokenStream { - let item = parse_derive_input(&input.to_string()).unwrap(); + let item = parse_macro_input!(input as DeriveInput); embed_migrations::derive_embed_migrations(&item) .to_string() .parse() diff --git a/diesel_migrations/migrations_macros/src/migrations.rs b/diesel_migrations/migrations_macros/src/migrations.rs index 49b29263facf..cebef60113b1 100644 --- a/diesel_migrations/migrations_macros/src/migrations.rs +++ b/diesel_migrations/migrations_macros/src/migrations.rs @@ -6,7 +6,7 @@ use std::path::{Path, PathBuf}; pub fn migration_directory_from_given_path( given_path: Option<&str>, -) -> Result> { +) -> Result> { let cargo_toml_directory = env::var("CARGO_MANIFEST_DIR")?; let cargo_manifest_path = Path::new(&cargo_toml_directory); let migrations_path = given_path.as_ref().map(Path::new); @@ -16,7 +16,7 @@ pub fn migration_directory_from_given_path( fn resolve_migrations_directory( cargo_manifest_dir: &Path, relative_path_to_migrations: Option<&Path>, -) -> Result> { +) -> Result> { let result = match relative_path_to_migrations { Some(dir) => cargo_manifest_dir.join(dir), None => { diff --git a/diesel_migrations/migrations_macros/src/util.rs b/diesel_migrations/migrations_macros/src/util.rs index 8c502bef9148..a871b4b62fdb 100644 --- a/diesel_migrations/migrations_macros/src/util.rs +++ b/diesel_migrations/migrations_macros/src/util.rs @@ -1,8 +1,11 @@ use syn::*; -pub fn str_value_of_meta_item<'a>(item: &'a MetaItem, name: &str) -> &'a str { +pub fn str_value_of_meta_item(item: &Meta, name: &str) -> String { match *item { - MetaItem::NameValue(_, Lit::Str(ref value, _)) => &*value, + Meta::NameValue(MetaNameValue { + lit: Lit::Str(ref value), + .. + }) => value.value(), _ => panic!( r#"`{}` must be in the form `#[{}="something"]`"#, name, name @@ -11,17 +14,20 @@ pub fn str_value_of_meta_item<'a>(item: &'a MetaItem, name: &str) -> &'a str { } pub fn get_options_from_input( - name: &str, + name: &Path, attrs: &[Attribute], on_bug: fn() -> !, -) -> Option> { - let options = attrs.iter().find(|a| a.name() == name).map(|a| &a.value); +) -> Option> { + let options = attrs + .iter() + .find(|a| &a.path == name) + .map(|a| a.parse_meta()); match options { - Some(&MetaItem::List(_, ref options)) => Some( - options + Some(Ok(Meta::List(MetaList { ref nested, .. }))) => Some( + nested .iter() .map(|o| match *o { - NestedMetaItem::MetaItem(ref m) => m.clone(), + NestedMeta::Meta(ref m) => m.clone(), _ => on_bug(), }) .collect(), @@ -31,13 +37,13 @@ pub fn get_options_from_input( } } -pub fn get_option<'a>(options: &'a [MetaItem], option_name: &str, on_bug: fn() -> !) -> &'a str { +pub fn get_option(options: &[Meta], option_name: &str, on_bug: fn() -> !) -> String { get_optional_option(options, option_name).unwrap_or_else(|| on_bug()) } -pub fn get_optional_option<'a>(options: &'a [MetaItem], option_name: &str) -> Option<&'a str> { +pub fn get_optional_option(options: &[Meta], option_name: &str) -> Option { options .iter() - .find(|a| a.name() == option_name) + .find(|a| a.path().is_ident(option_name)) .map(|a| str_value_of_meta_item(a, option_name)) } diff --git a/diesel_tests/Cargo.toml b/diesel_tests/Cargo.toml index ef2beba0d96e..26f262a9c18a 100644 --- a/diesel_tests/Cargo.toml +++ b/diesel_tests/Cargo.toml @@ -21,8 +21,8 @@ dotenv = ">=0.8, <0.11" quickcheck = { version = "0.4", features = ["unstable"] } uuid = { version = ">=0.2.0, <0.7.0" } serde_json = { version=">=0.9, <2.0" } -ipnetwork = ">=0.12.2, <0.14.0" -bigdecimal = ">= 0.0.10, < 0.0.15" +ipnetwork = ">=0.12.2, <0.16.0" +bigdecimal = ">= 0.0.10, <= 0.1.0" [features] default = [] diff --git a/diesel_tests/tests/filter.rs b/diesel_tests/tests/filter.rs index 53acd2b007e6..163fbcd97395 100644 --- a/diesel_tests/tests/filter.rs +++ b/diesel_tests/tests/filter.rs @@ -378,7 +378,7 @@ sql_function!(fn lower(x: VarChar) -> VarChar); fn filter_by_boxed_predicate() { fn by_name( name: &str, - ) -> Box> { + ) -> Box> { Box::new(lower(users::name).eq(name.to_string())) } diff --git a/examples/mysql/all_about_inserts/src/lib.rs b/examples/mysql/all_about_inserts/src/lib.rs index 226c2fb31bea..55e5bc5872b4 100644 --- a/examples/mysql/all_about_inserts/src/lib.rs +++ b/examples/mysql/all_about_inserts/src/lib.rs @@ -93,7 +93,7 @@ fn examine_sql_from_insert_multiple_columns() { assert_eq!(sql, debug_query::(&query).to_string()); } -pub fn insert_insertable_struct(conn: &MysqlConnection) -> Result<(), Box> { +pub fn insert_insertable_struct(conn: &MysqlConnection) -> Result<(), Box> { use schema::users::dsl::*; let json = r#"{ "name": "Sean", "hair_color": "Black" }"#; @@ -116,7 +116,7 @@ fn examine_sql_from_insertable_struct() { assert_eq!(sql, debug_query::(&query).to_string()); } -pub fn insert_insertable_struct_option(conn: &MysqlConnection) -> Result<(), Box> { +pub fn insert_insertable_struct_option(conn: &MysqlConnection) -> Result<(), Box> { use schema::users::dsl::*; let json = r#"{ "name": "Ruby", "hair_color": null }"#; @@ -229,7 +229,7 @@ fn examine_sql_from_insert_tuple_batch_with_default() { assert_eq!(sql, debug_query::(&query).to_string()); } -pub fn insert_insertable_struct_batch(conn: &MysqlConnection) -> Result<(), Box> { +pub fn insert_insertable_struct_batch(conn: &MysqlConnection) -> Result<(), Box> { use schema::users::dsl::*; let json = r#"[ diff --git a/examples/postgres/advanced-blog-cli/src/editor.rs b/examples/postgres/advanced-blog-cli/src/editor.rs index 64a3f2652d3c..b11b80c3b94d 100644 --- a/examples/postgres/advanced-blog-cli/src/editor.rs +++ b/examples/postgres/advanced-blog-cli/src/editor.rs @@ -6,13 +6,13 @@ use std::ffi::OsString; use std::io::prelude::*; use std::process::Command; -pub fn edit_string(s: &str) -> Result> { +pub fn edit_string(s: &str) -> Result> { let mut file = NamedTempFile::new()?; file.write_all(s.as_bytes())?; editor_output(&mut file) } -fn editor_output(file: &mut NamedTempFile) -> Result> { +fn editor_output(file: &mut NamedTempFile) -> Result> { use std::io::SeekFrom::Start; let status = Command::new(editor_command()?) @@ -30,7 +30,7 @@ fn editor_output(file: &mut NamedTempFile) -> Result> { Ok(buffer) } -fn editor_command() -> Result> { +fn editor_command() -> Result> { use std::env; env::var_os("VISUAL") diff --git a/examples/postgres/advanced-blog-cli/src/main.rs b/examples/postgres/advanced-blog-cli/src/main.rs index 07c103e73427..7579ff3ca44f 100644 --- a/examples/postgres/advanced-blog-cli/src/main.rs +++ b/examples/postgres/advanced-blog-cli/src/main.rs @@ -44,7 +44,7 @@ fn main() { handle_error(run_cli(&database_url, matches)); } -fn run_cli(database_url: &str, cli: Cli) -> Result<(), Box> { +fn run_cli(database_url: &str, cli: Cli) -> Result<(), Box> { let conn = PgConnection::establish(database_url)?; match cli { @@ -171,7 +171,7 @@ fn run_cli(database_url: &str, cli: Cli) -> Result<(), Box> { Ok(()) } -fn current_user(conn: &PgConnection) -> Result> { +fn current_user(conn: &PgConnection) -> Result> { match auth::current_user_from_env(conn) { Ok(Some(user)) => Ok(user), Ok(None) => Err("No user found with the given username".into()), @@ -179,7 +179,7 @@ fn current_user(conn: &PgConnection) -> Result> { } } -fn register_user(conn: &PgConnection) -> Result<(), Box> { +fn register_user(conn: &PgConnection) -> Result<(), Box> { use auth::AuthenticationError as Auth; use diesel::result::DatabaseErrorKind::UniqueViolation; use diesel::result::Error::DatabaseError; @@ -193,7 +193,7 @@ fn register_user(conn: &PgConnection) -> Result<(), Box> { } } -fn convert_auth_error(err: auth::AuthenticationError) -> Box { +fn convert_auth_error(err: auth::AuthenticationError) -> Box { use auth::AuthenticationError::*; match err { @@ -210,14 +210,14 @@ fn convert_auth_error(err: auth::AuthenticationError) -> Box { } } -fn handle_error(res: Result>) -> T { +fn handle_error(res: Result>) -> T { match res { Ok(x) => x, Err(e) => print_error_and_exit(&*e), } } -fn print_error_and_exit(err: &Error) -> ! { +fn print_error_and_exit(err: &dyn Error) -> ! { use std::process::exit; eprintln!("An unexpected error occurred: {}", err); exit(1); diff --git a/examples/postgres/all_about_inserts/src/lib.rs b/examples/postgres/all_about_inserts/src/lib.rs index c825bc8796fe..fef041f59fd7 100644 --- a/examples/postgres/all_about_inserts/src/lib.rs +++ b/examples/postgres/all_about_inserts/src/lib.rs @@ -92,7 +92,7 @@ fn examine_sql_from_insert_multiple_columns() { assert_eq!(sql, debug_query::(&query).to_string()); } -pub fn insert_insertable_struct(conn: &PgConnection) -> Result<(), Box> { +pub fn insert_insertable_struct(conn: &PgConnection) -> Result<(), Box> { use schema::users::dsl::*; let json = r#"{ "name": "Sean", "hair_color": "Black" }"#; @@ -115,7 +115,7 @@ fn examine_sql_from_insertable_struct() { assert_eq!(sql, debug_query::(&query).to_string()); } -pub fn insert_insertable_struct_option(conn: &PgConnection) -> Result<(), Box> { +pub fn insert_insertable_struct_option(conn: &PgConnection) -> Result<(), Box> { use schema::users::dsl::*; let json = r#"{ "name": "Ruby", "hair_color": null }"#; @@ -228,7 +228,7 @@ fn examine_sql_from_insert_tuple_batch_with_default() { assert_eq!(sql, debug_query::(&query).to_string()); } -pub fn insert_insertable_struct_batch(conn: &PgConnection) -> Result<(), Box> { +pub fn insert_insertable_struct_batch(conn: &PgConnection) -> Result<(), Box> { use schema::users::dsl::*; let json = r#"[ diff --git a/examples/sqlite/all_about_inserts/src/lib.rs b/examples/sqlite/all_about_inserts/src/lib.rs index 9d55d3bd6f5e..26134ad5b177 100644 --- a/examples/sqlite/all_about_inserts/src/lib.rs +++ b/examples/sqlite/all_about_inserts/src/lib.rs @@ -93,7 +93,7 @@ fn examine_sql_from_insert_multiple_columns() { assert_eq!(sql, debug_query::(&query).to_string()); } -pub fn insert_insertable_struct(conn: &SqliteConnection) -> Result<(), Box> { +pub fn insert_insertable_struct(conn: &SqliteConnection) -> Result<(), Box> { use schema::users::dsl::*; let json = r#"{ "name": "Sean", "hair_color": "Black" }"#; @@ -116,7 +116,7 @@ fn examine_sql_from_insertable_struct() { assert_eq!(sql, debug_query::(&query).to_string()); } -pub fn insert_insertable_struct_option(conn: &SqliteConnection) -> Result<(), Box> { +pub fn insert_insertable_struct_option(conn: &SqliteConnection) -> Result<(), Box> { use schema::users::dsl::*; let json = r#"{ "name": "Ruby", "hair_color": null }"#; @@ -241,7 +241,7 @@ fn examine_sql_from_insert_tuple_batch_with_default() { // assert_eq!(sql, debug_query::(&query).to_string()); } -pub fn insert_insertable_struct_batch(conn: &SqliteConnection) -> Result<(), Box> { +pub fn insert_insertable_struct_batch(conn: &SqliteConnection) -> Result<(), Box> { use schema::users::dsl::*; let json = r#"[