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

[avro] Add Either typeclass support #1004

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

[avro] Add Either typeclass support #1004

wants to merge 1 commit into from

Conversation

RustedBones
Copy link
Contributor

Support scala Either as a avro type union

Comment on lines +263 to +267
// `Either[A, B]` is a `UNION` of `[A, B]` and must default to first type `A`
override def makeDefault(d: Either[A, B])(cm: CaseMapper): fa.ToT = {
require(d.isLeft, "Either[A, B] can only default to Left[A]")
fa.to(d.left.get)(cm): @nowarn
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In scala Either is Right biased but here I chose Left as possible default based on type order definition. WDYT?

Copy link

codecov bot commented Jul 22, 2024

Codecov Report

Attention: Patch coverage is 88.88889% with 1 line in your changes missing coverage. Please review.

Project coverage is 95.15%. Comparing base (aa00c1f) to head (138972e).
Report is 26 commits behind head on main.

Files Patch % Lines
avro/src/main/scala/magnolify/avro/AvroType.scala 88.88% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1004      +/-   ##
==========================================
- Coverage   95.18%   95.15%   -0.04%     
==========================================
  Files          51       51              
  Lines        1827     1836       +9     
  Branches      153      161       +8     
==========================================
+ Hits         1739     1747       +8     
- Misses         88       89       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Support scala Either as a avro type union
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.

1 participant