Skip to content

Commit

Permalink
chore: use an upgraded version of the sqlx-postgres crate
Browse files Browse the repository at this point in the history
  • Loading branch information
etorreborre authored and metaclips committed Jul 3, 2024
1 parent f1e62d9 commit 0d1d35e
Show file tree
Hide file tree
Showing 10 changed files with 483 additions and 340 deletions.
712 changes: 416 additions & 296 deletions Cargo.lock

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions NOTICE.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ This file contains attributions for any 3rd-party open source code used in this
| fdeflate | MIT, Apache-2.0 | https://crates.io/crates/fdeflate |
| ff | MIT, Apache-2.0 | https://crates.io/crates/ff |
| fiat-crypto | MIT, Apache-2.0, BSD-1-Clause | https://crates.io/crates/fiat-crypto |
| finl_unicode | MIT, Apache-2.0 | https://crates.io/crates/finl_unicode |
| flate2 | MIT, Apache-2.0 | https://crates.io/crates/flate2 |
| flexi_logger | MIT, Apache-2.0 | https://crates.io/crates/flexi_logger |
| flume | Apache-2.0, MIT | https://crates.io/crates/flume |
Expand Down Expand Up @@ -275,6 +274,7 @@ This file contains attributions for any 3rd-party open source code used in this
| is-terminal | MIT | https://crates.io/crates/is-terminal |
| is-wsl | MIT | https://crates.io/crates/is-wsl |
| is_ci | ISC | https://crates.io/crates/is_ci |
| is_terminal_polyfill | MIT, Apache-2.0 | https://crates.io/crates/is_terminal_polyfill |
| itertools | MIT, Apache-2.0 | https://crates.io/crates/itertools |
| itoa | MIT, Apache-2.0 | https://crates.io/crates/itoa |
| jaq-core | MIT | https://crates.io/crates/jaq-core |
Expand All @@ -299,7 +299,6 @@ This file contains attributions for any 3rd-party open source code used in this
| libloading | ISC | https://crates.io/crates/libloading |
| libm | MIT, Apache-2.0 | https://crates.io/crates/libm |
| libsqlite3-sys | MIT | https://crates.io/crates/libsqlite3-sys |
| line-wrap | Apache-2.0 | https://crates.io/crates/line-wrap |
| linked-hash-map | MIT, Apache-2.0 | https://crates.io/crates/linked-hash-map |
| linux-raw-sys | Apache-2.0 WITH LLVM-exception, Apache-2.0, MIT | https://crates.io/crates/linux-raw-sys |
| lock_api | MIT, Apache-2.0 | https://crates.io/crates/lock_api |
Expand Down Expand Up @@ -491,6 +490,9 @@ This file contains attributions for any 3rd-party open source code used in this
| sqlformat | MIT, Apache-2.0 | https://crates.io/crates/sqlformat |
| sqlx-core | MIT, Apache-2.0 | https://crates.io/crates/sqlx-core |
| sqlx-etorreborre | MIT, Apache-2.0 | https://crates.io/crates/sqlx-etorreborre |
| sqlx-etorreborre-core | MIT, Apache-2.0 | https://crates.io/crates/sqlx-etorreborre-core |
| sqlx-etorreborre-postgres | MIT, Apache-2.0 | https://crates.io/crates/sqlx-etorreborre-postgres |
| sqlx-etorreborre-sqlite | MIT, Apache-2.0 | https://crates.io/crates/sqlx-etorreborre-sqlite |
| sqlx-macros | MIT, Apache-2.0 | https://crates.io/crates/sqlx-macros |
| sqlx-macros-core | MIT, Apache-2.0 | https://crates.io/crates/sqlx-macros-core |
| sqlx-postgres | MIT, Apache-2.0 | https://crates.io/crates/sqlx-postgres |
Expand Down Expand Up @@ -563,6 +565,7 @@ This file contains attributions for any 3rd-party open source code used in this
| unicode-ident | MIT, Apache-2.0, Unicode-DFS-2016 | https://crates.io/crates/unicode-ident |
| unicode-linebreak | Apache-2.0 | https://crates.io/crates/unicode-linebreak |
| unicode-normalization | MIT, Apache-2.0 | https://crates.io/crates/unicode-normalization |
| unicode-properties | MIT, Apache-2.0 | https://crates.io/crates/unicode-properties |
| unicode-segmentation | MIT, Apache-2.0 | https://crates.io/crates/unicode-segmentation |
| unicode-width | MIT, Apache-2.0 | https://crates.io/crates/unicode-width |
| unicode_categories | MIT, Apache-2.0 | https://crates.io/crates/unicode_categories |
Expand Down
3 changes: 1 addition & 2 deletions implementations/rust/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ test_postgres:
export OCKAM_POSTGRES_DATABASE_NAME=test
export OCKAM_POSTGRES_USER=postgres
export OCKAM_POSTGRES_PASSWORD=password
# deactivated for now
# cargo --locked nextest --config-file $(ROOT_DIR)/tools/nextest/.config/nextest.toml run -E 'test(sql) or test(cli_state)' --no-fail-fast --test-threads 1
cargo --locked nextest --config-file $(ROOT_DIR)/tools/nextest/.config/nextest.toml run -E 'test(sql) or test(cli_state)' --no-fail-fast --test-threads 1

lint: lint_cargo_fmt_check lint_cargo_deny lint_cargo_clippy
lint_cargo_fmt_check:
Expand Down
2 changes: 1 addition & 1 deletion implementations/rust/ockam/ockam_abac/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ ockam_executor = { version = "0.81.0", path = "../ockam_executor", default-featu
regex = { version = "1.10.5", default-features = false, optional = true }
rustyline = { version = "14.0.0", optional = true }
rustyline-derive = { version = "0.10.0", optional = true }
sqlx-etorreborre = { version = "0.7.5", optional = true }
sqlx-etorreborre = { version = "0.7.8", optional = true }
str-buf = "3.0.3"
tokio = { version = "1.38", default-features = false, optional = true, features = ["sync", "time", "rt", "rt-multi-thread", "macros"] }
tracing = { version = "0.1", default-features = false, features = ["attributes"] }
Expand Down
2 changes: 1 addition & 1 deletion implementations/rust/ockam/ockam_api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ reqwest = { version = "0.12", default-features = false, features = ["json", "rus
serde = { version = "1.0.203", features = ["derive"] }
serde_json = "1.0.118"
sha2 = "0.10.8"
sqlx-etorreborre = { version = "0.7.5" }
sqlx-etorreborre = { version = "0.7.8" }
strip-ansi-escapes = "0.2"
sysinfo = "0.30"
thiserror = "1.0"
Expand Down
2 changes: 1 addition & 1 deletion implementations/rust/ockam/ockam_app_lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ ockam_core = { path = "../ockam_core", version = "^0.112.0" }
ockam_multiaddr = { path = "../ockam_multiaddr", version = "0.56.0", features = ["cbor", "serde"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
sqlx-etorreborre = { version = "0.7.5" }
sqlx-etorreborre = { version = "0.7.8" }
thiserror = "1.0"
tokio = { version = "1.38.0", features = ["full"] }
tracing = { version = "0.1", default-features = false }
Expand Down
18 changes: 16 additions & 2 deletions implementations/rust/ockam/ockam_node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,18 @@ metrics = []
# message flows within Ockam apps.
debugger = ["ockam_core/debugger"]

storage = ["std", "time", "serde_json", "sqlx-etorreborre", "tokio-retry", "regex", "tempfile"]
storage = [
"std",
"time",
"serde_json",
"sqlx-etorreborre",
"sqlx-etorreborre-core",
"sqlx-etorreborre-sqlite",
"sqlx-etorreborre-postgres",
"tokio-retry",
"regex",
"tempfile",
]

[dependencies]
cfg-if = "1.0.0"
Expand All @@ -85,7 +96,10 @@ opentelemetry = { version = "0.23.0", features = ["logs", "metrics", "trace"], o
regex = { version = "1.10.5", default-features = false, optional = true }
serde = { version = "1.0", default-features = false, features = ["derive"] }
serde_json = { version = "1", optional = true }
sqlx-etorreborre = { version = "0.7.5", optional = true, features = ["postgres", "sqlite", "any", "migrate", "runtime-tokio"] }
sqlx-etorreborre = { version = "0.7.9", optional = true, features = ["postgres", "sqlite", "any", "migrate", "runtime-tokio"] }
sqlx-etorreborre-core = { version = "0.7.9", optional = true }
sqlx-etorreborre-postgres = { version = "0.7.9", optional = true }
sqlx-etorreborre-sqlite = { version = "0.7.9", optional = true }
tempfile = { version = "3.10.1", optional = true }
time = { version = "0.3.36", default-features = false, optional = true }
tokio = { version = "1.38", default-features = false, optional = true, features = ["sync", "time", "rt", "rt-multi-thread", "macros"] }
Expand Down
9 changes: 9 additions & 0 deletions implementations/rust/ockam/ockam_node/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,12 @@ pub use crate::tokio::runtime::{block_future, spawn};
/// in https://github.com/launchbadge/sqlx/pull/3298 are released
#[cfg(feature = "std")]
extern crate sqlx_etorreborre as sqlx;

#[cfg(feature = "std")]
extern crate sqlx_etorreborre_postgres as sqlx_postgres;

#[cfg(feature = "std")]
extern crate sqlx_etorreborre_core as sqlx_core;

#[cfg(feature = "std")]
extern crate sqlx_etorreborre_sqlite as sqlx_sqlite;
Original file line number Diff line number Diff line change
Expand Up @@ -459,40 +459,38 @@ pub mod tests {
/// This test checks that we can run a query and return an entity
#[tokio::test]
async fn test_query() -> Result<()> {
let db_file = NamedTempFile::new().unwrap();
let db_file = db_file.path();
let db = SqlxDatabase::create_sqlite(db_file).await?;

insert_identity(&db).await.unwrap();

// successful query
let result: Option<IdentifierRow> =
sqlx::query_as("SELECT identifier, name, vault_name, is_default FROM named_identity WHERE identifier = $1")
.bind("Ifa804b7fca12a19eed206ae180b5b576860ae651")
.fetch_optional(&*db.pool)
.await
.unwrap();
assert_eq!(
result,
Some(IdentifierRow {
identifier: "Ifa804b7fca12a19eed206ae180b5b576860ae651".into(),
name: "identity-1".to_string(),
vault_name: "vault-1".to_string(),
// This line tests the proper deserialization of a Boolean
// in SQLite where a Boolean maps to an INTEGER
is_default: Boolean::new(true),
})
);

// failed query
let result: Option<IdentifierRow> =
sqlx::query_as("SELECT identifier FROM named_identity WHERE identifier = $1")
.bind("x")
.fetch_optional(&*db.pool)
.await
.unwrap();
assert_eq!(result, None);
Ok(())
with_dbs(|db| async move {
insert_identity(&db).await.unwrap();

// successful query
let result: Option<IdentifierRow> =
sqlx::query_as("SELECT identifier, name, vault_name, is_default FROM named_identity WHERE identifier = $1")
.bind("Ifa804b7fca12a19eed206ae180b5b576860ae651")
.fetch_optional(&*db.pool)
.await
.unwrap();
assert_eq!(
result,
Some(IdentifierRow {
identifier: "Ifa804b7fca12a19eed206ae180b5b576860ae651".into(),
name: "identity-1".to_string(),
vault_name: "vault-1".to_string(),
// This line tests the proper deserialization of a Boolean
// in SQLite where a Boolean maps to an INTEGER
is_default: Boolean::new(true),
})
);

// failed query
let result: Option<IdentifierRow> =
sqlx::query_as("SELECT identifier FROM named_identity WHERE identifier = $1")
.bind("x")
.fetch_optional(&*db.pool)
.await
.unwrap();
assert_eq!(result, None);
Ok(())
}).await
}

/// HELPERS
Expand Down
2 changes: 1 addition & 1 deletion implementations/rust/ockam/ockam_vault/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ rand = { version = "0.8", default-features = false }
rand_pcg = { version = "0.3.1", default-features = false, optional = true }
serde = { version = "1", default-features = false, features = ["derive"] }
sha2 = { version = "0.10", default-features = false }
sqlx-etorreborre = { version = "0.7.5", optional = true }
sqlx-etorreborre = { version = "0.7.8", optional = true }
static_assertions = "1.1.0"
tracing = { version = "0.1", default-features = false }
x25519-dalek = { version = "2.0.1", default-features = false, features = ["precomputed-tables", "static_secrets", "zeroize"] }
Expand Down

0 comments on commit 0d1d35e

Please sign in to comment.