-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Add support for kotlinx-datetime serializers mapping to BSON #1462
Conversation
- Add kotlinx-datetime serializers that map to BSON as the expected types. - Make it easily configurable via `@Contextual` annotation. JAVA-5330
JAVA-5330
bson-kotlinx/build.gradle.kts
Outdated
@@ -45,6 +45,7 @@ dependencies { | |||
|
|||
implementation(platform("org.jetbrains.kotlinx:kotlinx-serialization-bom:1.5.0")) | |||
implementation("org.jetbrains.kotlinx:kotlinx-serialization-core") | |||
implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.4.0") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This version is compatible with Kotlin versions 1.5 and later. The next version 0.5.0 requires Kotlin 1.9 or higher, as indicated by this commit:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't take a hard dependency on this library - so this will need refactoring to make it optional. #1459 adds a check for kotlinx-json support, you could use that style to add an if statement for the defaultSerializersModule
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have refactored it to make the library optional, using the approach outlined in #1459 for checking kotlinx-datetime support. Thanks!
bson-kotlinx/build.gradle.kts
Outdated
@@ -45,6 +45,7 @@ dependencies { | |||
|
|||
implementation(platform("org.jetbrains.kotlinx:kotlinx-serialization-bom:1.5.0")) | |||
implementation("org.jetbrains.kotlinx:kotlinx-serialization-core") | |||
implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.4.0") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't take a hard dependency on this library - so this will need refactoring to make it optional. #1459 adds a check for kotlinx-json support, you could use that style to add an if statement for the defaultSerializersModule
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good - just need to update the javadoc to kdoc.
bson-kotlinx/src/main/kotlin/org/bson/codecs/kotlinx/DateTimeSerializers.kt
Show resolved
Hide resolved
bson-kotlinx/src/main/kotlin/org/bson/codecs/kotlinx/DateTimeSerializers.kt
Outdated
Show resolved
Hide resolved
…erializers.kt Co-authored-by: Ross Lawley <ross.lawley@gmail.com>
JAVA-5330
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More KDoc changes - then LGTM
bson-kotlinx/src/main/kotlin/org/bson/codecs/kotlinx/DateTimeSerializers.kt
Outdated
Show resolved
Hide resolved
bson-kotlinx/src/main/kotlin/org/bson/codecs/kotlinx/DateTimeSerializers.kt
Outdated
Show resolved
Hide resolved
bson-kotlinx/src/main/kotlin/org/bson/codecs/kotlinx/DateTimeSerializers.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! - btw I pushed some kdoc nit changes
@Contextual
annotation.JAVA-5330