Skip to content

Commit

Permalink
fix type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
lovasoa committed Sep 30, 2023
1 parent ab26b18 commit 40a06ab
Show file tree
Hide file tree
Showing 14 changed files with 179 additions and 159 deletions.
259 changes: 130 additions & 129 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ members = [

[package]
name = "sqlx-oldapi"
version = "0.6.13"
version = "0.6.14"
license = "MIT OR Apache-2.0"
readme = "README.md"
repository = "https://github.com/lovasoa/sqlx"
Expand Down Expand Up @@ -125,8 +125,8 @@ bstr = ["sqlx-core/bstr"]
git2 = ["sqlx-core/git2"]

[dependencies]
sqlx-core = { package = "sqlx-core-oldapi", version = "0.6.13", path = "sqlx-core", default-features = false }
sqlx-macros = { package = "sqlx-macros-oldapi", version = "0.6.13", path = "sqlx-macros", default-features = false, optional = true }
sqlx-core = { package = "sqlx-core-oldapi", version = "0.6.14", path = "sqlx-core", default-features = false }
sqlx-macros = { package = "sqlx-macros-oldapi", version = "0.6.14", path = "sqlx-macros", default-features = false, optional = true }

[dev-dependencies]
anyhow = "1.0.52"
Expand Down
2 changes: 1 addition & 1 deletion examples/postgres/axum-social-with-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2021"
[dependencies]
# Primary crates
axum = { version = "0.5.13", features = ["macros"] }
sqlx = { package = "sqlx-oldapi", version = "0.6.13", path = "../../../", features = ["runtime-tokio-rustls", "postgres", "time", "uuid"] }
sqlx = { package = "sqlx-oldapi", version = "0.6.14", path = "../../../", features = ["runtime-tokio-rustls", "postgres", "time", "uuid"] }
tokio = { version = "1.20.1", features = ["rt-multi-thread", "macros"] }

# Important secondary crates
Expand Down
2 changes: 1 addition & 1 deletion sqlx-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sqlx-cli"
version = "0.6.13"
version = "0.6.14"
description = "Command-line utility for SQLx, the Rust SQL toolkit."
edition = "2021"
readme = "README.md"
Expand Down
4 changes: 2 additions & 2 deletions sqlx-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sqlx-core-oldapi"
version = "0.6.13"
version = "0.6.14"
repository = "https://github.com/lovasoa/sqlx"
description = "Core of SQLx, the rust SQL toolkit. Not intended to be used directly."
license = "MIT OR Apache-2.0"
Expand Down Expand Up @@ -105,7 +105,7 @@ offline = ["serde", "either/serde"]
paste = "1.0.6"
ahash = "0.8.3"
atoi = "2.0.0"
sqlx-rt = { path = "../sqlx-rt", version = "0.6.13", package = "sqlx-rt-oldapi" }
sqlx-rt = { path = "../sqlx-rt", version = "0.6.14", package = "sqlx-rt-oldapi" }
base64 = { version = "0.21.2", default-features = false, optional = true, features = ["std"] }
bigdecimal_ = { version = "0.4.1", optional = true, package = "bigdecimal" }
rust_decimal = { version = "1.19.0", optional = true }
Expand Down
9 changes: 6 additions & 3 deletions sqlx-core/src/any/migrate.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::any::connection::AnyConnectionKind;
use crate::any::kind::AnyKind;
use crate::any::{Any, AnyConnection};
use crate::error::{Error, Result};
use crate::migrate::{AppliedMigration, Migrate, MigrateDatabase, MigrateError, Migration};
use crate::error::Result;
use crate::migrate::{AppliedMigration, Migrate, MigrateDatabase, MigrateResult, Migration};
use futures_core::future::BoxFuture;
use std::str::FromStr;
use std::time::Duration;
Expand Down Expand Up @@ -114,7 +114,10 @@ impl Migrate for AnyConnection {
}

#[allow(deprecated)]
fn validate<'e: 'm, 'm>(&'e mut self, migration: &'m Migration) -> BoxFuture<'m, Result<()>> {
fn validate<'e: 'm, 'm>(
&'e mut self,
migration: &'m Migration,
) -> BoxFuture<'m, MigrateResult<()>> {
match &mut self.0 {
#[cfg(feature = "postgres")]
AnyConnectionKind::Postgres(conn) => conn.validate(migration),
Expand Down
3 changes: 2 additions & 1 deletion sqlx-core/src/migrate/error.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::error::{BoxDynError, Error};
use crate::migrate::Migration;

#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
Expand Down Expand Up @@ -31,3 +30,5 @@ pub enum MigrateError {
#[error("an operation on the migration metadata table (_sqlx_migrations) failed")]
AccessMigrationMetadata(#[source] Error),
}

pub type MigrateResult<T> = std::result::Result<T, MigrateError>;
9 changes: 6 additions & 3 deletions sqlx-core/src/migrate/migrate.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::error::{Error, Result};
use crate::migrate::{AppliedMigration, MigrateError, Migration};
use crate::error::Result;
use crate::migrate::{AppliedMigration, MigrateResult, Migration};
use futures_core::future::BoxFuture;
use std::time::Duration;

Expand Down Expand Up @@ -35,7 +35,10 @@ pub trait Migrate {
// validate the migration
// checks that it does exist on the database and that the checksum matches
#[deprecated]
fn validate<'e: 'm, 'm>(&'e mut self, migration: &'m Migration) -> BoxFuture<'m, Result<()>>;
fn validate<'e: 'm, 'm>(
&'e mut self,
migration: &'m Migration,
) -> BoxFuture<'m, MigrateResult<()>>;

// Return the ordered list of applied migrations
fn list_applied_migrations(&mut self) -> BoxFuture<'_, Result<Vec<AppliedMigration>>>;
Expand Down
2 changes: 1 addition & 1 deletion sqlx-core/src/migrate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ mod migration_type;
mod migrator;
mod source;

pub use error::MigrateError;
pub use error::{MigrateError, MigrateResult};
pub use migrate::{Migrate, MigrateDatabase};
pub use migration::{AppliedMigration, Migration};
pub use migration_type::MigrationType;
Expand Down
10 changes: 7 additions & 3 deletions sqlx-core/src/mysql/migrate.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use crate::connection::{ConnectOptions, Connection};
use crate::error::{Error, Result};
use crate::executor::Executor;
use crate::migrate::MigrateError;
use crate::migrate::{AppliedMigration, Migration};
use crate::migrate::{Migrate, MigrateDatabase};
use crate::migrate::{MigrateError, MigrateResult};
use crate::mysql::{MySql, MySqlConnectOptions, MySqlConnection};
use crate::query::query;
use crate::query_as::query_as;
Expand Down Expand Up @@ -178,14 +178,18 @@ CREATE TABLE IF NOT EXISTS _sqlx_migrations (
})
}

fn validate<'e: 'm, 'm>(&'e mut self, migration: &'m Migration) -> BoxFuture<'m, Result<()>> {
fn validate<'e: 'm, 'm>(
&'e mut self,
migration: &'m Migration,
) -> BoxFuture<'m, MigrateResult<()>> {
Box::pin(async move {
// language=SQL
let checksum: Option<Vec<u8>> =
query_scalar("SELECT checksum FROM _sqlx_migrations WHERE version = ?")
.bind(migration.version)
.fetch_optional(self)
.await?;
.await
.map_err(MigrateError::AccessMigrationMetadata)?;

if let Some(checksum) = checksum {
return if checksum == &*migration.checksum {
Expand Down
12 changes: 8 additions & 4 deletions sqlx-core/src/postgres/migrate.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use crate::connection::{ConnectOptions, Connection};
use crate::error::{Error, Result};
use crate::error::Result;
use crate::executor::Executor;
use crate::migrate::MigrateError;
use crate::migrate::{AppliedMigration, Migration};
use crate::migrate::{Migrate, MigrateDatabase};
use crate::migrate::{MigrateError, MigrateResult};
use crate::postgres::{PgConnectOptions, PgConnection, Postgres};
use crate::query::query;
use crate::query_as::query_as;
Expand Down Expand Up @@ -188,14 +188,18 @@ CREATE TABLE IF NOT EXISTS _sqlx_migrations (
})
}

fn validate<'e: 'm, 'm>(&'e mut self, migration: &'m Migration) -> BoxFuture<'m, Result<()>> {
fn validate<'e: 'm, 'm>(
&'e mut self,
migration: &'m Migration,
) -> BoxFuture<'m, MigrateResult<()>> {
Box::pin(async move {
// language=SQL
let checksum: Option<Vec<u8>> =
query_scalar("SELECT checksum FROM _sqlx_migrations WHERE version = $1")
.bind(migration.version)
.fetch_optional(self)
.await?;
.await
.map_err(MigrateError::AccessMigrationMetadata)?;

if let Some(checksum) = checksum {
return if checksum == &*migration.checksum {
Expand Down
12 changes: 8 additions & 4 deletions sqlx-core/src/sqlite/migrate.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use crate::connection::{ConnectOptions, Connection};
use crate::error::{Error, Result};
use crate::error::Result;
use crate::executor::Executor;
use crate::migrate::MigrateError;
use crate::migrate::{AppliedMigration, Migration};
use crate::migrate::{Migrate, MigrateDatabase};
use crate::migrate::{MigrateError, MigrateResult};
use crate::query::query;
use crate::query_as::query_as;
use crate::query_scalar::query_scalar;
Expand Down Expand Up @@ -139,14 +139,18 @@ CREATE TABLE IF NOT EXISTS _sqlx_migrations (
Box::pin(async move { Ok(()) })
}

fn validate<'e: 'm, 'm>(&'e mut self, migration: &'m Migration) -> BoxFuture<'m, Result<()>> {
fn validate<'e: 'm, 'm>(
&'e mut self,
migration: &'m Migration,
) -> BoxFuture<'m, MigrateResult<()>> {
Box::pin(async move {
// language=SQL
let checksum: Option<Vec<u8>> =
query_scalar("SELECT checksum FROM _sqlx_migrations WHERE version = ?1")
.bind(migration.version)
.fetch_optional(self)
.await?;
.await
.map_err(MigrateError::AccessMigrationMetadata)?;

if let Some(checksum) = checksum {
if checksum == &*migration.checksum {
Expand Down
6 changes: 3 additions & 3 deletions sqlx-macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sqlx-macros-oldapi"
version = "0.6.13"
version = "0.6.14"
repository = "https://github.com/lovasoa/sqlx"
description = "Macros for SQLx, the rust SQL toolkit. Not intended to be used directly."
license = "MIT OR Apache-2.0"
Expand Down Expand Up @@ -75,8 +75,8 @@ heck = { version = "0.4", features = ["unicode"] }
either = "1.6.1"
once_cell = "1.9.0"
proc-macro2 = { version = "1.0.36", default-features = false }
sqlx-core = { package = "sqlx-core-oldapi", version = "0.6.13", default-features = false, features = ["any"], path = "../sqlx-core" }
sqlx-rt = { version = "0.6.13", default-features = false, path = "../sqlx-rt", package = "sqlx-rt-oldapi" }
sqlx-core = { package = "sqlx-core-oldapi", version = "0.6.14", default-features = false, features = ["any"], path = "../sqlx-core" }
sqlx-rt = { version = "0.6.14", default-features = false, path = "../sqlx-rt", package = "sqlx-rt-oldapi" }
serde = { version = "1.0.132", features = ["derive"], optional = true }
serde_json = { version = "1.0.73", optional = true }
sha2 = { version = "0.10.0", optional = true }
Expand Down
2 changes: 1 addition & 1 deletion sqlx-rt/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sqlx-rt-oldapi"
version = "0.6.13"
version = "0.6.14"
repository = "https://github.com/launchbadge/sqlx"
license = "MIT OR Apache-2.0"
description = "Runtime abstraction used by SQLx, the Rust SQL toolkit. Not intended to be used directly."
Expand Down

0 comments on commit 40a06ab

Please sign in to comment.