Skip to content

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
Contributor

Choose a reason for hiding this comment

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

Seems reasonable IMO

@codecov
Copy link

codecov bot commented Jul 22, 2024

Codecov Report

❌ Patch coverage is 88.88889% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 95.31%. Comparing base (2c10ba9) to head (bb2dcee).
⚠️ Report is 46 commits behind head on main.

Files with missing lines 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.34%   95.31%   -0.03%     
==========================================
  Files          56       56              
  Lines        1978     1987       +9     
  Branches      154      157       +3     
==========================================
+ Hits         1886     1894       +8     
- Misses         92       93       +1     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

3 participants