Repository navigation
feat!: Rework schema compatibility - #342
Conversation
|
I'm afraid I cannot approve this PR :-/
How can one be sure what has been written with a given schema ? Anything that the schema accepts could be in the file. I cannot make assumptions that parts of the schema were never used. If you strongly believe that it is better and it won't cause problems to the other users then feel free to merge it! |
|
I'll remove the partial compatibility and do some more testing to compare the new version with the old version (I'll see if I can get a fuzzer to run). |
|
I unfortunately couldn't get a fuzzer to work, the recursive branchy code makes it hard for the fuzzer to select new paths. I took a look at
So the new behaviour allows slightly more, but is also more honest about the compatibility. What do you think based on this table? |
e1cf3bb to
4cf0087
Compare
|
The CI checks didn't run for this PR for some reason. |
|
Ah, that was made stable in 1.88. So shall we bump the MSRV or shall I rewrite it with a match statement? Also the CI not running was me messing with target branch |
|
Let's bump! |
41f11f4 to
521c723
Compare
|
Version bumped and new lints fixed (some lints are gated behind the |
521c723 to
61b9a7c
Compare
61b9a7c to
6d70a2a
Compare
86b4128 to
6a37335
Compare
This new implementation is (in my opinion) simpler than the previous iteration and easier to modify when needed. I've introduced the concept of partial and full compatibility. Partial compatibility means that there incompatiblities but that depends on whats written, for example an enum `[A, B, C]` is partially compatible with the enum `[A, B]` but depends on what the writer has written. Users wishing to be absolutely sure, can treat `Compatibility::Partial` as an error, others can use it to slowly upgrade from an old schema.
6d70a2a to
59189d6
Compare
1cc27de to
b51892b
Compare
|
Rebased on main, and test added for resolving Decimals with different inner types. |
This adds support for the changed `Schema::Duration(FixedSchema)`
d63a6b0 to
25ca5ad
Compare
|
I've merged Anything left to do @martin-g? |
| // float promotes to double | ||
| (Schema::Float, Schema::Float | Schema::Double) => Ok(Compatibility::Full), | ||
| (Schema::Double, Schema::Double) => Ok(Compatibility::Full), | ||
| // bytes and strings are interchangeable |
There was a problem hiding this comment.
Are the always interchangeable ?
UuidSchema::Bytes has to be exactly 16 bytes.
UuidString::String has to be at least 32 chars.
The checks for Decimal bytes schema also miss to check the precision and scale here.
There was a problem hiding this comment.
Because they are decoded to and encoded from the uuid::Uuid type, resolving them will always work.
I've moved the Decimal check with the precision and scale above this statement, so this will only match now if one is Decimal::Bytes and one isn't.
…scale must be checked
I think this is better overall, but I can understand if you would want to revert the
Compatibility::Partialand keep exactly to old behavior.This new implementation is (in my opinion) simpler than the previous iteration and easier to modify when needed.
I've introduced the concept of partial and full compatibility. Partial compatibility means that there incompatibilities but that depends on whats written, for example an enum
[A, B, C]is partially compatible with the enum[A, B]but depends on what the writer has written.Users wishing to be absolutely sure, can treat
Compatibility::Partialas an error, others can use it to slowly upgrade from an old schema.Depends on #339, should be rebased after that's merged