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

allow to not store null using a new Configuration.nonEncodeNull property #5

Open
zigzago opened this issue Oct 5, 2019 · 4 comments

Comments

@zigzago
Copy link
Collaborator

zigzago commented Oct 5, 2019

Because we can't always add a NonEncodeNull annotation

@zigzago zigzago changed the title allow to does not store null using a new Configuration.nonEncodeNull property allow to not store null using a new Configuration.nonEncodeNull property Oct 5, 2019
@jershell
Copy link
Owner

jershell commented Oct 7, 2019

Litote/kmongo#104

@jershell
Copy link
Owner

It is big trouble because annotation allows mark ObjectId field. We have two way destinate goal, use @Serializable(with = ObjectIdSerializer::class) or use @nonEncodeNull.
@ContextualSerialization lose field type and try to found by value

//// kotlinx/serialization/ContextSerializer.kt
    public override fun serialize(encoder: Encoder, obj: T) {
        val s = encoder.context.getContextualOrDefault(obj)
        encoder.encodeSerializableValue(s, obj)
    }

that make imposible get actual serializer by null value
I hope may be in next version of kotlinx.serialization they add possibility for fix it

@jershell
Copy link
Owner

Hm, in v0.13.0 I look on the point "Hide NullableSerializer, introduce '.nullable' extension instead". Need more time for research

@jershell
Copy link
Owner

@zigzago
As variant i can make nonEncodeNullableId property of configuration with @file:UseSerializers(ObjectIdSerializer::class) or another serializer determ. ContextSerializer is not impossible to support

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

No branches or pull requests

2 participants