Skip to content

Commit

Permalink
Tutorial for selective JOIN.
Browse files Browse the repository at this point in the history
  • Loading branch information
urosjarc committed Apr 4, 2024
1 parent a32ee3f commit ead7bf7
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 70 deletions.
90 changes: 55 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Type safe SQL framework for Kotlin, built on top of JDBC and reflection.<br>
Strong focus on simplicity and minimal developer interference.<br>
</h3>
<h4 align="center">Sqlite, Maria, MySQL, Postgres, MSSQL, Oracle, DB2, Derby, H2</h4>
<p align="center">
+<b>290</b> <a href="https://github.com/urosjarc/db-messiah/blob/master/src/test">unit</a>,
+<b>210</b> <a href="https://github.com/urosjarc/db-messiah/blob/master/src/e2e">e2e</a>,
Expand All @@ -12,12 +13,38 @@
<a href="https://github.com/urosjarc/db-messiah/blob/master/src/tutorials/kotlin/Test_README.md">autogenerated</a>
and
<a href="https://github.com/urosjarc/db-messiah/blob/master/src/tutorials/kotlin/Test_README.kt">tested</a><br>
+<b>86%</b> instruction coverage
+<b>86%</b> instruction coverage<br>
:heart:
</p>

<br>
<table width="100%" border="0">
<tr>
<td width="33%">
<h3 align="center"><a href="https://github.com/urosjarc/db-messiah-extra">db-messiah-extra</a></h3>
<p align="center">Extra utils for db-messiah. Support for kotlinx.datetime types, etc... </p>
</td>
<td width="33%" align="center">
<p><a href="#introduction">Introduction</a></p>
<p><a href="#get-started">Get started</a></p>
<p><a href="#tutorials">Tutorials</a></p>
<p><a href="#specifications">Specifications</a></p>
<p><a href="#arhitecture">Arhitecture</a></p>
<p><a href="https://urosjarc.github.io/db-messiah/">Documentation</a></p>
</td>
<td width="33%">
<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>
</tr>
</table>
<br>

<h2 align="center">Introduction</h2>

<p align="center">
Db Messiah scans user provided data classes and all their properties with reflection<br>
in order to know how to decode user actions like `db.table.create&#60;T&#62;()`<br>
in order to know how to decode user actions like <code>db.table.create&#60;T&#62;()</code><br>
into prepared SQL statements that are type safe, escaped, and free from SQL injections.
</p>

Expand All @@ -28,37 +55,40 @@
</p>

```kotlin
data class TestTable(var id: Int? = null, val column: String)
data class TestTable(var id: Int? = null, val col0: String, val col1: Double)

val db = SqliteService(
config = Properties().apply { this["jdbcUrl"] = "jdbc:sqlite::memory:" },
ser = SqliteSerializer(
tables = listOf(Table(TestTable::id)),
tables = listOf(Table(primaryKey = TestTable::id)),
globalSerializers = BasicTS.sqlite
)
)
```

<p align="center">
Db Messiah provides simplistic but feature complete clean syntax for database interactions...
Db Messiah provides simplistic but feature complete<br>
clean syntax for database interactions...
</p>

```kotlin
db.transaction {
it.table.drop<TestTable>()
it.roolback.all()
it.table.create<TestTable>()
val s0 = it.roolback.savePoint()
it.table.delete<TestTable>()
it.row.insert(TestTable(column = "col0"))
it.row.insert(TestTable(col0 = "col0", col1 = 1.3))
it.table.delete<TestTable>()
it.roolback.to(s0)
// ...
}
```

Because of reflection, it provides very simple solution for writing complex queries.<br>
There are only 4 methods to be remembered: it.<b>name</b>, it.<b>column</b>, it.<b>table</b>, it.<b>input</b><br>
Thats it! Everything else is joust ordinary SQL syntax that you know and love.<br>
This is an example how the most complex query in db-messiah looks like,
it's basically raw SQL with additional features like type safety and SQL injection .
<p align="center">
Because it is powered by reflection, it provides simple solution for writing complex queries.<br>
You need to remember only 4 methods: <b>name</b>, <b>column</b>, <b>table</b>, <b>input</b>,<br>
everything else is joust plain old SQL syntax that you know and love...<br>
</p>

```kotlin
Expand All @@ -72,32 +102,22 @@ val result = it.query.get(output = Out::class, input = parent) {
"""
}
```
<p align="center">
This gives db-messiah unparalleled simplicity which lowers companies<br>
technical cost and time to teach beginners their SQL framework.<br>
The only downside is that you will be bind to a specific database,<br>
which I think will never be a problem since you never switch database<br>
in the middle of project development phase...
</p>

<br>
<br>
<table width="100%" border="0">
<tr>
<td width="33%">
<h3 align="center"><a href="https://github.com/urosjarc/db-messiah-extra">db-messiah-extra</a></h3>
<p align="center">Extra utils for db-messiah. Support for kotlinx.datetime types, etc... </p>
</td>
<td width="33%" align="center">
<p><a href="#get-started">Get started</a></p>
<p><a href="#tutorials">Tutorials</a></p>
<p><a href="#specifications">Specifications</a></p>
<p><a href="#arhitecture">Arhitecture</a></p>
<p><a href="https://urosjarc.github.io/db-messiah/">Documentation</a></p>
</td>
<td width="33%">
<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>
</tr>
</table>
<br>
<br>
<p align="center">
With addition to simplicity, it also provides premium enterprise features,<br>
like query profiler, database export to visualization formats,<br>
with forever free Apache-2.0 license!<br>
:heart:
</p>

<h2 align="center">Get started</h2>
<br><h2 align="center">Get started</h2>

```kotlin
/** DEPENDENCIES */
Expand Down
9 changes: 6 additions & 3 deletions src/tutorials/kotlin/Test_README.kt
Original file line number Diff line number Diff line change
Expand Up @@ -305,23 +305,26 @@ fun main() {
}

// START 'Minimal example'
data class TestTable(var id: Int? = null, val column: String)
data class TestTable(var id: Int? = null, val col0: String, val col1: Double)

val db = SqliteService(
config = Properties().apply { this["jdbcUrl"] = "jdbc:sqlite::memory:" },
ser = SqliteSerializer(
tables = listOf(Table(TestTable::id)),
tables = listOf(Table(primaryKey = TestTable::id)),
globalSerializers = BasicTS.sqlite
)
)
// STOP
// START 'Minimal syntax'
db.transaction {
it.table.drop<TestTable>()
it.roolback.all()
it.table.create<TestTable>()
val s0 = it.roolback.savePoint()
it.table.delete<TestTable>()
it.row.insert(TestTable(column = "col0"))
it.row.insert(TestTable(col0 = "col0", col1 = 1.3))
it.table.delete<TestTable>()
it.roolback.to(s0)
// ...
}
// STOP
Expand Down
81 changes: 49 additions & 32 deletions src/tutorials/kotlin/Test_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Type safe SQL framework for Kotlin, built on top of JDBC and reflection.<br>
Strong focus on simplicity and minimal developer interference.<br>
</h3>
<h4 align="center">Sqlite, Maria, MySQL, Postgres, MSSQL, Oracle, DB2, Derby, H2</h4>
<p align="center">
+<b>290</b> <a href="https://github.com/urosjarc/db-messiah/blob/master/src/test">unit</a>,
+<b>210</b> <a href="https://github.com/urosjarc/db-messiah/blob/master/src/e2e">e2e</a>,
Expand All @@ -12,12 +13,38 @@
<a href="https://github.com/urosjarc/db-messiah/blob/master/src/tutorials/kotlin/Test_README.md">autogenerated</a>
and
<a href="https://github.com/urosjarc/db-messiah/blob/master/src/tutorials/kotlin/Test_README.kt">tested</a><br>
+<b>86%</b> instruction coverage
+<b>86%</b> instruction coverage<br>
:heart:
</p>

<br>
<table width="100%" border="0">
<tr>
<td width="33%">
<h3 align="center"><a href="https://github.com/urosjarc/db-messiah-extra">db-messiah-extra</a></h3>
<p align="center">Extra utils for db-messiah. Support for kotlinx.datetime types, etc... </p>
</td>
<td width="33%" align="center">
<p><a href="#introduction">Introduction</a></p>
<p><a href="#get-started">Get started</a></p>
<p><a href="#tutorials">Tutorials</a></p>
<p><a href="#specifications">Specifications</a></p>
<p><a href="#arhitecture">Arhitecture</a></p>
<p><a href="https://urosjarc.github.io/db-messiah/">Documentation</a></p>
</td>
<td width="33%">
<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>
</tr>
</table>
<br>

<h2 align="center">Introduction</h2>

<p align="center">
Db Messiah scans user provided data classes and all their properties with reflection<br>
in order to know how to decode user actions like `db.table.create&#60;T&#62;()`<br>
in order to know how to decode user actions like <code>db.table.create&#60;T&#62;()</code><br>
into prepared SQL statements that are type safe, escaped, and free from SQL injections.
</p>

Expand All @@ -32,49 +59,39 @@
```

<p align="center">
Db Messiah provides simplistic but feature complete clean syntax for database interactions...
Db Messiah provides simplistic but feature complete<br>
clean syntax for database interactions...
</p>

```kotlin
// START 'Minimal syntax'
```

Because of reflection, it provides very simple solution for writing complex queries.<br>
There are only 4 methods to be remembered: it.<b>name</b>, it.<b>column</b>, it.<b>table</b>, it.<b>input</b><br>
Thats it! Everything else is joust ordinary SQL syntax that you know and love.<br>
This is an example how the most complex query in db-messiah looks like,
it's basically raw SQL with additional features like type safety and SQL injection .
<p align="center">
Because it is powered by reflection, it provides simple solution for writing complex queries.<br>
You need to remember only 4 methods: <b>name</b>, <b>column</b>, <b>table</b>, <b>input</b>,<br>
everything else is joust plain old SQL syntax that you know and love...<br>
</p>

```kotlin
// START 'Selective join'
```
<p align="center">
This gives db-messiah unparalleled simplicity which lowers companies<br>
technical cost and time to teach beginners their SQL framework.<br>
The only downside is that you will be bind to a specific database,<br>
which I think will never be a problem since you never switch database<br>
in the middle of project development phase...
</p>

<br>
<br>
<table width="100%" border="0">
<tr>
<td width="33%">
<h3 align="center"><a href="https://github.com/urosjarc/db-messiah-extra">db-messiah-extra</a></h3>
<p align="center">Extra utils for db-messiah. Support for kotlinx.datetime types, etc... </p>
</td>
<td width="33%" align="center">
<p><a href="#get-started">Get started</a></p>
<p><a href="#tutorials">Tutorials</a></p>
<p><a href="#specifications">Specifications</a></p>
<p><a href="#arhitecture">Arhitecture</a></p>
<p><a href="https://urosjarc.github.io/db-messiah/">Documentation</a></p>
</td>
<td width="33%">
<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>
</tr>
</table>
<br>
<br>
<p align="center">
With addition to simplicity, it also provides premium enterprise features,<br>
like query profiler, database export to visualization formats,<br>
with forever free Apache-2.0 license!<br>
:heart:
</p>

<h2 align="center">Get started</h2>
<br><h2 align="center">Get started</h2>

```kotlin
/** DEPENDENCIES */
Expand Down

0 comments on commit ead7bf7

Please sign in to comment.