-
Notifications
You must be signed in to change notification settings - Fork 114
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
Remove legacy serialization and deserialization APIs #1184
base: main
Are you sure you want to change the base?
Conversation
e2ee1fe
to
6542a09
Compare
See the following report for details: cargo semver-checks output
|
d0b0da8
to
52cc5c5
Compare
This error is not deprecated, this directive is clearly a leftover or mistake. It is probably caused by some merge, because I was not able to find the commit that caused this.
It was a leftover from the PR that migrated this test to new APIs.
It is no longer necessary after the PR that refactored this error.
555e7b1
to
9f20778
Compare
👍, let's move |
# Setup Sphinx | ||
def setup(sphinx): | ||
lexers['rust'] = RustLexer() | ||
lexers['rust,ignore'] = RustLexer() | ||
lexers['toml'] = TOMLLexer() |
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.
📝 I wasn't aware that there is such a place where we can configure how ```<lang> is parsed.
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.
Me neither. In general I don't know much abut how Scylla documentation building works.
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.
Mainly some nits. I want to make sure that all removed tests for legacy API have their equivalent for new API (if applicable).
When it comes to the value
module. I think that we should definitely make it a top-level module. Notice that deserialization tests are placed in deserialize::value_tests
, while serialization tests are in frame::value_tests
. So my proposition is to:
- move
value.rs
to top-level (src/value.rs
) - move
frame::value_tests.rs
toserialize::value_tests.rs
fn struct_from_row_wrong_size() { | ||
#[derive(FromRow, PartialEq, Eq, Debug)] | ||
struct MyRow { | ||
a: i32, | ||
b: Option<String>, | ||
c: Option<Vec<i32>>, | ||
} | ||
|
||
let too_short_row = Row { | ||
columns: vec![Some(CqlValue::Int(16)), None], | ||
}; | ||
|
||
let too_large_row = Row { | ||
columns: vec![ | ||
Some(CqlValue::Int(16)), | ||
None, | ||
Some(CqlValue::Set(vec![CqlValue::Int(1), CqlValue::Int(2)])), | ||
Some(CqlValue::Set(vec![CqlValue::Int(1), CqlValue::Int(2)])), | ||
], | ||
}; | ||
|
||
assert_eq!( | ||
MyRow::from_row(too_short_row), | ||
Err(FromRowError::WrongRowSize { | ||
expected: 3, | ||
actual: 2 | ||
}) | ||
); | ||
|
||
assert_eq!( | ||
MyRow::from_row(too_large_row), | ||
Err(FromRowError::WrongRowSize { | ||
expected: 3, | ||
actual: 4 | ||
}) | ||
); | ||
} | ||
|
||
// Enabling `expect_used` clippy lint, | ||
// validates that `derive(FromRow)` macro definition does do not violates such rule under the hood. | ||
// Could be removed after such rule will be applied for the whole crate. | ||
// <https://rust-lang.github.io/rust-clippy/master/index.html#/expect_used> | ||
#[deny(clippy::expect_used)] | ||
#[test] | ||
fn unnamed_struct_from_row() { | ||
#[derive(FromRow)] | ||
struct MyRow(i32, Option<String>, Option<Vec<i32>>); | ||
|
||
let row = Row { | ||
columns: vec![ | ||
Some(CqlValue::Int(16)), | ||
None, | ||
Some(CqlValue::Set(vec![CqlValue::Int(1), CqlValue::Int(2)])), | ||
], | ||
}; | ||
|
||
let my_row: MyRow = MyRow::from_row(row).unwrap(); | ||
|
||
assert_eq!(my_row.0, 16); | ||
assert_eq!(my_row.1, None); | ||
assert_eq!(my_row.2, Some(vec![1, 2])); | ||
} |
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.
Again - please make sure that analogous tests for new API exist (if applicable for new API).
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.
Those tests test old value "deserialization" (converting from CqlValue to other types), and to a lesser degree row deserialization (converting from Row = Vec<Option> to a concrete type).
New API has its own tests, which I believe to be extensive enough. See the scylla-cql/src/deserialize/value_tests.rs
and scylla-cql/src/deserialize/row_tests.rs
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.
Ok, that's good enough. BTW, do we support structs with unnamed fields for DeserializeRow
? I remember implementing that for FromRow
: #985. I'm asking since unnamed_struct_from_row
test checked that it works.
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.
I have no idea. @wprzytula ?
It is used by mdbook for code blocks that are syntactically valid Rust, but should not be compiled (e.g. because they contain an intentional compile error).
After legacy session removal it is no longer used.
This was the only leftover from the old deserialization interface.
Those are not used by the new macros.
It was made clonable before in order to accomodate sharing it between legacy and modern sessions. It is no longer necessary.
fe6be5c
to
e894b24
Compare
Still need to move value and value_tests module. |
This PR finally removes both of the old APIs.
Focus in review should be on making sure that I didn't miss anything that shall be removed.
Considerations
value
moduleThis module in
scylla_cql
is placed inframe
module and contained multiple things:Value
andValueList
traits and their implementations)CqlValue
,CqlTimeuuid
etcAfter removing (1), and removing
cql_to_rust
module which was also inframe
, I find it a bit weirdfor this module to be placed in
frame
.Serialization / deserialization are now a top-level modules in
scylla_cql
, so maybe this one should be too?Session
I removed LegacySession, and de-genericized Session, making it a simple struct again.
However I did not inline the methods implementations (like inlining
do_batch
intobatch
).Those inlines should probably happen at some point, but it is not a blocker for 1.0 so I left it for now.
I performed de-genericization because it is a breaking change and thus a blocker for 1.0
Ser / deser tests
Those are all over scylla_cql crate. We should think about the structure for those and move them into a reasonable place.
I left it for another time because this does not affect the API
Fixes: #1167
Pre-review checklist
I added relevant tests for new features and bug fixes.I have provided docstrings for the public items that I want to introduce../docs/source/
.Fixes:
annotations to PR description.