diff --git a/README.md b/README.md index 5eb06f7..bfaf7ec 100644 --- a/README.md +++ b/README.md @@ -30,18 +30,19 @@ implementation("com.urosjarc:db-messiah-extra:0.0.1")

DB Serializers

```kotlin -// SQLITE +/** SQLITE */ + val sqliteSerializer = SqliteSerializer( globalSerializers = BasicTS.sqlite + KotlinxTimeTS.sqlite, ... ) -// POSTGRESQL +/** POSTGRESQL */ + val sqliteSerializer = SqliteSerializer( globalSerializers = BasicTS.sqlite + KotlinxTimeTS.sqlite, ... ) - ```

JSON Serializers

@@ -52,10 +53,10 @@ val sqliteSerializer = SqliteSerializer( val json = Json { serializersModule = SerializersModule { - contextual(InstantSerializer) - contextual(LocalDateSerializer) - contextual(LocalTimeSerializer) - contextual(UUIDSerializer) + contextual(InstantJS) + contextual(LocalDateJS) + contextual(LocalTimeJS) + contextual(UUIDJS) } } @@ -67,10 +68,10 @@ val obj = json.decodeFromString<...>(...) install(ContentNegotiation) { json(Json { serializersModule = SerializersModule { - contextual(InstantSerializer) - contextual(LocalDateSerializer) - contextual(LocalTimeSerializer) - contextual(UUIDSerializer) + contextual(InstantJS) + contextual(LocalDateJS) + contextual(LocalTimeJS) + contextual(UUIDJS) } }) } @@ -78,11 +79,11 @@ install(ContentNegotiation) {

Features

-| Class | COLUMN | Databases | db-messiah-extra | JSON | -|:---------:|:------------:|:------------------------------------:|:---------------------------:|:-----------------------:| -| Instant | DATETIME | Sqlite, Mysql, MSSql, Maria, H2, DB2 | KotlinxInstantTS. DATETIME | InstantSerializer | -| Instant | TIMESTAMP | Derby, Postgres, Oracle | KotlinxInstantTS. TIMESTAMP | InstantSerializer | -| LocalDate | DATE | :white_check_mark: | KotlinxLocalDateTS. DATE | LocalDateSerializer | -| LocalTime | TIME | :white_check_mark: but Oracle | KotlinxTimeTS.TIME | LocalDateSerializer | -| LocalTime | NUMBER(8, 0) | Oracle | KotlinxTimeTS. NUMBER8 | LocalTimeSerializer |> -| UUID | db-messiah | db-messiah | db-messiah | UUIDSerializer |> +| Class | COLUMN | Databases | db-messiah-extra | JSON | +|:---------:|:------------:|:------------------------------------:|:---------------------------:|:-----------:| +| Instant | DATETIME | Sqlite, Mysql, MSSql, Maria, H2, DB2 | KotlinxInstantTS. DATETIME | InstantJS | +| Instant | TIMESTAMP | Derby, Postgres, Oracle | KotlinxInstantTS. TIMESTAMP | InstantJS | +| LocalDate | DATE | :white_check_mark: | KotlinxLocalDateTS. DATE | LocalDateJS | +| LocalTime | TIME | :white_check_mark: but Oracle | KotlinxTimeTS.TIME | LocalDateJS | +| LocalTime | NUMBER(8, 0) | Oracle | KotlinxTimeTS. NUMBER8 | LocalTimeJS |> +| UUID | db-messiah | db-messiah | db-messiah | UUIDJS |> diff --git a/src/main/kotlin/com/urosjarc/dbmessiah/extra/kotlinx/InstantSerializer.kt b/src/main/kotlin/com/urosjarc/dbmessiah/extra/kotlinx/InstantJS.kt similarity index 93% rename from src/main/kotlin/com/urosjarc/dbmessiah/extra/kotlinx/InstantSerializer.kt rename to src/main/kotlin/com/urosjarc/dbmessiah/extra/kotlinx/InstantJS.kt index 7c76457..df4001b 100644 --- a/src/main/kotlin/com/urosjarc/dbmessiah/extra/kotlinx/InstantSerializer.kt +++ b/src/main/kotlin/com/urosjarc/dbmessiah/extra/kotlinx/InstantJS.kt @@ -11,7 +11,7 @@ import java.time.Instant /** * Kotlinx serializer for [java.time.Instant] class. */ -public object InstantSerializer : KSerializer { +public object InstantJS : KSerializer { override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("java.time.Instant", PrimitiveKind.STRING) override fun deserialize(decoder: Decoder): Instant { diff --git a/src/main/kotlin/com/urosjarc/dbmessiah/extra/kotlinx/LocalDateSerializer.kt b/src/main/kotlin/com/urosjarc/dbmessiah/extra/kotlinx/LocalDateJS.kt similarity index 93% rename from src/main/kotlin/com/urosjarc/dbmessiah/extra/kotlinx/LocalDateSerializer.kt rename to src/main/kotlin/com/urosjarc/dbmessiah/extra/kotlinx/LocalDateJS.kt index ab66461..6518d3c 100644 --- a/src/main/kotlin/com/urosjarc/dbmessiah/extra/kotlinx/LocalDateSerializer.kt +++ b/src/main/kotlin/com/urosjarc/dbmessiah/extra/kotlinx/LocalDateJS.kt @@ -11,7 +11,7 @@ import java.time.LocalDate /** * Kotlinx serializer for [java.time.LocalDate] class. */ -public object LocalDateSerializer : KSerializer { +public object LocalDateJS : KSerializer { override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("java.time.LocalDate", PrimitiveKind.STRING) override fun deserialize(decoder: Decoder): LocalDate { diff --git a/src/main/kotlin/com/urosjarc/dbmessiah/extra/kotlinx/LocalTimeSerializer.kt b/src/main/kotlin/com/urosjarc/dbmessiah/extra/kotlinx/LocalTimeJS.kt similarity index 93% rename from src/main/kotlin/com/urosjarc/dbmessiah/extra/kotlinx/LocalTimeSerializer.kt rename to src/main/kotlin/com/urosjarc/dbmessiah/extra/kotlinx/LocalTimeJS.kt index 22e033a..d8d3172 100644 --- a/src/main/kotlin/com/urosjarc/dbmessiah/extra/kotlinx/LocalTimeSerializer.kt +++ b/src/main/kotlin/com/urosjarc/dbmessiah/extra/kotlinx/LocalTimeJS.kt @@ -11,7 +11,7 @@ import java.time.LocalTime /** * Kotlinx serializer for [java.time.LocalTime] class. */ -public object LocalTimeSerializer : KSerializer { +public object LocalTimeJS : KSerializer { override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("java.time.LocalTime", PrimitiveKind.STRING) override fun deserialize(decoder: Decoder): LocalTime { diff --git a/src/main/kotlin/com/urosjarc/dbmessiah/extra/kotlinx/UUIDSerializer.kt b/src/main/kotlin/com/urosjarc/dbmessiah/extra/kotlinx/UUIDJS.kt similarity index 93% rename from src/main/kotlin/com/urosjarc/dbmessiah/extra/kotlinx/UUIDSerializer.kt rename to src/main/kotlin/com/urosjarc/dbmessiah/extra/kotlinx/UUIDJS.kt index 25042e1..0ef0646 100644 --- a/src/main/kotlin/com/urosjarc/dbmessiah/extra/kotlinx/UUIDSerializer.kt +++ b/src/main/kotlin/com/urosjarc/dbmessiah/extra/kotlinx/UUIDJS.kt @@ -11,7 +11,7 @@ import java.util.* /** * Kotlinx serializer for [java.time.UUID] class. */ -public object UUIDSerializer : KSerializer { +public object UUIDJS : KSerializer { override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("java.util.UUID", PrimitiveKind.STRING) override fun deserialize(decoder: Decoder): UUID { diff --git a/src/test/kotlin/Test_InstantSerializer.kt b/src/test/kotlin/Test_InstantJS.kt similarity index 94% rename from src/test/kotlin/Test_InstantSerializer.kt rename to src/test/kotlin/Test_InstantJS.kt index 900f81b..a3d555e 100644 --- a/src/test/kotlin/Test_InstantSerializer.kt +++ b/src/test/kotlin/Test_InstantJS.kt @@ -5,7 +5,7 @@ import utils.json import java.time.Instant import kotlin.test.assertEquals -class Test_InstantSerializer { +class Test_InstantJS { @Test fun `test serialization`() { val instant = Instant.now() diff --git a/src/test/kotlin/Test_LocalDateSerializer.kt b/src/test/kotlin/Test_LocalDateJS.kt similarity index 94% rename from src/test/kotlin/Test_LocalDateSerializer.kt rename to src/test/kotlin/Test_LocalDateJS.kt index 4f0d1ec..c9023ef 100644 --- a/src/test/kotlin/Test_LocalDateSerializer.kt +++ b/src/test/kotlin/Test_LocalDateJS.kt @@ -5,7 +5,7 @@ import utils.json import java.time.LocalDate import kotlin.test.assertEquals -class Test_LocalDateSerializer { +class Test_LocalDateJS { @Test fun `test serialization`() { val instant = LocalDate.now() diff --git a/src/test/kotlin/Test_LocalTimeSerializer.kt b/src/test/kotlin/Test_LocalTimeJS.kt similarity index 94% rename from src/test/kotlin/Test_LocalTimeSerializer.kt rename to src/test/kotlin/Test_LocalTimeJS.kt index 6540236..92b5391 100644 --- a/src/test/kotlin/Test_LocalTimeSerializer.kt +++ b/src/test/kotlin/Test_LocalTimeJS.kt @@ -5,7 +5,7 @@ import utils.json import java.time.LocalTime import kotlin.test.assertEquals -class Test_LocalTimeSerializer { +class Test_LocalTimeJS { @Test fun `test serialization`() { val instant = LocalTime.now() diff --git a/src/test/kotlin/Test_UUIDSerializer.kt b/src/test/kotlin/Test_UUIDJS.kt similarity index 97% rename from src/test/kotlin/Test_UUIDSerializer.kt rename to src/test/kotlin/Test_UUIDJS.kt index ca2f01b..ba0f413 100644 --- a/src/test/kotlin/Test_UUIDSerializer.kt +++ b/src/test/kotlin/Test_UUIDJS.kt @@ -6,7 +6,7 @@ import utils.UId import utils.json import kotlin.test.assertEquals -class test_UUIDSerializer { +class Test_UUIDJS { @Test fun `test id serialization`() { val id = UId() diff --git a/src/test/kotlin/utils/Serializers.kt b/src/test/kotlin/utils/Serializers.kt index 59fc644..2bc07de 100644 --- a/src/test/kotlin/utils/Serializers.kt +++ b/src/test/kotlin/utils/Serializers.kt @@ -1,10 +1,10 @@ package utils import com.urosjarc.dbmessiah.data.TypeSerializer -import com.urosjarc.dbmessiah.extra.kotlinx.InstantSerializer -import com.urosjarc.dbmessiah.extra.kotlinx.LocalDateSerializer -import com.urosjarc.dbmessiah.extra.kotlinx.LocalTimeSerializer -import com.urosjarc.dbmessiah.extra.kotlinx.UUIDSerializer +import com.urosjarc.dbmessiah.extra.kotlinx.InstantJS +import com.urosjarc.dbmessiah.extra.kotlinx.LocalDateJS +import com.urosjarc.dbmessiah.extra.kotlinx.LocalTimeJS +import com.urosjarc.dbmessiah.extra.kotlinx.UUIDJS import com.urosjarc.dbmessiah.serializers.IdTS import kotlinx.serialization.json.Json import kotlinx.serialization.modules.SerializersModule @@ -12,10 +12,10 @@ import kotlinx.serialization.modules.contextual val json = Json { serializersModule = SerializersModule { - contextual(InstantSerializer) - contextual(LocalDateSerializer) - contextual(LocalTimeSerializer) - contextual(UUIDSerializer) + contextual(InstantJS) + contextual(LocalDateJS) + contextual(LocalTimeJS) + contextual(UUIDJS) } } diff --git a/src/test/kotlin/utils/domain.kt b/src/test/kotlin/utils/domain.kt index a2cc246..07c264a 100644 --- a/src/test/kotlin/utils/domain.kt +++ b/src/test/kotlin/utils/domain.kt @@ -1,6 +1,6 @@ package utils -import com.urosjarc.dbmessiah.extra.kotlinx.UUIDSerializer +import com.urosjarc.dbmessiah.extra.kotlinx.UUIDJS import kotlinx.datetime.Clock import kotlinx.datetime.TimeZone import kotlinx.datetime.toLocalDateTime @@ -19,7 +19,7 @@ value class Id(val value: Int) { @Serializable @JvmInline value class UId( - @Serializable(with = UUIDSerializer::class) + @Serializable(with = UUIDJS::class) val value: UUID = UUID.randomUUID() ) { override fun toString(): String {