-
Notifications
You must be signed in to change notification settings - Fork 238
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
Ability to specify defaults by an annotation #528
Comments
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Not stale – I'd still be interested to see how hard this feature would be to add. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Could we re-open this feature-request, having the same issue, or maybe a explanation why this is not do-able? |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Please don't stale, trying to find some time trying to handle this issue. |
@janjaali if you want to add this, then look here: https://github.com/sksamuel/avro4s/blob/release/4.0.x/avro4s-core/src/main/scala/com/sksamuel/avro4s/Records.scala#L200-L205 You need to update that first case statement to look for an annotation on the field. You can add the lookup code in AnnotationExtractors. |
Thanks @sksamuel, I will try to come up with a PR in the upcoming holiday season. Wish you happy holidays and a good start into the new year ;) |
In my situation almost every field is optional. I am looking for a way to automatically add "null" as the default value for every optional. Is something like that supported? |
Somewhat related feature request: #714. |
I'm guessing this is not getting done any time soon? 😢 |
If you pr I will release but I no longer actively work on scala projects. |
Nah, I'll just use this solution by Erik |
I'd like to be able to specify a field as having a default value without having to use default arguments. Ie, currently I have to do:
whereas I'd like to be able to do something like:
The reason being that having the default value in the case class means it's very easy to forget to specify an argument in my application code when I'm instantiating the case class (which actually led to me nearly shipping a bug to production the other day). Would this be a difficult feature to add? I'd potentially be able to work on a PR – I work with @alexjg who's contributed to this codebase before.
Thanks very much!
The text was updated successfully, but these errors were encountered: