diff --git a/README.md b/README.md
index f04db90d..84d6f093 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,8 @@
db-messiah
-Kotlin lib. for enterprise database development
+
+ Lib. similar to JetBrains/Exposed, but without annotations, DSLs or DAOs...
+ Lib. has a strong focus on clean architecture and simplicity.
+
+290 unit,
+210 e2e,
@@ -11,6 +14,21 @@
tested
+86% instruction coverage
+
+```kotlin
+val outputs = it.query.get(output = Out::class, input = parent) {
+ """
+ SELECT
+ ${it.column(Child::value)} AS ${it.name(Out::child_value)},
+ ${it.column(Parent::value)} AS ${it.name(Out::parent_value)}
+ FROM ${it.table()}
+ INNER JOIN ${it.table()} ON ${it.column(Parent::pk)} = ${it.column(Child::parent_pk)}
+ WHERE ${it.column(Child::value)} = ${it.input(Parent::value)}
+ """
+}
+assert(outputs == listOf(Out(child_value="value_3", parent_value="value_3")))
+```
+
@@ -40,8 +58,8 @@
```kotlin
/** DEPENDENCIES */
-implementation("com.urosjarc:db-messiah:0.0.1") // Required
-implementation("com.urosjarc:db-messiah-extra:0.0.1") // Optional
+implementation("com.urosjarc:db-messiah:0.0.2") // Required
+implementation("com.urosjarc:db-messiah-extra:0.0.2") // Optional
implementation("org.apache.logging.log4j:log4j-slf4j2-impl:2.20.0") //Optional
/** DRIVERS */
@@ -102,6 +120,10 @@ data class Unsafe(
val pk: UUID = UUID.randomUUID(), // Unsafe UUID manual primary key
val created: Instant = Instant.now() // Support for java.time.*
)
+
+/** QUERY DTO */
+
+data class Out(val child_value: String, val parent_value: String)
```
Database
@@ -130,12 +152,13 @@ val sqliteSerializer = SqliteSerializer(
)
),
),
+ globalOutputs = listOf(Out::class)
)
/** POSTGRES */
val pgSerializer = PgSerializer(
- globalSerializers = BasicTS.sqlite + JavaTimeTS.postgresql,
+ globalSerializers = BasicTS.postgresql + JavaTimeTS.postgresql,
schemas = listOf(
PgSchema(
name = "name", tables = listOf(
@@ -271,9 +294,8 @@ sqlite.autocommit {
WHERE ${it.column(Child::value)} = ${it.input(Parent::value)}
"""
}
- println(moreChildren)
assert(moreChildren == listOf(children[3]))
-}
+
```
Transactions
@@ -396,52 +418,51 @@ For detailed explanation read about Specifications
-| | Schema | Serializer | Service | Basic types | java.time.* types |
-|:--------:|:-------------:|:----------------:|:-------------:|:-------------------:|:----------------------:|
-| DB2 | Db2Schema | Db2Serializer | Db2Service | BasicTS.db2 | JavaTimeTS.db2 |
-| Derby | DerbySchema | DerbySerializer | DerbyService | BasicTS.derby | JavaTimeTS.derby |
-| H2 | H2Schema | H2Serializer | H2Service | BasicTS.h2 | JavaTimeTS.h2 |
-| Maria | MariaSchema | MariaSerializer | MariaService | BasicTS.maria | JavaTimeTS.maria |
-| MS SQL | MssqlSchema | MssqlSerializer | MssqlService | BasicTS.mssql | JavaTimeTS.mssql |
-| MySQL | MysqlSchema | MysqlSerializer | MysqlService | BasicTS.mysql | JavaTimeTS.mysql |
-| Oracle | OracleSchema | OracleSerializer | OracleService | BasicTS.oracle | JavaTimeTS.oracle |
-| Postgres | PgSchema | PgSerializer | PgService | BasicTS. postgresql | JavaTimeTS. postgresql |
-| Sqlite | :x: | SqliteSerializer | SqliteService | BasicTS.sqlite | JavaTimeTS.sqlite |
+| | Schema | Serializer | Service | Basic types | java.time.* types |
+|:--------:|:------------:|:----------------:|:-------------:|:-------------------:|:----------------------:|
+| DB2 | Db2Schema | Db2Serializer | Db2Service | BasicTS.db2 | JavaTimeTS.db2 |
+| Derby | DerbySchema | DerbySerializer | DerbyService | BasicTS.derby | JavaTimeTS.derby |
+| H2 | H2Schema | H2Serializer | H2Service | BasicTS.h2 | JavaTimeTS.h2 |
+| Maria | MariaSchema | MariaSerializer | MariaService | BasicTS.maria | JavaTimeTS.maria |
+| MS SQL | MssqlSchema | MssqlSerializer | MssqlService | BasicTS.mssql | JavaTimeTS.mssql |
+| MySQL | MysqlSchema | MysqlSerializer | MysqlService | BasicTS.mysql | JavaTimeTS.mysql |
+| Oracle | OracleSchema | OracleSerializer | OracleService | BasicTS.oracle | JavaTimeTS.oracle |
+| Postgres | PgSchema | PgSerializer | PgService | BasicTS. postgresql | JavaTimeTS. postgresql |
+| Sqlite | :x: | SqliteSerializer | SqliteService | BasicTS.sqlite | JavaTimeTS.sqlite |
Features
-| | Escape | Schema | Auto INT PK | Auto UUID PK | UUID column | Many queries | Cascade | Procedure |
+| | Escape | Schema | Auto INT PK | Auto UUID PK | UUID column | Many queries | Cascade | Procedure |
|:--------:|:------:|:----------------------:|:------------------:|:------------------:|:------------:|:------------------:|:-------------------------------------:|:----------------------:|
-| DB2 | "%s" | :large_orange_diamond: | :white_check_mark: | :x: | CHAR(36) | :x: | :x: | :large_orange_diamond: |
-| Derby | "%s" | :white_check_mark: | :white_check_mark: | :x: | CHAR(36) | :x: | :x: | :x: |
-| H2 | "%s" | :white_check_mark: | :white_check_mark: | :white_check_mark: | UUID | :x: | :white_check_mark: | :x: |
-| Maria | \`%s\` | :white_check_mark: | :white_check_mark: | :x: | UUID | :x: | :x: | :white_check_mark: |
-| MS SQL | [%s] | :white_check_mark: | :white_check_mark: | :x: | UNIQUEIDE... | :white_check_mark: | :x: | :white_check_mark: |
-| MySQL | \`%s\` | :white_check_mark: | :white_check_mark: | :x: | CHAR(36) | :x: | :x: | :white_check_mark: |
-| Oracle | "%s" | :large_orange_diamond: | :white_check_mark: | :x: | VARCHAR2(36) | :x: | :white_check_mark: | :white_check_mark: |
-| Postgres | "%s" | :white_check_mark: | :white_check_mark: | :white_check_mark: | UUID | :white_check_mark: | :white_check_mark: :white_check_mark: | :x: |
-| Sqlite | "%s" | :x: | :white_check_mark: | :x: | CHAR(36) | :x: | :x: | :x: |
+| DB2 | "%s" | :large_orange_diamond: | :white_check_mark: | :x: | CHAR(36) | :x: | :x: | :large_orange_diamond: |
+| Derby | "%s" | :white_check_mark: | :white_check_mark: | :x: | CHAR(36) | :x: | :x: | :x: |
+| H2 | "%s" | :white_check_mark: | :white_check_mark: | :white_check_mark: | UUID | :x: | :white_check_mark: | :x: |
+| Maria | \`%s\` | :white_check_mark: | :white_check_mark: | :x: | UUID | :x: | :x: | :white_check_mark: |
+| MS SQL | [%s] | :white_check_mark: | :white_check_mark: | :x: | UNIQUEIDE... | :white_check_mark: | :x: | :white_check_mark: |
+| MySQL | \`%s\` | :white_check_mark: | :white_check_mark: | :x: | CHAR(36) | :x: | :x: | :white_check_mark: |
+| Oracle | "%s" | :large_orange_diamond: | :white_check_mark: | :x: | VARCHAR2(36) | :x: | :white_check_mark: | :white_check_mark: |
+| Postgres | "%s" | :white_check_mark: | :white_check_mark: | :white_check_mark: | UUID | :white_check_mark: | :white_check_mark: :white_check_mark: | :x: |
+| Sqlite | "%s" | :x: | :white_check_mark: | :x: | CHAR(36) | :x: | :x: | :x: |
Type system
-| KClass | COLUMN | Databases | db-messiah | db-messiah-extra |
-|:---------------:|:------------:|:------------------------------------:|:-----------------------:|:--------------------------:|
-| Boolean | BOOL | :white_check_mark: | :white_check_mark: | :x: |
-| Char | CHAR | :white_check_mark: | :white_check_mark: | :x: |
-| String | VARCHAR(100) | :white_check_mark: | :white_check_mark: | :x: |
-| Float | FLOAT | :white_check_mark: | :white_check_mark: | :x: |
-| Double | DOUBLE | :white_check_mark: | :white_check_mark: | :x: |
-| Byte / UByte | TINYINT | :white_check_mark: | :white_check_mark: | :x: |
-| Short / UShort | SMALLINT | :white_check_mark: | :white_check_mark: | :x: |
-| Int / Uint | INTEGER | :white_check_mark: | :white_check_mark: | :x: |
-| Long / ULong | BIGINT | :white_check_mark: | :white_check_mark: | :x: |
-| Instant | DATETIME | Sqlite, Mysql, MSSql, Maria, H2, DB2 | Java :white_check_mark: | kotlinx :white_check_mark: |
-| Instant | TIMESTAMP | Derby, Postgres, Oracle | Java :white_check_mark: | kotlinx :white_check_mark: |
-| LocalDateTime | :x: | :x: | Java :x: | kotlinx :x: |
-| LocalDate | DATE | :white_check_mark: | Java :white_check_mark: | kotlinx :white_check_mark: |
-| LocalTime | TIME | :white_check_mark: but Oracle | Java :white_check_mark: | kotlinx :white_check_mark: |
-| LocalTime | NUMBER(5, 0) | Oracle | Java :white_check_mark: | kotlinx :white_check_mark: |>
-
+| KClass | COLUMN | Databases | db-messiah | db-messiah-extra |
+|:--------------:|:------------:|:------------------------------------:|:-----------------------:|:--------------------------:|
+| Boolean | BOOL | :white_check_mark: | :white_check_mark: | :x: |
+| Char | CHAR | :white_check_mark: | :white_check_mark: | :x: |
+| String | VARCHAR(100) | :white_check_mark: | :white_check_mark: | :x: |
+| Float | FLOAT | :white_check_mark: | :white_check_mark: | :x: |
+| Double | DOUBLE | :white_check_mark: | :white_check_mark: | :x: |
+| Byte / UByte | TINYINT | :white_check_mark: | :white_check_mark: | :x: |
+| Short / UShort | SMALLINT | :white_check_mark: | :white_check_mark: | :x: |
+| Int / Uint | INTEGER | :white_check_mark: | :white_check_mark: | :x: |
+| Long / ULong | BIGINT | :white_check_mark: | :white_check_mark: | :x: |
+| Instant | DATETIME | Sqlite, Mysql, MSSql, Maria, H2, DB2 | Java :white_check_mark: | kotlinx :white_check_mark: |
+| Instant | TIMESTAMP | Derby, Postgres, Oracle | Java :white_check_mark: | kotlinx :white_check_mark: |
+| LocalDateTime | :x: | :x: | Java :x: | kotlinx :x: |
+| LocalDate | DATE | :white_check_mark: | Java :white_check_mark: | kotlinx :white_check_mark: |
+| LocalTime | TIME | :white_check_mark: but Oracle | Java :white_check_mark: | kotlinx :white_check_mark: |
+| LocalTime | NUMBER(5, 0) | Oracle | Java :white_check_mark: | kotlinx :white_check_mark: |>
PRIMARY KEY
@@ -452,7 +473,6 @@ For detailed explanation read about INSERT BATCH
-
UPDATE / DELETE
diff --git a/build.gradle.kts b/build.gradle.kts
index c8acf1a1..1cf86c69 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -203,8 +203,8 @@ tasks.register("readme") {
var readme = File("./src/tutorials/kotlin/Test_README.md").readText()
val dependencies = mutableListOf(
- "implementation(\"${project.group}:${project.name}:$version\") // Required",
- "implementation(\"${project.group}:${project.name}-extra:$version\") // Optional",
+ "implementation(\"${project.group}:${project.name}:${project.version}\") // Required",
+ "implementation(\"${project.group}:${project.name}-extra:${project.version}\") // Optional",
)
dependencies += optionals.map { "implementation(\"$it\") //Optional" }
diff --git a/src/tutorials/kotlin/Test_README.kt b/src/tutorials/kotlin/Test_README.kt
index 54cd3b0c..b7369eb5 100644
--- a/src/tutorials/kotlin/Test_README.kt
+++ b/src/tutorials/kotlin/Test_README.kt
@@ -56,6 +56,10 @@ data class Unsafe(
val pk: UUID = UUID.randomUUID(), // Unsafe UUID manual primary key
val created: Instant = Instant.now() // Support for java.time.*
)
+
+/** QUERY DTO */
+
+data class Out(val child_value: String, val parent_value: String)
// STOP
// START 'Database'
@@ -82,12 +86,13 @@ val sqliteSerializer = SqliteSerializer(
)
),
),
+ globalOutputs = listOf(Out::class)
)
/** POSTGRES */
val pgSerializer = PgSerializer(
- globalSerializers = BasicTS.sqlite + JavaTimeTS.postgresql,
+ globalSerializers = BasicTS.postgresql + JavaTimeTS.postgresql,
schemas = listOf(
PgSchema(
name = "name", tables = listOf(
@@ -202,10 +207,22 @@ fun main() {
WHERE ${it.column(Child::value)} = ${it.input(Parent::value)}
"""
}
- println(moreChildren)
assert(moreChildren == listOf(children[3]))
+
+ // START 'Selective join'
+ val outputs = it.query.get(output = Out::class, input = parent) {
+ """
+ SELECT
+ ${it.column(Child::value)} AS ${it.name(Out::child_value)},
+ ${it.column(Parent::value)} AS ${it.name(Out::parent_value)}
+ FROM ${it.table()}
+ INNER JOIN ${it.table()} ON ${it.column(Parent::pk)} = ${it.column(Child::parent_pk)}
+ WHERE ${it.column(Child::value)} = ${it.input(Parent::value)}
+ """
+ }
+ assert(outputs == listOf(Out(child_value="value_3", parent_value="value_3")))
+ // STOP
}
- // STOP
// START 'Transactions'
sqlite.transaction { // Any exception inside will trigger rollback ALL!
diff --git a/src/tutorials/kotlin/Test_README.md b/src/tutorials/kotlin/Test_README.md
index e1437c29..c88bbc81 100644
--- a/src/tutorials/kotlin/Test_README.md
+++ b/src/tutorials/kotlin/Test_README.md
@@ -1,5 +1,8 @@
db-messiah
-Kotlin lib. for enterprise database development
+
+ Lib. similar to JetBrains/Exposed, but without annotations, DSLs or DAOs...
+ Lib. has a strong focus on clean architecture and simplicity.
+
+290 unit,
+210 e2e,
@@ -11,6 +14,11 @@
tested
+86% instruction coverage
+
+```kotlin
+// START 'Selective join'
+```
+
@@ -158,52 +166,51 @@ For detailed explanation read about Specifications
-| | Schema | Serializer | Service | Basic types | java.time.* types |
-|:--------:|:-------------:|:----------------:|:-------------:|:-------------------:|:----------------------:|
-| DB2 | Db2Schema | Db2Serializer | Db2Service | BasicTS.db2 | JavaTimeTS.db2 |
-| Derby | DerbySchema | DerbySerializer | DerbyService | BasicTS.derby | JavaTimeTS.derby |
-| H2 | H2Schema | H2Serializer | H2Service | BasicTS.h2 | JavaTimeTS.h2 |
-| Maria | MariaSchema | MariaSerializer | MariaService | BasicTS.maria | JavaTimeTS.maria |
-| MS SQL | MssqlSchema | MssqlSerializer | MssqlService | BasicTS.mssql | JavaTimeTS.mssql |
-| MySQL | MysqlSchema | MysqlSerializer | MysqlService | BasicTS.mysql | JavaTimeTS.mysql |
-| Oracle | OracleSchema | OracleSerializer | OracleService | BasicTS.oracle | JavaTimeTS.oracle |
-| Postgres | PgSchema | PgSerializer | PgService | BasicTS. postgresql | JavaTimeTS. postgresql |
-| Sqlite | :x: | SqliteSerializer | SqliteService | BasicTS.sqlite | JavaTimeTS.sqlite |
+| | Schema | Serializer | Service | Basic types | java.time.* types |
+|:--------:|:------------:|:----------------:|:-------------:|:-------------------:|:----------------------:|
+| DB2 | Db2Schema | Db2Serializer | Db2Service | BasicTS.db2 | JavaTimeTS.db2 |
+| Derby | DerbySchema | DerbySerializer | DerbyService | BasicTS.derby | JavaTimeTS.derby |
+| H2 | H2Schema | H2Serializer | H2Service | BasicTS.h2 | JavaTimeTS.h2 |
+| Maria | MariaSchema | MariaSerializer | MariaService | BasicTS.maria | JavaTimeTS.maria |
+| MS SQL | MssqlSchema | MssqlSerializer | MssqlService | BasicTS.mssql | JavaTimeTS.mssql |
+| MySQL | MysqlSchema | MysqlSerializer | MysqlService | BasicTS.mysql | JavaTimeTS.mysql |
+| Oracle | OracleSchema | OracleSerializer | OracleService | BasicTS.oracle | JavaTimeTS.oracle |
+| Postgres | PgSchema | PgSerializer | PgService | BasicTS. postgresql | JavaTimeTS. postgresql |
+| Sqlite | :x: | SqliteSerializer | SqliteService | BasicTS.sqlite | JavaTimeTS.sqlite |
Features
-| | Escape | Schema | Auto INT PK | Auto UUID PK | UUID column | Many queries | Cascade | Procedure |
+| | Escape | Schema | Auto INT PK | Auto UUID PK | UUID column | Many queries | Cascade | Procedure |
|:--------:|:------:|:----------------------:|:------------------:|:------------------:|:------------:|:------------------:|:-------------------------------------:|:----------------------:|
-| DB2 | "%s" | :large_orange_diamond: | :white_check_mark: | :x: | CHAR(36) | :x: | :x: | :large_orange_diamond: |
-| Derby | "%s" | :white_check_mark: | :white_check_mark: | :x: | CHAR(36) | :x: | :x: | :x: |
-| H2 | "%s" | :white_check_mark: | :white_check_mark: | :white_check_mark: | UUID | :x: | :white_check_mark: | :x: |
-| Maria | \`%s\` | :white_check_mark: | :white_check_mark: | :x: | UUID | :x: | :x: | :white_check_mark: |
-| MS SQL | [%s] | :white_check_mark: | :white_check_mark: | :x: | UNIQUEIDE... | :white_check_mark: | :x: | :white_check_mark: |
-| MySQL | \`%s\` | :white_check_mark: | :white_check_mark: | :x: | CHAR(36) | :x: | :x: | :white_check_mark: |
-| Oracle | "%s" | :large_orange_diamond: | :white_check_mark: | :x: | VARCHAR2(36) | :x: | :white_check_mark: | :white_check_mark: |
-| Postgres | "%s" | :white_check_mark: | :white_check_mark: | :white_check_mark: | UUID | :white_check_mark: | :white_check_mark: :white_check_mark: | :x: |
-| Sqlite | "%s" | :x: | :white_check_mark: | :x: | CHAR(36) | :x: | :x: | :x: |
+| DB2 | "%s" | :large_orange_diamond: | :white_check_mark: | :x: | CHAR(36) | :x: | :x: | :large_orange_diamond: |
+| Derby | "%s" | :white_check_mark: | :white_check_mark: | :x: | CHAR(36) | :x: | :x: | :x: |
+| H2 | "%s" | :white_check_mark: | :white_check_mark: | :white_check_mark: | UUID | :x: | :white_check_mark: | :x: |
+| Maria | \`%s\` | :white_check_mark: | :white_check_mark: | :x: | UUID | :x: | :x: | :white_check_mark: |
+| MS SQL | [%s] | :white_check_mark: | :white_check_mark: | :x: | UNIQUEIDE... | :white_check_mark: | :x: | :white_check_mark: |
+| MySQL | \`%s\` | :white_check_mark: | :white_check_mark: | :x: | CHAR(36) | :x: | :x: | :white_check_mark: |
+| Oracle | "%s" | :large_orange_diamond: | :white_check_mark: | :x: | VARCHAR2(36) | :x: | :white_check_mark: | :white_check_mark: |
+| Postgres | "%s" | :white_check_mark: | :white_check_mark: | :white_check_mark: | UUID | :white_check_mark: | :white_check_mark: :white_check_mark: | :x: |
+| Sqlite | "%s" | :x: | :white_check_mark: | :x: | CHAR(36) | :x: | :x: | :x: |
Type system
-| KClass | COLUMN | Databases | db-messiah | db-messiah-extra |
-|:---------------:|:------------:|:------------------------------------:|:-----------------------:|:--------------------------:|
-| Boolean | BOOL | :white_check_mark: | :white_check_mark: | :x: |
-| Char | CHAR | :white_check_mark: | :white_check_mark: | :x: |
-| String | VARCHAR(100) | :white_check_mark: | :white_check_mark: | :x: |
-| Float | FLOAT | :white_check_mark: | :white_check_mark: | :x: |
-| Double | DOUBLE | :white_check_mark: | :white_check_mark: | :x: |
-| Byte / UByte | TINYINT | :white_check_mark: | :white_check_mark: | :x: |
-| Short / UShort | SMALLINT | :white_check_mark: | :white_check_mark: | :x: |
-| Int / Uint | INTEGER | :white_check_mark: | :white_check_mark: | :x: |
-| Long / ULong | BIGINT | :white_check_mark: | :white_check_mark: | :x: |
-| Instant | DATETIME | Sqlite, Mysql, MSSql, Maria, H2, DB2 | Java :white_check_mark: | kotlinx :white_check_mark: |
-| Instant | TIMESTAMP | Derby, Postgres, Oracle | Java :white_check_mark: | kotlinx :white_check_mark: |
-| LocalDateTime | :x: | :x: | Java :x: | kotlinx :x: |
-| LocalDate | DATE | :white_check_mark: | Java :white_check_mark: | kotlinx :white_check_mark: |
-| LocalTime | TIME | :white_check_mark: but Oracle | Java :white_check_mark: | kotlinx :white_check_mark: |
-| LocalTime | NUMBER(5, 0) | Oracle | Java :white_check_mark: | kotlinx :white_check_mark: |>
-
+| KClass | COLUMN | Databases | db-messiah | db-messiah-extra |
+|:--------------:|:------------:|:------------------------------------:|:-----------------------:|:--------------------------:|
+| Boolean | BOOL | :white_check_mark: | :white_check_mark: | :x: |
+| Char | CHAR | :white_check_mark: | :white_check_mark: | :x: |
+| String | VARCHAR(100) | :white_check_mark: | :white_check_mark: | :x: |
+| Float | FLOAT | :white_check_mark: | :white_check_mark: | :x: |
+| Double | DOUBLE | :white_check_mark: | :white_check_mark: | :x: |
+| Byte / UByte | TINYINT | :white_check_mark: | :white_check_mark: | :x: |
+| Short / UShort | SMALLINT | :white_check_mark: | :white_check_mark: | :x: |
+| Int / Uint | INTEGER | :white_check_mark: | :white_check_mark: | :x: |
+| Long / ULong | BIGINT | :white_check_mark: | :white_check_mark: | :x: |
+| Instant | DATETIME | Sqlite, Mysql, MSSql, Maria, H2, DB2 | Java :white_check_mark: | kotlinx :white_check_mark: |
+| Instant | TIMESTAMP | Derby, Postgres, Oracle | Java :white_check_mark: | kotlinx :white_check_mark: |
+| LocalDateTime | :x: | :x: | Java :x: | kotlinx :x: |
+| LocalDate | DATE | :white_check_mark: | Java :white_check_mark: | kotlinx :white_check_mark: |
+| LocalTime | TIME | :white_check_mark: but Oracle | Java :white_check_mark: | kotlinx :white_check_mark: |
+| LocalTime | NUMBER(5, 0) | Oracle | Java :white_check_mark: | kotlinx :white_check_mark: |>
PRIMARY KEY
@@ -214,7 +221,6 @@ For detailed explanation read about INSERT BATCH
-
UPDATE / DELETE