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

#45: Add @CsvEmbed #126

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

#45: Add @CsvEmbed #126

wants to merge 1 commit into from

Conversation

ybasket
Copy link
Collaborator

@ybasket ybasket commented Mar 2, 2021

Allows to map nested case class structures from and to flat CSV. See included docs for more info. Fixes #45.

Allows to map nested case class structures from and to flat CSV. Fixes #45.
@ybasket ybasket requested a review from satabin March 2, 2021 21:22
for {
head <- (Head(row), default.head) match {
case (r @ Right(_), _) => r
case (Left(_: DecoderError.ColumnMissing), Some(default)) => Right(default)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is a somewhat tricky case as it could be that some of the fields of the embedded value are present, some are invalid. In this edge case, it depends on the order of fields whether the default is taken or the error of an invalid field is bubbled up. The only way to mitigate this would be to introduce error-accumulating parsing (which would indeed be an interesting addition), but as the exact combination of

  • embedding
  • invalid fields for the embedded value
  • missing fields for the embedded value and
  • a default for the embedded field

should be extremely rare in the wild, I believe this is fine.

Base automatically changed from 1.x to main March 20, 2021 16:45
Copy link
Member

@satabin satabin left a comment

Choose a reason for hiding this comment

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

Looks good, but you probably need to rebase to get the line context into account.

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.

None yet

2 participants