Skip to content

Commit

Permalink
Renaming long names to short ones.
Browse files Browse the repository at this point in the history
  • Loading branch information
urosjarc committed Mar 30, 2024
1 parent 17a834a commit d100f10
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 43 deletions.
47 changes: 22 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,11 @@
<br>
<table width="100%" border="0">
<tr>
<td width="33%">
<td width="50%">
<h3 align="center"><a href="https://github.com/urosjarc/db-messiah">db-messiah</a></h3>
<p align="center">Kotlin lib. for enterprise database development</p>
</td>
<td width="33%" align="center">
<p><a href="#get-started">Get started</a></p>
<p><a href="#features">Features</a></p>
</td>
<td width="33%">
<td width="50%">
<h3 align="center"><a href="https://github.com/urosjarc/db-analyser">db-analyser</a></h3>
<p align="center">GUI for db analysis, to help you create complex JOIN statements for SQL or db-messiah.
</td>
Expand All @@ -30,18 +26,19 @@ implementation("com.urosjarc:db-messiah-extra:0.0.1")
<br><h3 align="center">DB Serializers</h3>

```kotlin
// SQLITE
/** SQLITE */

val sqliteSerializer = SqliteSerializer(
globalSerializers = BasicTS.sqlite + KotlinxTimeTS.sqlite,
...
)

// POSTGRESQL
/** POSTGRESQL */

val sqliteSerializer = SqliteSerializer(
globalSerializers = BasicTS.sqlite + KotlinxTimeTS.sqlite,
...
)

```

<br><h3 align="center">JSON Serializers</h3>
Expand All @@ -52,10 +49,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)
}
}

Expand All @@ -67,22 +64,22 @@ 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)
}
})
}
```

<br><h3 align="center">Features</h3>

| 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 |>
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import java.time.Instant
/**
* Kotlinx serializer for [java.time.Instant] class.
*/
public object InstantSerializer : KSerializer<Instant> {
public object InstantJS : KSerializer<Instant> {
override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("java.time.Instant", PrimitiveKind.STRING)

override fun deserialize(decoder: Decoder): Instant {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import java.time.LocalDate
/**
* Kotlinx serializer for [java.time.LocalDate] class.
*/
public object LocalDateSerializer : KSerializer<LocalDate> {
public object LocalDateJS : KSerializer<LocalDate> {
override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("java.time.LocalDate", PrimitiveKind.STRING)

override fun deserialize(decoder: Decoder): LocalDate {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import java.time.LocalTime
/**
* Kotlinx serializer for [java.time.LocalTime] class.
*/
public object LocalTimeSerializer : KSerializer<LocalTime> {
public object LocalTimeJS : KSerializer<LocalTime> {
override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("java.time.LocalTime", PrimitiveKind.STRING)

override fun deserialize(decoder: Decoder): LocalTime {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import java.util.*
/**
* Kotlinx serializer for [java.time.UUID] class.
*/
public object UUIDSerializer : KSerializer<UUID> {
public object UUIDJS : KSerializer<UUID> {
override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("java.util.UUID", PrimitiveKind.STRING)

override fun deserialize(decoder: Decoder): UUID {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Parent>()
Expand Down
16 changes: 8 additions & 8 deletions src/test/kotlin/utils/Serializers.kt
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
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
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)
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/test/kotlin/utils/domain.kt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -19,7 +19,7 @@ value class Id<T>(val value: Int) {
@Serializable
@JvmInline
value class UId<T>(
@Serializable(with = UUIDSerializer::class)
@Serializable(with = UUIDJS::class)
val value: UUID = UUID.randomUUID()
) {
override fun toString(): String {
Expand Down

0 comments on commit d100f10

Please sign in to comment.