Skip to content

Conversation

Xyedo
Copy link

@Xyedo Xyedo commented Aug 4, 2025

Fixes: #1146
it also make it migrating from #[sqlx(default)] to scylladb #[scylla(allow_missing)] smoothly

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.

@Xyedo Xyedo force-pushed the partial-DeserializeValue branch from 67e73b9 to 820386a Compare August 4, 2025 10:34
@github-actions github-actions bot added the semver-checks-breaking cargo-semver-checks reports that this PR introduces breaking API changes label Aug 4, 2025
Copy link

github-actions bot commented Aug 4, 2025

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

See the following report for details:

cargo semver-checks output
./scripts/semver-checks.sh --baseline-rev 3da897d6e81e785c9be145da47f31248c33a4f30
+ cargo semver-checks -p scylla -p scylla-cql --baseline-rev 3da897d6e81e785c9be145da47f31248c33a4f30
     Cloning 3da897d6e81e785c9be145da47f31248c33a4f30
    Building scylla v1.3.1 (current)
       Built [  43.126s] (current)
     Parsing scylla v1.3.1 (current)
      Parsed [   0.108s] (current)
    Building scylla v1.3.1 (baseline)
error: running cargo-doc on crate 'scylla' failed with output:
-----
   Compiling libc v0.2.175
   Compiling proc-macro2 v1.0.101
   Compiling unicode-ident v1.0.18
   Compiling shlex v1.3.0
   Compiling autocfg v1.5.0
    Checking cfg-if v1.0.3
   Compiling dunce v1.0.5
   Compiling fs_extra v1.3.0
   Compiling num-traits v0.2.19
   Compiling getrandom v0.3.3
   Compiling quote v1.0.40
    Checking pin-project-lite v0.2.16
   Compiling syn v2.0.106
   Compiling jobserver v0.1.34
   Compiling pkg-config v0.3.32
    Checking zeroize v1.8.1
   Compiling cc v1.2.34
    Checking once_cell v1.21.3
   Compiling vcpkg v0.2.15
   Compiling cmake v0.1.54
   Compiling aws-lc-rs v1.13.3
   Compiling fnv v1.0.7
   Compiling strsim v0.11.1
   Compiling ident_case v1.0.1
   Compiling zerocopy v0.8.26
    Checking num-integer v0.1.46
    Checking mio v1.0.4
   Compiling aws-lc-sys v0.30.0
   Compiling openssl-sys v0.9.109
    Checking socket2 v0.6.0
    Checking futures-sink v0.3.31
    Checking bytes v1.10.1
   Compiling libm v0.2.15
    Checking futures-core v0.3.31
    Checking futures-channel v0.3.31
    Checking rand_core v0.9.3
    Checking rustls-pki-types v1.12.0
   Compiling lock_api v0.4.13
   Compiling num-bigint v0.3.3
   Compiling synstructure v0.13.2
   Compiling darling_core v0.20.11
   Compiling bigdecimal v0.4.8
   Compiling parking_lot_core v0.9.11
   Compiling rustls v0.23.31
    Checking futures-task v0.3.31
    Checking slab v0.4.11
    Checking untrusted v0.9.0
   Compiling snap v1.1.1
    Checking foreign-types-shared v0.1.1
   Compiling crossbeam-utils v0.8.21
    Checking powerfmt v0.2.0
    Checking futures-io v0.3.31
   Compiling tokio-macros v2.5.0
   Compiling zerofrom-derive v0.1.6
    Checking tokio v1.47.1
   Compiling darling_macro v0.20.11
   Compiling futures-macro v0.3.31
   Compiling thiserror v1.0.69
    Checking pin-utils v0.1.0
    Checking memchr v2.7.5
   Compiling openssl v0.10.73
   Compiling thiserror v2.0.16
    Checking futures-util v0.3.31
   Compiling darling v0.20.11
    Checking zerofrom v0.1.6
   Compiling openssl-macros v0.1.1
   Compiling yoke-derive v0.8.0
   Compiling thiserror-impl v1.0.69
   Compiling thiserror-impl v2.0.16
    Checking deranged v0.5.3
    Checking foreign-types v0.3.2
    Checking ppv-lite86 v0.2.21
    Checking num-bigint v0.4.6
    Checking subtle v2.6.1
    Checking bitflags v2.9.3
    Checking smallvec v1.15.1
    Checking either v1.15.0
    Checking num-conv v0.1.0
    Checking twox-hash v2.1.1
    Checking time-core v0.1.5
    Checking log v0.4.27
    Checking scopeguard v1.2.0
    Checking stable_deref_trait v1.2.0
   Compiling tokio-openssl v0.6.5
    Checking iana-time-zone v0.1.63
    Checking chrono v0.4.41
    Checking yoke v0.8.0
    Checking time v0.3.42
    Checking lz4_flex v0.11.5
    Checking itertools v0.14.0
    Checking rand_chacha v0.9.0
    Checking futures-executor v0.3.31
   Compiling scylla-macros v1.3.1 (/home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-3da897d6e81e785c9be145da47f31248c33a4f30/c3ed706bfaabbfdac8a0ac777c681ed8709c2256/scylla-macros)
   Compiling tracing-attributes v0.1.30
    Checking uuid v1.18.0
    Checking tracing-core v0.1.34
    Checking secrecy v0.8.0
    Checking equivalent v1.0.2
    Checking byteorder v1.5.0
    Checking allocator-api2 v0.2.21
    Checking hashbrown v0.14.5
    Checking foldhash v0.1.5
    Checking hashbrown v0.15.5
    Checking dashmap v6.1.0
    Checking scylla-cql v1.3.1 (/home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-3da897d6e81e785c9be145da47f31248c33a4f30/c3ed706bfaabbfdac8a0ac777c681ed8709c2256/scylla-cql)
    Checking tracing v0.1.41
    Checking futures v0.3.31
    Checking histogram v0.11.3
    Checking rand v0.9.2
   Compiling async-trait v0.1.89
    Checking rand_pcg v0.9.0
    Checking socket2 v0.5.10
    Checking arc-swap v1.7.1
    Checking rustls-webpki v0.103.4
    Checking tokio-rustls v0.26.2
 Documenting scylla v1.3.1 (/home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-3da897d6e81e785c9be145da47f31248c33a4f30/c3ed706bfaabbfdac8a0ac777c681ed8709c2256/scylla)
�[38;5;9merror: couldn't read `/home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-3da897d6e81e785c9be145da47f31248c33a4f30/c3ed706bfaabbfdac8a0ac777c681ed8709c2256/scylla/src/deserialize/README.md`: No such file or directory (os error 2)
   �[38;5;12m--> /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-3da897d6e81e785c9be145da47f31248c33a4f30/c3ed706bfaabbfdac8a0ac777c681ed8709c2256/scylla/src/lib.rs:203:14
    �[38;5;12m|
�[38;5;12m203 �[38;5;12m|     #![doc = include_str!("deserialize/README.md")]
    �[38;5;12m|              �[38;5;9m^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: could not document `scylla`

-----

error: failed to build rustdoc for crate scylla v1.3.1
note: this is usually due to a compilation error in the crate,
      and is unlikely to be a bug in cargo-semver-checks
note: the following command can be used to reproduce the compilation error:
      cargo new --lib example &&
          cd example &&
          echo '[workspace]' >> Cargo.toml &&
          cargo add --path /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-3da897d6e81e785c9be145da47f31248c33a4f30/c3ed706bfaabbfdac8a0ac777c681ed8709c2256/scylla --features bigdecimal-04,chrono-04,default,full-serialization,metrics,num-bigint-03,num-bigint-04,openssl-010,rustls-023,secrecy-08,time-03 &&
          cargo check

    Building scylla-cql v1.3.1 (current)
       Built [  10.534s] (current)
     Parsing scylla-cql v1.3.1 (current)
      Parsed [   0.037s] (current)
    Building scylla-cql v1.3.1 (baseline)
       Built [  10.511s] (baseline)
     Parsing scylla-cql v1.3.1 (baseline)
      Parsed [   0.037s] (baseline)
    Checking scylla-cql v1.3.1 -> v1.3.1 (no change; assume patch)
     Checked [   0.338s] 165 checks: 165 pass, 13 skip
     Summary no semver update required
    Finished [  22.259s] scylla-cql
error: aborting due to failure to build rustdoc for crate scylla v1.3.1

Stack backtrace:
   0: anyhow::error::<impl anyhow::Error>::msg
   1: anyhow::__private::format_err
   2: cargo_semver_checks::data_generation::generate::generate_rustdoc
   3: cargo_semver_checks::data_generation::request::CrateDataRequest::resolve
   4: cargo_semver_checks::rustdoc_gen::StatefulRustdocGenerator<cargo_semver_checks::rustdoc_gen::ReadyState>::load_rustdoc
   5: cargo_semver_checks::Check::check_release
   6: cargo_semver_checks::exit_on_error
   7: cargo_semver_checks::main
   8: std::sys::backtrace::__rust_begin_short_backtrace
   9: main
make: *** [Makefile:73: semver-rev] Error 1

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds an allow_missing attribute to struct fields for both row and value deserialization, allowing fields to be initialized with Default::default() when missing from the database instead of failing. This feature provides compatibility with sqlx's #[sqlx(default)] attribute for smoother migration to scylla-rust-driver.

  • Implements #[scylla(allow_missing)] attribute for both struct-level and field-level usage
  • Adds support for the attribute in both row and value deserialization contexts
  • Includes comprehensive test coverage for the new functionality

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
scylla-macros/src/lib.rs Adds documentation for the new allow_missing attribute
scylla-macros/src/serialize/value.rs Adds ignored allow_missing attribute parsing for value serialization
scylla-macros/src/serialize/row.rs Adds ignored allow_missing attribute parsing for row serialization
scylla-macros/src/deserialize/value.rs Implements allow_missing logic for value deserialization
scylla-macros/src/deserialize/row.rs Implements allow_missing logic for row deserialization
scylla/tests/integration/macros/hygiene.rs Adds hygiene tests for the new attribute
scylla-cql/src/deserialize/row_tests.rs Adds comprehensive tests for allow_missing functionality

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@@ -378,6 +378,11 @@ mod deserialize;
/// column into the first field, second column into the second field and so on.
/// It will still still verify that the column types and field types match.
///
/// #[(scylla(allow_missing))]
Copy link
Preview

Copilot AI Aug 13, 2025

Choose a reason for hiding this comment

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

Missing space after # - should be /// #[scylla(allow_missing)]

Suggested change
/// #[(scylla(allow_missing))]
/// #[scylla(allow_missing)]

Copilot uses AI. Check for mistakes.

Copy link
Author

@Xyedo Xyedo Sep 1, 2025

Choose a reason for hiding this comment

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

done in the latest commit

@@ -395,6 +400,11 @@ mod deserialize;
/// By default, the generated implementation will try to match the Rust field
/// to a column with the same name. This attribute allows to match to a column
/// with provided name.
///
/// #[(scylla(allow_missing))]
Copy link
Preview

Copilot AI Aug 13, 2025

Choose a reason for hiding this comment

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

Missing space after # - should be /// #[scylla(allow_missing)]

Suggested change
/// #[(scylla(allow_missing))]
/// #[scylla(allow_missing)]

Copilot uses AI. Check for mistakes.

Copy link
Author

Choose a reason for hiding this comment

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

done in the latest commit

add allow_missing with macro DeserializeRow,
add allow_missing in the struct attributes to handle partial deserialization and
make it easier instead of defining on each struct field
@Xyedo Xyedo force-pushed the partial-DeserializeValue branch from 820386a to 7091295 Compare September 1, 2025 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

How to do partial deserialization
1 participant