Skip to content

Conversation

@taslimmuhammed
Copy link
Contributor

Fixes #273
Sorry for the delay, I have tested the code[query creation part] by creating a similar table but not in the entire project, if possible please test it on your environment.

Copy link
Contributor

@gusinacio gusinacio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, first of all thanks for the contribution! From my point of view, this all makes sense and it should work properly.

One key point is that this approach misses sqlx greatest feature which is compile time checks. This is really important in case someone changes the code in the future so we know that it compiles to a valid sql.

Could you rewrite that using sqlx macros for compile-time checks?

@gusinacio
Copy link
Contributor

gusinacio commented Sep 24, 2024

You can find an example of how to do that using this as an example.

sqlx::query!(
r#"INSERT INTO scalar_tap_receipts (
signer_address,
signature,
allocation_id,
timestamp_ns,
nonce,
value
) SELECT * FROM UNNEST(
$1::CHAR(40)[],
$2::BYTEA[],
$3::CHAR(40)[],
$4::NUMERIC(20)[],
$5::NUMERIC(20)[],
$6::NUMERIC(40)[]
)"#,
&signers,
&signatures,
&allocation_ids,
&timestamps,
&nonces,
&values,
)

@taslimmuhammed
Copy link
Contributor Author

Thanks for the review, I'll try using macros

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feat.Req] Bulk insert of failed receipts

2 participants