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

Don't return error on unexpected UDT field in SerializeCql macro #885

Merged
merged 2 commits into from
Dec 18, 2023

Conversation

Lorak-mmk
Copy link
Collaborator

In order to properly support ALTERing UDTs in database, code that serializes UDT shouldn't return error when there is column in UDT that is not present in Rust struct.
This PR changes the default behavior like this, and adds an force_exact_match attribute to opt-in to previous behavior.

CQL specification says:

  A UDT value will generally have one value
  for each field of the type it represents, but it is allowed to have less values than
  the type has fields.

so I decided to not send anything in place of missing fields rather than send e.g. NULLs.

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.

@Lorak-mmk Lorak-mmk requested a review from piodul December 18, 2023 02:00
scylla-cql/src/macros.rs Show resolved Hide resolved
scylla-cql/src/macros.rs Show resolved Hide resolved
scylla-cql/src/types/serialize/value.rs Show resolved Hide resolved
scylla-cql/src/types/serialize/value.rs Show resolved Hide resolved
@Lorak-mmk Lorak-mmk force-pushed the more_lenient_serialize_macros branch from ea2b506 to bc2200b Compare December 18, 2023 16:38
This commit changes default behavior of SerializeCql: now it doesn't
return error if there is additional field in UDT, not present in Rust
struct. This is to support adding fields to UDT in database.

New attribute, called `force_exact_match`, is added to opt-in to
previous behavior.

Documentation is adjusted, and failing test fragments are removed.
This commit adds tests for new behavior of SerializeCql - ignoring
unknown UDT fields.
It also adds tests for new attribute (`force_exact_match`).
@Lorak-mmk Lorak-mmk force-pushed the more_lenient_serialize_macros branch from bc2200b to 77fb6e2 Compare December 18, 2023 16:49
@Lorak-mmk Lorak-mmk requested a review from piodul December 18, 2023 16:49
@piodul piodul merged commit a0eaff0 into scylladb:main Dec 18, 2023
8 checks passed
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

Successfully merging this pull request may close these issues.

2 participants