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

Fix transction rollback on Future drop #1121

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

wquark
Copy link

@wquark wquark commented Mar 20, 2024

PR for #1120. Also rollsback the savepoint (found while implementing this).

@sfackler
Copy link
Owner

Looks good to me other than the one nit!

@sfackler
Copy link
Owner

Looks like it needs a cargo fmt, and this should fix the chrono deprecation warning:

diff --git a/postgres-types/src/chrono_04.rs b/postgres-types/src/chrono_04.rs
index d599bde0..64166309 100644
--- a/postgres-types/src/chrono_04.rs
+++ b/postgres-types/src/chrono_04.rs
@@ -111,9 +111,10 @@ impl ToSql for DateTime<FixedOffset> {
 impl<'a> FromSql<'a> for NaiveDate {
     fn from_sql(_: &Type, raw: &[u8]) -> Result<NaiveDate, Box<dyn Error + Sync + Send>> {
         let jd = types::date_from_sql(raw)?;
+        let jd = Duration::try_days(jd)?;
         base()
             .date()
-            .checked_add_signed(Duration::days(i64::from(jd)))
+            .checked_add_signed(jd)
             .ok_or_else(|| "value too large to decode".into())
     }

- fixes drop of `Future` after synchronous message send but before
  `Transaction` object creation
- follow-on to
  sfackler@f6189a9
  for `TransactionBuilder` and savepoint `Transaction::transaction`
  creation
- use non-deprecated `Duration::try_days` method
- remove redundant top-level `rand` import
@wquark
Copy link
Author

wquark commented Mar 22, 2024

Ran cargo fmt and fixed warnings. Left the warning fixes in a separate commit since they seemed unrelated.

@wquark
Copy link
Author

wquark commented Mar 26, 2024

Hey @sfackler, would be great to get this pushed forward so we can remove our patched dependencies. Let me know if there are other blockers, thanks.

@wquark
Copy link
Author

wquark commented Apr 8, 2024

@sfackler another bump on merging this PR. Any other blockers?

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.

None yet

2 participants