-
Notifications
You must be signed in to change notification settings - Fork 111
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
Deal with chrono deprecations #951
Conversation
3893ba6
to
0058d93
Compare
Chrono deprecated several method in 0.4.35 / 0.4.34 - chrono::Duration::days -> chrono::Duration::try_days New method was introduced in 0.4.33, so quite recently. This requires us to bump minimum chrono version. - NaiveDateTime::from_timestamp_opt -> DateTime::from_timestamp This requires some other changes, because of the switch from NaiveDateTime to DateTime. - NaiveDateTime::timestamp_millis -> .and_utc().timestamp_millis() I also added a comment explaining the implementation of CqlValueDisplayer and why it doesn't use existing `impl TryInto<NaiveDate> for CqlDate`.
0058d93
to
8648c3b
Compare
New APIs were added in 0.4.32, not 0.4.33 - updated the PR accordingly after verifying that it works after |
// This is basically a copy of the code used in `impl TryInto<NaiveDate> for CqlDate` impl | ||
// in scylla-cql. We can't call this impl because it is behind chrono feature in scylla-cql. | ||
|
||
// date_days is u32 then converted to i64 then we subtract 2^31; | ||
// Max value is 2^31, min value is -2^31. Both values can safely fit in chrono::Duration, this call won't panic |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we anyway use chrono
in scylla
unconditionally, why we even put it under feature in scylla_cql
? What benefit could one have from disabling chrono
in scylla_cql
when it's still required in scylla
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe less code generated for scylla-cql?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be a very small gain compared to complexity added. Especially that, as you can see, we handle CqlDate
with chrono
anyway.
Tests doesn't serialize NaivedateTime, it serializes DateTime. It's not possible for it to serialize NaiveDateTime,as there is no such serialization implementation. Rename the test to reflect reality.
Chrono deprecated several method in 0.4.35 / 0.4.34
chrono::Duration::days -> chrono::Duration::try_days New method was introduced in 0.4.33, so quite recently. This requires us to bump minimum chrono version.
NaiveDateTime::from_timestamp_opt -> DateTime::from_timestamp This requires some other changes, because of the switch from NaiveDateTime to DateTime.
NaiveDateTime::timestamp_millis -> .and_utc().timestamp_millis()
I also added a comment explaining the implementation of CqlValueDisplayer and why it doesn't use existing
impl TryInto<NaiveDate> for CqlDate
.Fixes: #950
Pre-review checklist
./docs/source/
.Fixes:
annotations to PR description.