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
Updates bson-kotlin DataClassCodec.kt to allow the usage of default values #1260
base: master
Are you sure you want to change the base?
Conversation
avoids providing null to parameters that are not nullable, allowing for the usage of default values
Hi @jyemin could you take a look please 🙏 |
The kotlin bson codec already supports default values for data classes. This PR is something slightly different, it wants to use default values where the data stored is a What is the correct thing to when a field is nullable and there is a
Will all users want to allow a |
hey @rozza thanks for taking a look 🙏 the changes on the PR will not affect the case you described, since in this case category is nullable, the filter on |
Hi @rozza could you take another quick look? |
Hi @filipeportes, Thanks for your perservance with this issue. I've added JAVA-5281 to track it. This will be triaged and if successful scheduled for a future release. I will update the ticket here also, the open question is, if the change in behavior is the correct change to make and will it also apply to bson-kotlinx. Ross |
Just to update it looks like there is a way for kotlinx to do this with json, via configuration. So its now on the backlog for applying to both kotlin-bson and kotlinx-bson. However, there is no firm timeline as to when this work will be scheduled. Please watch the ticket for further details. Ross |
avoids providing null to parameters that are not nullable, allowing for the usage of default values.
example:
given a data Class:
the following objects will produce
CodecConfigurationException: Unable to invoke primary constructor of Item data class
:with the changes proposed in this PR, the result will be decoding the documents and using the default values in case no actual values are provided.
PS: