-
-
Notifications
You must be signed in to change notification settings - Fork 91
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
[Feature request] Support for flattening models #100
Comments
Yeah, would be even better if it supported shapeless.Witness selector for fieldFrom/fieldTo names, like this:
|
One of possible solutions to this problem would be to allow pulling fields from nested case classes and pushing them down to nested. DataHolder(1, InnerData("name_val", 10))
.into[Target]
.withFieldsPulledFrom(_.data)
.transform
Target(1, "name_val", 10)
.into[DataHolder]
.withFieldsPushedTo(_.data, _.name, _.ival)
.transform It could work as long as pulling/pushing fields doesn't introduce name clash. Other possibility is to generalize renaming to support renaming of nested fields as well: DataHolder(1, InnerData("name_val", 10))
.into[Target]
.withFieldRenamed(_.data.name, _.name)
.withFieldRenamed(_.data.ival, _.ival)
.transform
Target(1, "name_val", 10)
.into[DataHolder]
.withFieldRenamed(_.name, _.data.name)
.withFieldRenamed(_.ival, _.data.ival)
.transform Actually, both proposals are orthogonal and can be implemented independently. |
as for my purposes 2nd way is ok |
great thx |
It would be great to have possibility to map inner fields of object to top level object.
It would be nice to have any way to tell transformer that i need to extract fields from inner classes
Now i'm using workaround like this
Main problem here is that i have no possibility to reuse it on
OtherDataHolder
so i need every time to write this code.The text was updated successfully, but these errors were encountered: