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

time types panic on overflow #1171

Open
allan2 opened this issue Aug 15, 2024 · 0 comments
Open

time types panic on overflow #1171

allan2 opened this issue Aug 15, 2024 · 0 comments

Comments

@allan2
Copy link
Contributor

allan2 commented Aug 15, 2024

When constructing time types using out-of-range values, panic occurs.
This affects most of the FromSql and ToSql implementations for time 0.2 and 0.3.

let row = client.query_one("SELECT 'infinity'::timestamp", &[])?;
let res = row.try_get::<_, time::PrimitiveDateTime>(0);  // this panics

Minimal example here --> allan2/postrgres-time-overflow

The fix is to use fallible operations like checked_add and try_from.
An infinity test like test_special_params_without_wrapper should also be added for time. [1].

I have a PR in the works but I will wait for #1164 and #1170 first.

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

No branches or pull requests

1 participant