Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump sqlx #791

Merged
merged 2 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 53 additions & 34 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ semaphore = { git = "https://github.com/worldcoin/semaphore-rs", rev = "251e908d
] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
sqlx = { version = "0.7", features = [
sqlx = { version = "0.8.2", features = [
"runtime-tokio-native-tls",
"any",
"postgres",
Expand Down Expand Up @@ -98,6 +98,10 @@ testcontainers-modules = { version = "0.3.7", features = ["postgres"] }
tracing-subscriber = "0.3.11"
tracing-test = "0.2"

[patch.crates-io]
# Necessary until https://github.com/recmo/uint/pull/400 is merged and released
ruint = { git = "https://github.com/Dzejkop/uint", rev = "9a1a6019c519e9cd76add2494190d21fc5f574f9" }

[profile.release]
panic = "abort"
overflow-checks = true
Expand Down
17 changes: 11 additions & 6 deletions src/database/types.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use sqlx::database::{HasArguments, HasValueRef};
use sqlx::encode::IsNull;
use sqlx::error::BoxDynError;
use sqlx::prelude::FromRow;
use sqlx::{Decode, Encode, Postgres, Type};
use sqlx::{Database, Decode, Encode, Postgres, Type};

use crate::identity_tree::{Hash, UnprocessedStatus};
use crate::prover::identity::Identity;
Expand Down Expand Up @@ -92,7 +91,10 @@ pub struct BatchEntryData {
pub struct Commitments(pub Vec<Hash>);

impl Encode<'_, Postgres> for Commitments {
fn encode_by_ref(&self, buf: &mut <Postgres as HasArguments<'_>>::ArgumentBuffer) -> IsNull {
fn encode_by_ref(
&self,
buf: &mut <Postgres as Database>::ArgumentBuffer<'_>,
) -> Result<IsNull, BoxDynError> {
let commitments = &self
.0
.iter()
Expand All @@ -104,7 +106,7 @@ impl Encode<'_, Postgres> for Commitments {
}

impl Decode<'_, Postgres> for Commitments {
fn decode(value: <Postgres as HasValueRef<'_>>::ValueRef) -> Result<Self, BoxDynError> {
fn decode(value: <Postgres as Database>::ValueRef<'_>) -> Result<Self, BoxDynError> {
let value = <Vec<[u8; 32]> as Decode<Postgres>>::decode(value)?;

let res = value.iter().map(|&v| Hash::from_be_bytes(v)).collect();
Expand Down Expand Up @@ -133,7 +135,10 @@ impl From<Vec<Hash>> for Commitments {
pub struct LeafIndexes(pub Vec<usize>);

impl Encode<'_, Postgres> for LeafIndexes {
fn encode_by_ref(&self, buf: &mut <Postgres as HasArguments<'_>>::ArgumentBuffer) -> IsNull {
fn encode_by_ref(
&self,
buf: &mut <Postgres as Database>::ArgumentBuffer<'_>,
) -> Result<IsNull, BoxDynError> {
let commitments = &self
.0
.iter()
Expand All @@ -145,7 +150,7 @@ impl Encode<'_, Postgres> for LeafIndexes {
}

impl Decode<'_, Postgres> for LeafIndexes {
fn decode(value: <Postgres as HasValueRef<'_>>::ValueRef) -> Result<Self, BoxDynError> {
fn decode(value: <Postgres as Database>::ValueRef<'_>) -> Result<Self, BoxDynError> {
let value = <Vec<i64> as Decode<Postgres>>::decode(value)?;

let res = value.iter().map(|&v| v as usize).collect();
Expand Down
Loading
Loading