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

feat: implement FromCqlVal and SerializeValue for PrimitiveDatetime #1115

Closed
wants to merge 3 commits into from

Conversation

dracarys18
Copy link

Pre-review checklist

  • I have split my patch into logically separate commits.
  • All commit messages clearly explain what they change and why.
  • I added relevant tests for new features and bug fixes.
  • All commits compile, pass static checks and pass test.
  • PR description sums up the changes and reasons why they should be introduced.
  • I have provided docstrings for the public items that I want to introduce.
  • I have adjusted the documentation in ./docs/source/.
  • I added appropriate Fixes: annotations to PR description.

Copy link

github-actions bot commented Nov 6, 2024

cargo semver-checks detected some API incompatibilities in this PR.
Checked commit: 47c89d5

See the following report for details:

cargo semver-checks output
./scripts/semver-checks.sh --baseline-rev 64b4afcdb4286b21f6cc1acb55266d6607f250e0
+ cargo semver-checks -p scylla -p scylla-cql --baseline-rev 64b4afcdb4286b21f6cc1acb55266d6607f250e0
     Cloning 64b4afcdb4286b21f6cc1acb55266d6607f250e0
     Parsing scylla v0.14.0 (current)
      Parsed [  23.503s] (current)
     Parsing scylla v0.14.0 (baseline)
      Parsed [  22.710s] (baseline)
    Checking scylla v0.14.0 -> v0.14.0 (no change)
     Checked [   0.113s] 94 checks: 84 pass, 10 fail, 0 warn, 0 skip

--- failure auto_trait_impl_removed: auto trait no longer implemented ---

Description:
A public type has stopped implementing one or more auto traits. This can break downstream code that depends on the traits being implemented.
        ref: https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.36.0/src/lints/auto_trait_impl_removed.ron

Failed in:
  type UdtMetadataError is no longer UnwindSafe, in /home/runner/work/scylla-rust-driver/scylla-rust-driver/scylla/src/transport/errors.rs:484
  type UdtMetadataError is no longer RefUnwindSafe, in /home/runner/work/scylla-rust-driver/scylla-rust-driver/scylla/src/transport/errors.rs:484
  type SingleRowError is no longer UnwindSafe, in /home/runner/work/scylla-rust-driver/scylla-rust-driver/scylla/src/transport/query_result.rs:458
  type SingleRowError is no longer RefUnwindSafe, in /home/runner/work/scylla-rust-driver/scylla-rust-driver/scylla/src/transport/query_result.rs:458
  type MetadataError is no longer UnwindSafe, in /home/runner/work/scylla-rust-driver/scylla-rust-driver/scylla/src/transport/errors.rs:408
  type MetadataError is no longer RefUnwindSafe, in /home/runner/work/scylla-rust-driver/scylla-rust-driver/scylla/src/transport/errors.rs:408
  type FirstRowError is no longer UnwindSafe, in /home/runner/work/scylla-rust-driver/scylla-rust-driver/scylla/src/transport/query_result.rs:442
  type FirstRowError is no longer RefUnwindSafe, in /home/runner/work/scylla-rust-driver/scylla-rust-driver/scylla/src/transport/query_result.rs:442
  type TablesMetadataError is no longer UnwindSafe, in /home/runner/work/scylla-rust-driver/scylla-rust-driver/scylla/src/transport/errors.rs:497
  type TablesMetadataError is no longer RefUnwindSafe, in /home/runner/work/scylla-rust-driver/scylla-rust-driver/scylla/src/transport/errors.rs:497
  type KeyspacesMetadataError is no longer UnwindSafe, in /home/runner/work/scylla-rust-driver/scylla-rust-driver/scylla/src/transport/errors.rs:446
  type KeyspacesMetadataError is no longer RefUnwindSafe, in /home/runner/work/scylla-rust-driver/scylla-rust-driver/scylla/src/transport/errors.rs:446
  type ProtocolError is no longer UnwindSafe, in /home/runner/work/scylla-rust-driver/scylla-rust-driver/scylla/src/transport/errors.rs:279
  type ProtocolError is no longer RefUnwindSafe, in /home/runner/work/scylla-rust-driver/scylla-rust-driver/scylla/src/transport/errors.rs:279
  type TracingProtocolError is no longer UnwindSafe, in /home/runner/work/scylla-rust-driver/scylla-rust-driver/scylla/src/transport/errors.rs:363
  type TracingProtocolError is no longer RefUnwindSafe, in /home/runner/work/scylla-rust-driver/scylla-rust-driver/scylla/src/transport/errors.rs:363
  type ViewsMetadataError is no longer UnwindSafe, in /home/runner/work/scylla-rust-driver/scylla-rust-driver/scylla/src/transport/errors.rs:519
  type ViewsMetadataError is no longer RefUnwindSafe, in /home/runner/work/scylla-rust-driver/scylla-rust-driver/scylla/src/transport/errors.rs:519

--- failure derive_trait_impl_removed: built-in derived trait no longer implemented ---

Description:
A public type has stopped deriving one or more traits. This can break downstream code that depends on those types implementing those traits.
        ref: https://doc.rust-lang.org/reference/attributes/derive.html#derive
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.36.0/src/lints/derive_trait_impl_removed.ron

Failed in:
  type SingleRowError no longer derives PartialEq, in /home/runner/work/scylla-rust-driver/scylla-rust-driver/scylla/src/transport/query_result.rs:458
  type SingleRowError no longer derives Eq, in /home/runner/work/scylla-rust-driver/scylla-rust-driver/scylla/src/transport/query_result.rs:458
  type FirstRowError no longer derives Clone, in /home/runner/work/scylla-rust-driver/scylla-rust-driver/scylla/src/transport/query_result.rs:442
  type FirstRowError no longer derives PartialEq, in /home/runner/work/scylla-rust-driver/scylla-rust-driver/scylla/src/transport/query_result.rs:442
  type FirstRowError no longer derives Eq, in /home/runner/work/scylla-rust-driver/scylla-rust-driver/scylla/src/transport/query_result.rs:442

--- failure enum_missing: pub enum removed or renamed ---

Description:
A publicly-visible enum cannot be imported by its prior path. A `pub use` may have been removed, or the enum itself may have been renamed or removed entirely.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.36.0/src/lints/enum_missing.ron

Failed in:
  enum scylla::transport::query_result::SingleRowTypedError, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-64b4afcdb4286b21f6cc1acb55266d6607f250e0/7cd63be660774e034f17246d4d786d0cc0c76c91/scylla/src/transport/query_result.rs:245
  enum scylla::transport::query_result::FirstRowTypedError, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-64b4afcdb4286b21f6cc1acb55266d6607f250e0/7cd63be660774e034f17246d4d786d0cc0c76c91/scylla/src/transport/query_result.rs:199
  enum scylla::transport::query_result::MaybeFirstRowTypedError, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-64b4afcdb4286b21f6cc1acb55266d6607f250e0/7cd63be660774e034f17246d4d786d0cc0c76c91/scylla/src/transport/query_result.rs:217

--- failure enum_tuple_variant_changed_kind: An enum tuple variant changed kind ---

Description:
A public enum's exhaustive tuple variant has changed to a different kind of enum variant, breaking possible instantiations and patterns.
        ref: https://doc.rust-lang.org/reference/items/enumerations.html
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.36.0/src/lints/enum_tuple_variant_changed_kind.ron

Failed in:
  variant TracingProtocolError::TracesSessionNotRows in /home/runner/work/scylla-rust-driver/scylla-rust-driver/scylla/src/transport/errors.rs:366
  variant TracingProtocolError::TracesEventsNotRows in /home/runner/work/scylla-rust-driver/scylla-rust-driver/scylla/src/transport/errors.rs:378

--- failure enum_variant_added: enum variant added on exhaustive enum ---

Description:
A publicly-visible enum without #[non_exhaustive] has a new variant.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#enum-variant-new
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.36.0/src/lints/enum_variant_added.ron

Failed in:
  variant FirstRowError:TypeCheckFailed in /home/runner/work/scylla-rust-driver/scylla-rust-driver/scylla/src/transport/query_result.rs:449
  variant FirstRowError:DeserializationFailed in /home/runner/work/scylla-rust-driver/scylla-rust-driver/scylla/src/transport/query_result.rs:453
  variant SingleRowError:UnexpectedRowCount in /home/runner/work/scylla-rust-driver/scylla-rust-driver/scylla/src/transport/query_result.rs:461
  variant SingleRowError:TypeCheckFailed in /home/runner/work/scylla-rust-driver/scylla-rust-driver/scylla/src/transport/query_result.rs:465
  variant SingleRowError:DeserializationFailed in /home/runner/work/scylla-rust-driver/scylla-rust-driver/scylla/src/transport/query_result.rs:469

--- failure enum_variant_missing: pub enum variant removed or renamed ---

Description:
A publicly-visible enum has at least one variant that is no longer available under its prior name. It may have been renamed or removed entirely.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.36.0/src/lints/enum_variant_missing.ron

Failed in:
  variant SingleRowError::RowsExpected, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-64b4afcdb4286b21f6cc1acb55266d6607f250e0/7cd63be660774e034f17246d4d786d0cc0c76c91/scylla/src/transport/query_result.rs:237
  variant SingleRowError::BadNumberOfRows, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-64b4afcdb4286b21f6cc1acb55266d6607f250e0/7cd63be660774e034f17246d4d786d0cc0c76c91/scylla/src/transport/query_result.rs:241
  variant FirstRowError::RowsExpected, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-64b4afcdb4286b21f6cc1acb55266d6607f250e0/7cd63be660774e034f17246d4d786d0cc0c76c91/scylla/src/transport/query_result.rs:191

--- failure inherent_method_missing: pub method removed or renamed ---

Description:
A publicly-visible method or associated fn is no longer available under its prior name. It may have been renamed or removed entirely.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.36.0/src/lints/inherent_method_missing.ron

Failed in:
  QueryResult::rows_num, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-64b4afcdb4286b21f6cc1acb55266d6607f250e0/7cd63be660774e034f17246d4d786d0cc0c76c91/scylla/src/transport/query_result.rs:42
  QueryResult::rows, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-64b4afcdb4286b21f6cc1acb55266d6607f250e0/7cd63be660774e034f17246d4d786d0cc0c76c91/scylla/src/transport/query_result.rs:52
  QueryResult::rows_typed, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-64b4afcdb4286b21f6cc1acb55266d6607f250e0/7cd63be660774e034f17246d4d786d0cc0c76c91/scylla/src/transport/query_result.rs:62
  QueryResult::rows_or_empty, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-64b4afcdb4286b21f6cc1acb55266d6607f250e0/7cd63be660774e034f17246d4d786d0cc0c76c91/scylla/src/transport/query_result.rs:78
  QueryResult::rows_typed_or_empty, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-64b4afcdb4286b21f6cc1acb55266d6607f250e0/7cd63be660774e034f17246d4d786d0cc0c76c91/scylla/src/transport/query_result.rs:85
  QueryResult::first_row, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-64b4afcdb4286b21f6cc1acb55266d6607f250e0/7cd63be660774e034f17246d4d786d0cc0c76c91/scylla/src/transport/query_result.rs:91
  QueryResult::first_row_typed, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-64b4afcdb4286b21f6cc1acb55266d6607f250e0/7cd63be660774e034f17246d4d786d0cc0c76c91/scylla/src/transport/query_result.rs:100
  QueryResult::maybe_first_row, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-64b4afcdb4286b21f6cc1acb55266d6607f250e0/7cd63be660774e034f17246d4d786d0cc0c76c91/scylla/src/transport/query_result.rs:106
  QueryResult::maybe_first_row_typed, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-64b4afcdb4286b21f6cc1acb55266d6607f250e0/7cd63be660774e034f17246d4d786d0cc0c76c91/scylla/src/transport/query_result.rs:112
  QueryResult::single_row, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-64b4afcdb4286b21f6cc1acb55266d6607f250e0/7cd63be660774e034f17246d4d786d0cc0c76c91/scylla/src/transport/query_result.rs:123
  QueryResult::single_row_typed, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-64b4afcdb4286b21f6cc1acb55266d6607f250e0/7cd63be660774e034f17246d4d786d0cc0c76c91/scylla/src/transport/query_result.rs:135
  QueryResult::col_specs, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-64b4afcdb4286b21f6cc1acb55266d6607f250e0/7cd63be660774e034f17246d4d786d0cc0c76c91/scylla/src/transport/query_result.rs:141
  QueryResult::get_column_spec, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-64b4afcdb4286b21f6cc1acb55266d6607f250e0/7cd63be660774e034f17246d4d786d0cc0c76c91/scylla/src/transport/query_result.rs:150
  QueryResult::rows_num, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-64b4afcdb4286b21f6cc1acb55266d6607f250e0/7cd63be660774e034f17246d4d786d0cc0c76c91/scylla/src/transport/query_result.rs:42
  QueryResult::rows, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-64b4afcdb4286b21f6cc1acb55266d6607f250e0/7cd63be660774e034f17246d4d786d0cc0c76c91/scylla/src/transport/query_result.rs:52
  QueryResult::rows_typed, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-64b4afcdb4286b21f6cc1acb55266d6607f250e0/7cd63be660774e034f17246d4d786d0cc0c76c91/scylla/src/transport/query_result.rs:62
  QueryResult::rows_or_empty, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-64b4afcdb4286b21f6cc1acb55266d6607f250e0/7cd63be660774e034f17246d4d786d0cc0c76c91/scylla/src/transport/query_result.rs:78
  QueryResult::rows_typed_or_empty, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-64b4afcdb4286b21f6cc1acb55266d6607f250e0/7cd63be660774e034f17246d4d786d0cc0c76c91/scylla/src/transport/query_result.rs:85
  QueryResult::first_row, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-64b4afcdb4286b21f6cc1acb55266d6607f250e0/7cd63be660774e034f17246d4d786d0cc0c76c91/scylla/src/transport/query_result.rs:91
  QueryResult::first_row_typed, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-64b4afcdb4286b21f6cc1acb55266d6607f250e0/7cd63be660774e034f17246d4d786d0cc0c76c91/scylla/src/transport/query_result.rs:100
  QueryResult::maybe_first_row, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-64b4afcdb4286b21f6cc1acb55266d6607f250e0/7cd63be660774e034f17246d4d786d0cc0c76c91/scylla/src/transport/query_result.rs:106
  QueryResult::maybe_first_row_typed, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-64b4afcdb4286b21f6cc1acb55266d6607f250e0/7cd63be660774e034f17246d4d786d0cc0c76c91/scylla/src/transport/query_result.rs:112
  QueryResult::single_row, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-64b4afcdb4286b21f6cc1acb55266d6607f250e0/7cd63be660774e034f17246d4d786d0cc0c76c91/scylla/src/transport/query_result.rs:123
  QueryResult::single_row_typed, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-64b4afcdb4286b21f6cc1acb55266d6607f250e0/7cd63be660774e034f17246d4d786d0cc0c76c91/scylla/src/transport/query_result.rs:135
  QueryResult::col_specs, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-64b4afcdb4286b21f6cc1acb55266d6607f250e0/7cd63be660774e034f17246d4d786d0cc0c76c91/scylla/src/transport/query_result.rs:141
  QueryResult::get_column_spec, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-64b4afcdb4286b21f6cc1acb55266d6607f250e0/7cd63be660774e034f17246d4d786d0cc0c76c91/scylla/src/transport/query_result.rs:150

--- failure struct_missing: pub struct removed or renamed ---

Description:
A publicly-visible struct cannot be imported by its prior path. A `pub use` may have been removed, or the struct itself may have been renamed or removed entirely.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.36.0/src/lints/struct_missing.ron

Failed in:
  struct scylla::transport::session::Session, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-64b4afcdb4286b21f6cc1acb55266d6607f250e0/7cd63be660774e034f17246d4d786d0cc0c76c91/scylla/src/transport/session.rs:153
  struct scylla::Session, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-64b4afcdb4286b21f6cc1acb55266d6607f250e0/7cd63be660774e034f17246d4d786d0cc0c76c91/scylla/src/transport/session.rs:153
  struct scylla::transport::query_result::RowsExpectedError, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-64b4afcdb4286b21f6cc1acb55266d6607f250e0/7cd63be660774e034f17246d4d786d0cc0c76c91/scylla/src/transport/query_result.rs:169
  struct scylla::transport::iterator::TypedRowIterator, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-64b4afcdb4286b21f6cc1acb55266d6607f250e0/7cd63be660774e034f17246d4d786d0cc0c76c91/scylla/src/transport/iterator.rs:895
  struct scylla::transport::iterator::RowIterator, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-64b4afcdb4286b21f6cc1acb55266d6607f250e0/7cd63be660774e034f17246d4d786d0cc0c76c91/scylla/src/transport/iterator.rs:41
  struct scylla::CachingSession, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-64b4afcdb4286b21f6cc1acb55266d6607f250e0/7cd63be660774e034f17246d4d786d0cc0c76c91/scylla/src/transport/caching_session.rs:34
  struct scylla::transport::query_result::RowsNotExpectedError, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-64b4afcdb4286b21f6cc1acb55266d6607f250e0/7cd63be660774e034f17246d4d786d0cc0c76c91/scylla/src/transport/query_result.rs:182

--- failure struct_pub_field_missing: pub struct's pub field removed or renamed ---

Description:
A publicly-visible struct has at least one public field that is no longer available under its prior name. It may have been renamed or removed entirely.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.36.0/src/lints/struct_pub_field_missing.ron

Failed in:
  field rows of struct QueryResult, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-64b4afcdb4286b21f6cc1acb55266d6607f250e0/7cd63be660774e034f17246d4d786d0cc0c76c91/scylla/src/transport/query_result.rs:18
  field warnings of struct QueryResult, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-64b4afcdb4286b21f6cc1acb55266d6607f250e0/7cd63be660774e034f17246d4d786d0cc0c76c91/scylla/src/transport/query_result.rs:20
  field tracing_id of struct QueryResult, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-64b4afcdb4286b21f6cc1acb55266d6607f250e0/7cd63be660774e034f17246d4d786d0cc0c76c91/scylla/src/transport/query_result.rs:22
  field serialized_size of struct QueryResult, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-64b4afcdb4286b21f6cc1acb55266d6607f250e0/7cd63be660774e034f17246d4d786d0cc0c76c91/scylla/src/transport/query_result.rs:26
  field rows of struct QueryResult, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-64b4afcdb4286b21f6cc1acb55266d6607f250e0/7cd63be660774e034f17246d4d786d0cc0c76c91/scylla/src/transport/query_result.rs:18
  field warnings of struct QueryResult, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-64b4afcdb4286b21f6cc1acb55266d6607f250e0/7cd63be660774e034f17246d4d786d0cc0c76c91/scylla/src/transport/query_result.rs:20
  field tracing_id of struct QueryResult, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-64b4afcdb4286b21f6cc1acb55266d6607f250e0/7cd63be660774e034f17246d4d786d0cc0c76c91/scylla/src/transport/query_result.rs:22
  field serialized_size of struct QueryResult, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-64b4afcdb4286b21f6cc1acb55266d6607f250e0/7cd63be660774e034f17246d4d786d0cc0c76c91/scylla/src/transport/query_result.rs:26

--- failure struct_pub_field_now_doc_hidden: pub struct field is now #[doc(hidden)] ---

Description:
A pub field of a pub struct is now marked #[doc(hidden)] and is no longer part of the public API.
        ref: https://doc.rust-lang.org/rustdoc/write-documentation/the-doc-attribute.html#hidden
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.36.0/src/lints/struct_pub_field_now_doc_hidden.ron

Failed in:
  field QueryResult.warnings in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/scylla/src/transport/query_result.rs:137
  field QueryResult.tracing_id in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/scylla/src/transport/query_result.rs:137
  field QueryResult.warnings in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/scylla/src/transport/query_result.rs:137
  field QueryResult.tracing_id in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/scylla/src/transport/query_result.rs:137

     Summary semver requires new major version: 10 major and 0 minor checks failed
    Finished [  46.384s] scylla
     Parsing scylla-cql v0.3.0 (current)
      Parsed [  11.310s] (current)
     Parsing scylla-cql v0.3.0 (baseline)
      Parsed [  10.065s] (baseline)
    Checking scylla-cql v0.3.0 -> v0.3.0 (no change)
     Checked [   0.106s] 94 checks: 93 pass, 1 fail, 0 warn, 0 skip

--- failure struct_missing: pub struct removed or renamed ---

Description:
A publicly-visible struct cannot be imported by its prior path. A `pub use` may have been removed, or the struct itself may have been renamed or removed entirely.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.36.0/src/lints/struct_missing.ron

Failed in:
  struct scylla_cql::frame::response::result::Rows, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-64b4afcdb4286b21f6cc1acb55266d6607f250e0/7cd63be660774e034f17246d4d786d0cc0c76c91/scylla-cql/src/frame/response/result.rs:588
  struct scylla_cql::types::deserialize::result::RowIterator, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-64b4afcdb4286b21f6cc1acb55266d6607f250e0/7cd63be660774e034f17246d4d786d0cc0c76c91/scylla-cql/src/types/deserialize/result.rs:9

     Summary semver requires new major version: 1 major and 0 minor checks failed
    Finished [  21.529s] scylla-cql
make: *** [Makefile:61: semver-rev] Error 1

@wprzytula
Copy link
Collaborator

Please note that FromCqlVal is going to be deprecated beginning with the next release. Please implement DeserializeValue, too.

@dracarys18
Copy link
Author

Done @wprzytula

@github-actions github-actions bot added the semver-checks-breaking cargo-semver-checks reports that this PR introduces breaking API changes label Nov 13, 2024
wprzytula
wprzytula previously approved these changes Nov 13, 2024
@wprzytula
Copy link
Collaborator

Could you add relevant unit tests, too? Just to be sure the implementation is correct.

@dracarys18
Copy link
Author

Could you add relevant unit tests, too? Just to be sure the implementation is correct.

Do we need test cases for it though? It uses already existing implementation of Serialization and deserialization

@wprzytula
Copy link
Collaborator

Could you add relevant unit tests, too? Just to be sure the implementation is correct.

Do we need test cases for it though? It uses already existing implementation of Serialization and deserialization

I agree that the ser/de part of this PR is minimal. However, we are still adding a new type that wasn't tested in any way before and it's a good habit to have at least one test: ser/de equivalence, on one concrete value of the type.

@wprzytula wprzytula changed the title feat: implment FromCqlVal and SerializeValue for PrimitiveDatetime feat: implement FromCqlVal and SerializeValue for PrimitiveDatetime Nov 13, 2024
@dracarys18
Copy link
Author

@wprzytula Sure added the test you can check, I can see assert_ser_de_identity serializes the value to the type and de-serializes it back and checks if they match. Which should be enough right?

@Lorak-mmk
Copy link
Collaborator

Looks good to me, but I'm don't feel that confident when working with date / time.

@piodul Do you know if there is any reason to not have such implementation?
Also pinging @Anfid because you implemented #745

@Anfid
Copy link
Contributor

Anfid commented Nov 13, 2024

When working on my implementation, I referenced this doc a lot
https://opensource.docs.scylladb.com/stable/cql/types.html#timestamps

What it says about timestamps without timezone is that they're assumed to be in the local timezone of the coordinating ScyllaDB node, while the implementation in this PR uses UTC. My hesitation is that it may result in confusing behavior if some other library is used for a different server, for example. The doc also recommends always explicitly adding timestamps to avoid this exact potential ambiguity in implementations, as far as I understand.

@dracarys18
Copy link
Author

I can use the UtcOffset::current_local_offset() to get the current system time through syscall, let me know if you expect this behavior I will change it in the PR

@Anfid
Copy link
Contributor

Anfid commented Nov 13, 2024

I'm not a frequent contributor, I just happened to make that PR, so please correct me if I'm wrong. The timezone on a coordinating ScyllaDB node may not match the timezone on the machine where this current code is executed, so the UtcOffset::current_local_offset() won't match the documented behavior.

Unfortunately, I myself am not sure how to address this problem and if it's a major problem at all, or just a niche case that should be documented. I'd prefer some input from other contributors on that matter.

@dracarys18
Copy link
Author

I don't think it's ever possible for a client to know the server's system time. I think when they say local time they must mean the client local time. Because if the client is providing the CQLTimestamp input to the database the client must be providing the client's local time.

I am also not sure how the server would get the local time, Let's say if I have a table and I have default value set on my table schema for a field with type Timestamp. Every time I insert a data the server would take local time and if the nodes are in different regions this local time would vary everywhere. So I am not entirely sure.

@dracarys18
Copy link
Author

dracarys18 commented Nov 14, 2024

Hey @Anfid @wprzytula , I also checked the TryInto implementation from OffsetDatetime to CqlTimeStamp, You are using the function from_unix_timestamp_nanos which inherently assumes the offset is UTC. I don't the time is interpreted as client's local time even in the previous implementation.
Reference to the function code

@Anfid
Copy link
Contributor

Anfid commented Nov 14, 2024

@dracarys18 This is reasonable for unix timestamp, as it's specifically defined to be in UTC, and then you get local time by adding timezone offset information to it.

@dracarys18
Copy link
Author

@Anfid Correct me if I am wrong, that's the same behavior followed in this PR right?

@Anfid
Copy link
Contributor

Anfid commented Nov 14, 2024

@dracarys18 not really, as PrimitiveDateTime specifically describes time completely stripped of any timezone information. It could be some local time in any timezone, not just UTC. Unix timestamp, however, is defined to always be relative to UTC regardless of your local timezone. For that same reason there aren't any impl From<PrimitiveDateTime> for OffsetDateTime in the time crate, because just blindly assuming UTC may lead to subtle issues.

@Anfid
Copy link
Contributor

Anfid commented Nov 14, 2024

In general, you can break timestamps into the following categories:

  1. Describing the exact moment in time
    These timestamps describe the moment, but not the way it should be displayed. CQL time and unix timestamps fall into this category. Both are always recorded in UTC timezone.
  2. Describing the exact moment in time + how it should be displayed to the user
    These timestamps contain both timestamp information and the timezone offset and they're intended to be displayed to the user in some way. Examples are OffsetDateTime in time. Since time doesn't have any type to fit category 1, OffsetDateTime is also often used to describe the exact moment in time.
  3. Describing the local time
    These ones have no information about the moment when something happened and are only useful to display something to the user or for more flexible interactions with other programs that don't have timezone support. For example, some software developed for local markets may only accept local time in the timezone of that country, using UTC there would lead to bugs. Examples of these types are PrimitiveDateTime in time and, if I'm not mistaken, SQL timestamps.

@dracarys18
Copy link
Author

@Anfid I agree that PrimitiveDateTime wont have the timezone context, Here for this use case we are converting a PrimitiveDateTime to a Unix Timestamp which will always be UTC. And while converting it from Timestamp to PrimitiveDatetime we will have to convert it into OffsetDateTime and then PrimitiveDateTime

@Anfid
Copy link
Contributor

Anfid commented Nov 14, 2024

The point of my message above is precisely about how I don't consider implicit conversion of PrimitiveDateTime to unix timestamp, CQL timestamp or OffsetDateTime a good idea. Even more so if this behavior is not explicitly documented.

To illustrate a potential example of problems that it might cause, let's think about some hypothetical calendar or reminders app. When user creates an event, it contains date and time info, but no timezone. If the developer forgets to add timezone info manually and writes a PrimitiveDateTime to the DB, after this PR it will not result in compile error. The event would be recorded, but it would have implicit UTC timezone. If the developer then fetches events as OffsetDateTime and compares them to OffsetDateTime::now_utc(), this may result in sending events at an incorrect time.

An even more problematic example might occur of there's a mix of events serialized from PrimitiveDateTime and OffsetDateTime in one table, where they would just be impossible to compare, work with and fix after the fact.

Ideally I personally prefer types to support the development process as much as possible. However if others have different opinions on that matter, I wouldn't start a war over it :)

@dracarys18
Copy link
Author

@wprzytula @Lorak-mmk Can we please merge this?

@Lorak-mmk
Copy link
Collaborator

Lorak-mmk commented Nov 18, 2024

When working on my implementation, I referenced this doc a lot https://opensource.docs.scylladb.com/stable/cql/types.html#timestamps

What it says about timestamps without timezone is that they're assumed to be in the local timezone of the coordinating ScyllaDB node, while the implementation in this PR uses UTC. My hesitation is that it may result in confusing behavior if some other library is used for a different server, for example. The doc also recommends always explicitly adding timestamps to avoid this exact potential ambiguity in implementations, as far as I understand.

The doc describes textual format, used e.g. when querying manually through clqsh. Binary cql format uses unix epoch as a reference point, and thus utc:
https://github.com/apache/cassandra/blob/f5793af48f3381234f48619d2568f6b64cefbf14/doc/native_protocol_v4.spec#L946-L950

I'm not a frequent contributor, I just happened to make that PR, so please correct me if I'm wrong. The timezone on a coordinating ScyllaDB node may not match the timezone on the machine where this current code is executed, so the UtcOffset::current_local_offset() won't match the documented behavior.

This is true, but not really relevant because of what I wrote above.

I don't think it's ever possible for a client to know the server's system time. I think when they say local time they must mean the client local time. Because if the client is providing the CQLTimestamp input to the database the client must be providing the client's local time.

I am also not sure how the server would get the local time, Let's say if I have a table and I have default value set on my table schema for a field with type Timestamp. Every time I insert a data the server would take local time and if the nodes are in different regions this local time would vary everywhere. So I am not entirely sure.

The docs do mean coordinator local time, and not client local time. In the case you are discussing, server gets a string with time, without timezone. Server doesn't know client's timezone, so it uses its own. Why it uses coordinator local time instead of utc? No idea, probably C* did it that way so Scylla had to follow.
Again, this is totally irrelevant for this PR because this is textual CQL syntax and not binary protocol.

@wprzytula @Lorak-mmk Can we please merge this?

The comments from @Anfid ( #1115 (comment) #1115 (comment) #1115 (comment) ) convinced me that we should not add this implementation.
PrimitiveDateTime has no information about timezone, so it may have any timezone.
Inserting it into DB requires using UTC as its timezone (.assume_utc() call in the PR), but there is no way to know if this assumption is correct.
Selecting it from DB, while not strictly incorrect like inserting, loses information (because from UTC time in DB you got no-timezone time), so is a potential for bugs.

@Lorak-mmk Lorak-mmk closed this Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/deserialization semver-checks-breaking cargo-semver-checks reports that this PR introduces breaking API changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants