sksamuel / avro4s

Avro schema generation and serialization / deserialization for Scala
Apache License 2.0
714 stars 236 forks source link

Match Union's sort order with enum's and with sort order in 4.x #830

Closed vkorchik closed 1 month ago

vkorchik commented 3 months ago

Seems like annotation @AvroSortPriority sorts records in Union in reversed order comparing with Enums, as well as with Enums/Unions from avro4s:4.x.

Probably the reason is a sort order here in Subtypes. Comparing with enums in 5.x and unions in 4.x, it seems to me that the Ordering compares A with B - ascending order, when instead it should compare B to A - descending. Since AvroSortPriority is descending-based (if we could say so), then there should be B compare A.

The same (but reversed) issue with AvroUnionPosition will be automatically resolved since these two annotations are tightly coupled anyway.

vkorchik commented 2 months ago

@sksamuel , could you please review this PR?