-
Notifications
You must be signed in to change notification settings - Fork 136
feat: add allow_missing in the struct_field #1416
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
base: main
Are you sure you want to change the base?
Conversation
67e73b9
to
820386a
Compare
See the following report for details: cargo semver-checks output
|
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.
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.
scylla-macros/src/lib.rs
Outdated
@@ -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))] |
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.
Missing space after #
- should be /// #[scylla(allow_missing)]
/// #[(scylla(allow_missing))] | |
/// #[scylla(allow_missing)] |
Copilot uses AI. Check for mistakes.
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.
done in the latest commit
scylla-macros/src/lib.rs
Outdated
@@ -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))] |
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.
Missing space after #
- should be /// #[scylla(allow_missing)]
/// #[(scylla(allow_missing))] | |
/// #[scylla(allow_missing)] |
Copilot uses AI. Check for mistakes.
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.
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
820386a
to
7091295
Compare
Fixes: #1146
it also make it migrating from #[sqlx(default)] to scylladb #[scylla(allow_missing)] smoothly
Pre-review checklist
./docs/source/
.Fixes:
annotations to PR description.