diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index ca1bb8b1c..f24ad33db 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -33,10 +33,18 @@ jobs: with: toolchain: nightly components: rustfmt - - run: cargo fmt --all -- --check + - run: cargo fmt --manifest-path Cargo.toml --all -- --check + - run: cargo fmt --manifest-path sea-query-attr/Cargo.toml --all -- --check - run: cargo fmt --manifest-path sea-query-binder/Cargo.toml --all -- --check - - run: cargo fmt --manifest-path sea-query-rusqlite/Cargo.toml --all -- --check + - run: cargo fmt --manifest-path sea-query-derive/Cargo.toml --all -- --check - run: cargo fmt --manifest-path sea-query-postgres/Cargo.toml --all -- --check + - run: cargo fmt --manifest-path sea-query-rusqlite/Cargo.toml --all -- --check + - run: cargo fmt --manifest-path examples/sqlx_sqlite/Cargo.toml --all -- --check + - run: cargo fmt --manifest-path examples/sqlx_any/Cargo.toml --all -- --check + - run: cargo fmt --manifest-path examples/rusqlite/Cargo.toml --all -- --check + - run: cargo fmt --manifest-path examples/sqlx_postgres/Cargo.toml --all -- --check + - run: cargo fmt --manifest-path examples/postgres/Cargo.toml --all -- --check + - run: cargo fmt --manifest-path examples/sqlx_mysql/Cargo.toml --all -- --check clippy: name: Clippy @@ -247,3 +255,12 @@ jobs: - uses: dtolnay/rust-toolchain@stable - run: cargo build --manifest-path examples/${{ matrix.example }}/Cargo.toml - run: cargo run --manifest-path examples/${{ matrix.example }}/Cargo.toml + + any: + name: Any + runs-on: ubuntu-latest + needs: ["test", "derive-test", "binder-build"] + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@stable + - run: cargo build --manifest-path examples/sqlx_any/Cargo.toml diff --git a/Cargo.toml b/Cargo.toml index 5c0bf3f58..86c19e991 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,7 +41,7 @@ uuid = { version = "1", default-features = false, optional = true } proc-macro2 = { version = "1", default-features = false, optional = true } quote = { version = "1", default-features = false, optional = true } time = { version = "0.3", default-features = false, optional = true, features = ["macros", "formatting"] } -ipnetwork = { version = "0.19", default-features = false, optional = true } +ipnetwork = { version = "0.20", default-features = false, optional = true } mac_address = { version = "1.1", default-features = false, optional = true } ordered-float = { version = "3.4", default-features = false, optional = true } diff --git a/examples/sqlx_any/Cargo.toml b/examples/sqlx_any/Cargo.toml index 0ee206b63..7dc16a82c 100644 --- a/examples/sqlx_any/Cargo.toml +++ b/examples/sqlx_any/Cargo.toml @@ -14,7 +14,7 @@ serde_json = "1" rust_decimal = { version = "1" } bigdecimal = { version = "0.3" } async-std = { version = "1.8", features = [ "attributes" ] } -sqlx = "0.6" +sqlx = "0.7" sea-query = { path = "../../" } sea-query-binder = { path = "../../sea-query-binder", features = [ "sqlx-postgres", diff --git a/examples/sqlx_any/src/main.rs b/examples/sqlx_any/src/main.rs index 0e206b7b3..f88df0bc9 100644 --- a/examples/sqlx_any/src/main.rs +++ b/examples/sqlx_any/src/main.rs @@ -1,4 +1,4 @@ -use chrono::{NaiveDate, NaiveDateTime}; +use chrono::NaiveDate; use sea_query::{ ColumnDef, Expr, Func, Iden, MysqlQueryBuilder, OnConflict, Order, PostgresQueryBuilder, Query, QueryBuilder, SchemaBuilder, SqliteQueryBuilder, Table, @@ -65,7 +65,7 @@ async fn main() { .col(ColumnDef::new(Character::Created).date_time()) .build_any(schema_builder); - let result = sqlx::query(&sql).execute(&mut pool).await; + let result = sqlx::query(&sql).execute(&mut *pool).await; println!("Create table character: {result:?}\n"); // Create @@ -90,7 +90,7 @@ async fn main() { .build_any_sqlx(query_builder); let row = sqlx::query_with(&sql, values) - .fetch_one(&mut pool) + .fetch_one(&mut *pool) .await .unwrap(); let id: i32 = row.try_get(0).unwrap(); @@ -111,7 +111,7 @@ async fn main() { .build_any_sqlx(query_builder); let rows = sqlx::query_as_with::<_, CharacterStructChrono, _>(&sql, values) - .fetch_all(&mut pool) + .fetch_all(&mut *pool) .await .unwrap(); println!("Select one from character:"); @@ -128,7 +128,7 @@ async fn main() { .and_where(Expr::col(Character::Id).eq(id)) .build_any_sqlx(query_builder); - let result = sqlx::query_with(&sql, values).execute(&mut pool).await; + let result = sqlx::query_with(&sql, values).execute(&mut *pool).await; println!("Update character: {result:?}\n"); // Read @@ -146,7 +146,7 @@ async fn main() { .build_any_sqlx(query_builder); let rows = sqlx::query_as_with::<_, CharacterStructChrono, _>(&sql, values) - .fetch_all(&mut pool) + .fetch_all(&mut *pool) .await .unwrap(); println!("Select one from character:"); @@ -163,7 +163,7 @@ async fn main() { .build_any_sqlx(query_builder); let row = sqlx::query_with(&sql, values) - .fetch_one(&mut pool) + .fetch_one(&mut *pool) .await .unwrap(); print!("Count character: "); @@ -184,7 +184,7 @@ async fn main() { ) .build_any_sqlx(query_builder); - let result = sqlx::query_with(&sql, values).execute(&mut pool).await; + let result = sqlx::query_with(&sql, values).execute(&mut *pool).await; println!("Insert into character (with upsert): {result:?}\n"); // Read @@ -201,7 +201,7 @@ async fn main() { .build_any_sqlx(query_builder); let rows = sqlx::query_as_with::<_, CharacterStructChrono, _>(&sql, values) - .fetch_all(&mut pool) + .fetch_all(&mut *pool) .await .unwrap(); println!("Select all characters:"); @@ -217,7 +217,7 @@ async fn main() { .and_where(Expr::col(Character::Id).eq(id)) .build_any_sqlx(query_builder); - let result = sqlx::query_with(&sql, values).execute(&mut pool).await; + let result = sqlx::query_with(&sql, values).execute(&mut *pool).await; println!("Delete character: {result:?}"); } @@ -236,5 +236,5 @@ struct CharacterStructChrono { id: i32, character: String, font_size: i32, - created: NaiveDateTime, + created: String, } diff --git a/examples/sqlx_mysql/Cargo.toml b/examples/sqlx_mysql/Cargo.toml index a1067a2f2..aeb8b7f21 100644 --- a/examples/sqlx_mysql/Cargo.toml +++ b/examples/sqlx_mysql/Cargo.toml @@ -14,7 +14,7 @@ serde_json = "1" rust_decimal = { version = "1" } bigdecimal = { version = "0.3" } async-std = { version = "1.8", features = [ "attributes" ] } -sqlx = "0.6" +sqlx = "0.7" sea-query = { path = "../../" } sea-query-binder = { path = "../../sea-query-binder", features = [ "sqlx-mysql", diff --git a/examples/sqlx_mysql/src/main.rs b/examples/sqlx_mysql/src/main.rs index 1cb2b2793..f69522ca3 100644 --- a/examples/sqlx_mysql/src/main.rs +++ b/examples/sqlx_mysql/src/main.rs @@ -40,7 +40,7 @@ async fn main() { .col(ColumnDef::new(Character::Created).date_time()) .build(MysqlQueryBuilder); - let result = sqlx::query(&sql).execute(&mut pool).await; + let result = sqlx::query(&sql).execute(&mut *pool).await; println!("Create table character: {result:?}\n"); // Create @@ -92,7 +92,7 @@ async fn main() { ]) .build_sqlx(MysqlQueryBuilder); - let result = sqlx::query_with(&sql, values).execute(&mut pool).await; + let result = sqlx::query_with(&sql, values).execute(&mut *pool).await; println!("Insert into character: {result:?}\n"); let id = result.unwrap().last_insert_id(); @@ -115,7 +115,7 @@ async fn main() { .build_sqlx(MysqlQueryBuilder); let rows = sqlx::query_as_with::<_, CharacterStructChrono, _>(&sql, values.clone()) - .fetch_all(&mut pool) + .fetch_all(&mut *pool) .await .unwrap(); println!("Select one from character:"); @@ -125,7 +125,7 @@ async fn main() { println!(); let rows = sqlx::query_as_with::<_, CharacterStructTime, _>(&sql, values) - .fetch_all(&mut pool) + .fetch_all(&mut *pool) .await .unwrap(); println!("Select one from character:"); @@ -142,7 +142,7 @@ async fn main() { .and_where(Expr::col(Character::Id).eq(id)) .build_sqlx(MysqlQueryBuilder); - let result = sqlx::query_with(&sql, values).execute(&mut pool).await; + let result = sqlx::query_with(&sql, values).execute(&mut *pool).await; println!("Update character: {result:?}\n"); // Read @@ -164,7 +164,7 @@ async fn main() { .build_sqlx(MysqlQueryBuilder); let rows = sqlx::query_as_with::<_, CharacterStructChrono, _>(&sql, values.clone()) - .fetch_all(&mut pool) + .fetch_all(&mut *pool) .await .unwrap(); println!("Select one from character:"); @@ -174,7 +174,7 @@ async fn main() { println!(); let rows = sqlx::query_as_with::<_, CharacterStructTime, _>(&sql, values) - .fetch_all(&mut pool) + .fetch_all(&mut *pool) .await .unwrap(); println!("Select one from character:"); @@ -197,7 +197,7 @@ async fn main() { ) .build_sqlx(MysqlQueryBuilder); - let result = sqlx::query_with(&sql, values).execute(&mut pool).await; + let result = sqlx::query_with(&sql, values).execute(&mut *pool).await; println!("Insert into character (with upsert): {result:?}\n"); let id = result.unwrap().last_insert_id(); @@ -219,7 +219,7 @@ async fn main() { .build_sqlx(MysqlQueryBuilder); let rows = sqlx::query_as_with::<_, CharacterStructChrono, _>(&sql, values.clone()) - .fetch_all(&mut pool) + .fetch_all(&mut *pool) .await .unwrap(); println!("Select all characters:"); @@ -229,7 +229,7 @@ async fn main() { println!(); let rows = sqlx::query_as_with::<_, CharacterStructTime, _>(&sql, values) - .fetch_all(&mut pool) + .fetch_all(&mut *pool) .await .unwrap(); println!("Select all characters:"); @@ -246,7 +246,7 @@ async fn main() { .build_sqlx(MysqlQueryBuilder); let row = sqlx::query_with(&sql, values) - .fetch_one(&mut pool) + .fetch_one(&mut *pool) .await .unwrap(); print!("Count character: "); @@ -261,7 +261,7 @@ async fn main() { .and_where(Expr::col(Character::Id).eq(id)) .build_sqlx(MysqlQueryBuilder); - let result = sqlx::query_with(&sql, values).execute(&mut pool).await; + let result = sqlx::query_with(&sql, values).execute(&mut *pool).await; println!("Delete character: {result:?}"); } diff --git a/examples/sqlx_postgres/Cargo.toml b/examples/sqlx_postgres/Cargo.toml index b69786fe9..4f3cbeccd 100644 --- a/examples/sqlx_postgres/Cargo.toml +++ b/examples/sqlx_postgres/Cargo.toml @@ -13,10 +13,10 @@ uuid = { version = "1", features = ["serde", "v4"] } serde_json = "1" rust_decimal = { version = "1" } bigdecimal = { version = "0.3" } -ipnetwork = { version = "0.19" } +ipnetwork = { version = "0.20" } mac_address = { version = "1.1" } async-std = { version = "1.8", features = [ "attributes" ] } -sqlx = "0.6" +sqlx = "0.7" sea-query = { path = "../../" } sea-query-binder = { path = "../../sea-query-binder", features = [ "sqlx-postgres", diff --git a/examples/sqlx_postgres/src/main.rs b/examples/sqlx_postgres/src/main.rs index 0915797d2..ab41e2ea7 100644 --- a/examples/sqlx_postgres/src/main.rs +++ b/examples/sqlx_postgres/src/main.rs @@ -47,7 +47,7 @@ async fn main() { .col(ColumnDef::new(Character::MacAddress).mac_address()) .build(PostgresQueryBuilder); - let result = sqlx::query(&sql).execute(&mut pool).await; + let result = sqlx::query(&sql).execute(&mut *pool).await; println!("Create table character: {result:?}\n"); // Create @@ -111,7 +111,7 @@ async fn main() { .build_sqlx(PostgresQueryBuilder); let row = sqlx::query_with(&sql, values) - .fetch_one(&mut pool) + .fetch_one(&mut *pool) .await .unwrap(); let id: i32 = row.try_get(0).unwrap(); @@ -138,7 +138,7 @@ async fn main() { .build_sqlx(PostgresQueryBuilder); let rows = sqlx::query_as_with::<_, CharacterStructChrono, _>(&sql, values.clone()) - .fetch_all(&mut pool) + .fetch_all(&mut *pool) .await .unwrap(); println!("Select one from character:"); @@ -148,7 +148,7 @@ async fn main() { println!(); let rows = sqlx::query_as_with::<_, CharacterStructTime, _>(&sql, values) - .fetch_all(&mut pool) + .fetch_all(&mut *pool) .await .unwrap(); println!("Select one from character:"); @@ -165,7 +165,7 @@ async fn main() { .and_where(Expr::col(Character::Id).eq(id)) .build_sqlx(PostgresQueryBuilder); - let result = sqlx::query_with(&sql, values).execute(&mut pool).await; + let result = sqlx::query_with(&sql, values).execute(&mut *pool).await; println!("Update character: {result:?}\n"); // Read @@ -189,7 +189,7 @@ async fn main() { .build_sqlx(PostgresQueryBuilder); let rows = sqlx::query_as_with::<_, CharacterStructChrono, _>(&sql, values.clone()) - .fetch_all(&mut pool) + .fetch_all(&mut *pool) .await .unwrap(); println!("Select one from character:"); @@ -199,7 +199,7 @@ async fn main() { println!(); let rows = sqlx::query_as_with::<_, CharacterStructTime, _>(&sql, values) - .fetch_all(&mut pool) + .fetch_all(&mut *pool) .await .unwrap(); println!("Select one from character:"); @@ -216,7 +216,7 @@ async fn main() { .build_sqlx(PostgresQueryBuilder); let row = sqlx::query_with(&sql, values) - .fetch_one(&mut pool) + .fetch_one(&mut *pool) .await .unwrap(); print!("Count character: "); @@ -238,7 +238,7 @@ async fn main() { ) .build_sqlx(PostgresQueryBuilder); - let result = sqlx::query_with(&sql, values).execute(&mut pool).await; + let result = sqlx::query_with(&sql, values).execute(&mut *pool).await; println!("Insert into character (with upsert): {result:?}\n"); // Read @@ -261,7 +261,7 @@ async fn main() { .build_sqlx(PostgresQueryBuilder); let rows = sqlx::query_as_with::<_, CharacterStructChrono, _>(&sql, values.clone()) - .fetch_all(&mut pool) + .fetch_all(&mut *pool) .await .unwrap(); println!("Select all characters:"); @@ -271,7 +271,7 @@ async fn main() { println!(); let rows = sqlx::query_as_with::<_, CharacterStructTime, _>(&sql, values) - .fetch_all(&mut pool) + .fetch_all(&mut *pool) .await .unwrap(); println!("Select all characters:"); @@ -287,7 +287,7 @@ async fn main() { .and_where(Expr::col(Character::Id).eq(id)) .build_sqlx(PostgresQueryBuilder); - let result = sqlx::query_with(&sql, values).execute(&mut pool).await; + let result = sqlx::query_with(&sql, values).execute(&mut *pool).await; println!("Delete character: {result:?}"); } diff --git a/examples/sqlx_sqlite/Cargo.toml b/examples/sqlx_sqlite/Cargo.toml index a92638aca..03fd0c489 100644 --- a/examples/sqlx_sqlite/Cargo.toml +++ b/examples/sqlx_sqlite/Cargo.toml @@ -12,7 +12,7 @@ time = { version = "0.3", features = ["macros"] } uuid = { version = "1", features = ["serde", "v4"] } serde_json = "1" async-std = { version = "1.8", features = [ "attributes" ] } -sqlx = "0.6.1" +sqlx = "0.7" sea-query = { path = "../../" } sea-query-binder = { path = "../../sea-query-binder", features = [ "sqlx-sqlite", diff --git a/sea-query-binder/Cargo.toml b/sea-query-binder/Cargo.toml index 3f204c63d..ad4f1c1b3 100644 --- a/sea-query-binder/Cargo.toml +++ b/sea-query-binder/Cargo.toml @@ -3,7 +3,7 @@ [package] name = "sea-query-binder" -version = "0.4.0" +version = "0.5.0" authors = [ "Valentin Tolmer ", "Ivan Krivosheev " ] edition = "2021" description = "Driver library for using SeaQuery with SQLx" @@ -18,14 +18,14 @@ rust-version = "1.60" [dependencies] sea-query = { version = "0.29", path = "..", default-features = false, features = ["thread-safe"] } -sqlx = { version = "0.6.1", default-features = false, optional = true } +sqlx = { version = "0.7", default-features = false, optional = true } serde_json = { version = "1", default-features = false, optional = true, features = ["std"] } chrono = { version = "0.4", default-features = false, optional = true, features = ["clock"] } rust_decimal = { version = "1", default-features = false, optional = true } bigdecimal = { version = "0.3", default-features = false, optional = true } uuid = { version = "1", default-features = false, optional = true } time = { version = "0.3", default-features = false, optional = true, features = ["macros", "formatting"] } -ipnetwork = { version = "0.19", default-features = false, optional = true } +ipnetwork = { version = "0.20", default-features = false, optional = true } mac_address = { version = "1.1", default-features = false, optional = true } [features] @@ -35,7 +35,7 @@ sqlx-sqlite = ["sqlx/sqlite"] sqlx-any = ["sqlx/any"] with-chrono = ["sqlx?/chrono", "sea-query/with-chrono", "chrono"] with-json = ["sqlx?/json", "sea-query/with-json", "serde_json"] -with-rust_decimal = ["sqlx?/decimal", "sea-query/with-rust_decimal", "rust_decimal"] +with-rust_decimal = ["sqlx?/rust_decimal", "sea-query/with-rust_decimal", "rust_decimal"] with-bigdecimal = ["sqlx?/bigdecimal", "sea-query/with-bigdecimal", "bigdecimal"] with-uuid = ["sqlx?/uuid", "sea-query/with-uuid", "uuid"] with-time = ["sqlx?/time", "sea-query/with-time", "time"] @@ -44,7 +44,7 @@ with-mac_address = ["sqlx?/mac_address", "sea-query/with-mac_address", "mac_addr postgres-array = ["sea-query/postgres-array"] runtime-async-std-native-tls = ["sqlx?/runtime-async-std-native-tls"] runtime-async-std-rustls = ["sqlx?/runtime-async-std-rustls", ] -runtime-actix-native-tls = ["sqlx?/runtime-actix-native-tls"] -runtime-actix-rustls = ["sqlx?/runtime-actix-rustls"] +runtime-actix-native-tls = ["sqlx?/runtime-tokio-native-tls"] +runtime-actix-rustls = ["sqlx?/runtime-tokio-rustls"] runtime-tokio-native-tls = ["sqlx?/runtime-tokio-native-tls"] runtime-tokio-rustls = ["sqlx?/runtime-tokio-rustls"] diff --git a/sea-query-binder/src/sqlx_any.rs b/sea-query-binder/src/sqlx_any.rs index bc03ec57d..8f303eefb 100644 --- a/sea-query-binder/src/sqlx_any.rs +++ b/sea-query-binder/src/sqlx_any.rs @@ -50,24 +50,24 @@ impl<'q> sqlx::IntoArguments<'q, sqlx::any::Any> for SqlxValues { args.add(b.map(|b| *b)); } #[cfg(feature = "with-chrono")] - Value::ChronoDate(d) => { - args.add(d.map(|d| *d)); + Value::ChronoDate(t) => { + args.add(Value::ChronoDate(t).chrono_as_naive_utc_in_string()); } #[cfg(feature = "with-chrono")] Value::ChronoTime(t) => { - args.add(t.map(|t| *t)); + args.add(Value::ChronoTime(t).chrono_as_naive_utc_in_string()); } #[cfg(feature = "with-chrono")] Value::ChronoDateTime(t) => { - args.add(t.map(|t| *t)); + args.add(Value::ChronoDateTime(t).chrono_as_naive_utc_in_string()); } #[cfg(feature = "with-chrono")] Value::ChronoDateTimeUtc(t) => { - args.add(t.map(|t| *t)); + args.add(Value::ChronoDateTimeUtc(t).chrono_as_naive_utc_in_string()); } #[cfg(feature = "with-chrono")] Value::ChronoDateTimeLocal(t) => { - args.add(t.map(|t| *t)); + args.add(Value::ChronoDateTimeLocal(t).chrono_as_naive_utc_in_string()); } #[cfg(feature = "with-chrono")] Value::ChronoDateTimeWithTimeZone(t) => { diff --git a/sea-query-postgres/Cargo.toml b/sea-query-postgres/Cargo.toml index 04b22a098..56a72cde4 100644 --- a/sea-query-postgres/Cargo.toml +++ b/sea-query-postgres/Cargo.toml @@ -22,7 +22,7 @@ postgres-types = { version = "0.2", default-features = false } bytes = { version = "1", default-features = false } rust_decimal = { version = "1", default-features = false, optional = true } bigdecimal = { version = "0.3", default-features = false, optional = true } -ipnetwork = { version = "0.19", default-features = false, optional = true } +ipnetwork = { version = "0.20", default-features = false, optional = true } mac_address = { version = "1.1", default-features = false, optional = true } eui48 = { version = "1", default-features = false, optional = true } cidr = { version = "0.2", default-features = false, optional = true }