Update sqlx to 0.7

This commit is contained in:
Luca Palmieri 2023-09-14 09:43:32 +02:00
parent 0864761da8
commit a17336fc42
8 changed files with 923 additions and 648 deletions

View file

@ -14,7 +14,7 @@ on:
env:
CARGO_TERM_COLOR: always
SQLX_VERSION: 0.6.2
SQLX_VERSION: 0.7.1
SQLX_FEATURES: "rustls,postgres"
jobs:
@ -49,7 +49,7 @@ jobs:
SKIP_DOCKER=true ./scripts/init_db.sh
- name: Check sqlx-data.json is up-to-date
run: |
cargo sqlx prepare --check -- --bin zero2prod
cargo sqlx prepare --workspace --check
- name: Run tests
run: cargo test

View file

@ -0,0 +1,17 @@
{
"db_name": "PostgreSQL",
"query": "\n INSERT INTO subscriptions (id, email, name, subscribed_at)\n VALUES ($1, $2, $3, $4)\n ",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Uuid",
"Text",
"Text",
"Timestamptz"
]
},
"nullable": []
},
"hash": "793f0df728d217c204123f12e4eafd6439db2d49d0cb506618ae9e780c7e0558"
}

1522
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -17,7 +17,7 @@ actix-web = "4"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
serde = "1.0.115"
config = { version = "0.13", default-features = false, features = ["yaml"] }
sqlx = { version = "0.6", default-features = false, features = ["runtime-actix-rustls", "macros", "postgres", "uuid", "chrono", "migrate", "offline"] }
sqlx = { version = "0.7", default-features = false, features = ["runtime-tokio-rustls", "macros", "postgres", "uuid", "chrono", "migrate"] }
uuid = { version = "1", features = ["v4"] }
chrono = { version = "0.4.22", default-features = false, features = ["clock"] }
reqwest = { version = "0.11", default-features = false, features = ["json", "rustls-tls"] }

View file

@ -10,7 +10,7 @@ fi
if ! [ -x "$(command -v sqlx)" ]; then
echo >&2 "Error: sqlx is not installed."
echo >&2 "Use:"
echo >&2 " cargo install --version='~0.6' sqlx-cli --no-default-features --features rustls,postgres"
echo >&2 " cargo install --version='~0.7' sqlx-cli --no-default-features --features rustls,postgres"
echo >&2 "to install it."
exit 1
fi

View file

@ -1,18 +0,0 @@
{
"db": "PostgreSQL",
"793f0df728d217c204123f12e4eafd6439db2d49d0cb506618ae9e780c7e0558": {
"query": "\n INSERT INTO subscriptions (id, email, name, subscribed_at)\n VALUES ($1, $2, $3, $4)\n ",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Uuid",
"Text",
"Text",
"Timestamptz"
]
},
"nullable": []
}
}
}

View file

@ -2,7 +2,6 @@ use crate::domain::SubscriberEmail;
use secrecy::{ExposeSecret, Secret};
use serde_aux::field_attributes::deserialize_number_from_string;
use sqlx::postgres::{PgConnectOptions, PgSslMode};
use sqlx::ConnectOptions;
use std::convert::{TryFrom, TryInto};
#[derive(serde::Deserialize)]
@ -46,9 +45,7 @@ impl DatabaseSettings {
}
pub fn with_db(&self) -> PgConnectOptions {
let mut options = self.without_db().database(&self.database_name);
options.log_statements(tracing::log::LevelFilter::Trace);
options
self.without_db().database(&self.database_name)
}
}

View file

@ -12,7 +12,6 @@ async fn main() -> std::io::Result<()> {
let configuration = get_configuration().expect("Failed to read configuration.");
let connection_pool = PgPoolOptions::new()
.acquire_timeout(std::time::Duration::from_secs(2))
.connect_lazy_with(configuration.database.with_db());
let sender_email = configuration