martin-g commented on code in PR #339:
URL: https://github.com/apache/avro-rs/pull/339#discussion_r2576709302
##########
avro/src/decode.rs:
##########
@@ -101,39 +102,66 @@ pub(crate) fn decode_internal<R: Read, S: Borrow<Schema>>(
}
}
}
- Schema::Decimal(DecimalSchema { ref inner, .. }) => match &**inner {
- Schema::Fixed { .. } => {
- match decode_internal(inner, names, enclosing_namespace,
reader)? {
+ Schema::Decimal(DecimalSchema { inner, .. }) => match inner {
+ InnerDecimalSchema::Fixed(fixed) => {
+ match decode_internal(
+ &Schema::Fixed(fixed.copy_only_size()),
+ names,
+ enclosing_namespace,
+ reader,
+ )? {
Value::Fixed(_, bytes) =>
Ok(Value::Decimal(Decimal::from(bytes))),
value => Err(Details::FixedValue(value).into()),
}
}
- Schema::Bytes => match decode_internal(inner, names,
enclosing_namespace, reader)? {
- Value::Bytes(bytes) =>
Ok(Value::Decimal(Decimal::from(bytes))),
- value => Err(Details::BytesValue(value).into()),
- },
- schema => Err(Details::ResolveDecimalSchema(schema.into()).into()),
+ InnerDecimalSchema::Bytes => {
+ match decode_internal(&Schema::Bytes, names,
enclosing_namespace, reader)? {
+ Value::Bytes(bytes) =>
Ok(Value::Decimal(Decimal::from(bytes))),
+ value => Err(Details::BytesValue(value).into()),
+ }
+ }
},
Schema::BigDecimal => {
match decode_internal(&Schema::Bytes, names, enclosing_namespace,
reader)? {
Value::Bytes(bytes) =>
deserialize_big_decimal(&bytes).map(Value::BigDecimal),
value => Err(Details::BytesValue(value).into()),
}
}
- Schema::Uuid => {
+ Schema::Uuid(UuidSchema::String) => {
+ let Value::String(string) =
+ decode_internal(&Schema::String, names, enclosing_namespace,
reader)?
+ else {
+ // Calling decode_internal with Schema::String can only return
a Value::String or an error
Review Comment:
No idea!
If no tests fail we could remove it and re-add later if we/someone find(s)
the reason.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]