-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add annotations for simple table actions * Update README.md * Add missing type parameters after merge * Fix README.md * Improve update * Add @update annotation * Update README.md * Add @upsert
- Loading branch information
1 parent
36e2587
commit eb5b064
Showing
20 changed files
with
396 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package de.mineking.database | ||
|
||
@Target(AnnotationTarget.FIELD) | ||
@Retention(AnnotationRetention.RUNTIME) | ||
annotation class Column(val name: String = "") | ||
|
||
@Target(AnnotationTarget.FIELD) | ||
@Retention(AnnotationRetention.RUNTIME) | ||
annotation class AutoIncrement | ||
|
||
@Target(AnnotationTarget.FIELD) | ||
@Retention(AnnotationRetention.RUNTIME) | ||
annotation class AutoGenerate(val generator: String = "") | ||
|
||
@Target(AnnotationTarget.FIELD) | ||
@Retention(AnnotationRetention.RUNTIME) | ||
annotation class Key | ||
|
||
@Target(AnnotationTarget.FIELD) | ||
@Retention(AnnotationRetention.RUNTIME) | ||
annotation class Unique(val name: String = "") | ||
|
||
@Target(AnnotationTarget.FIELD) | ||
@Retention(AnnotationRetention.RUNTIME) | ||
annotation class Reference(val table: String) | ||
|
||
@Target(AnnotationTarget.FIELD) | ||
@Retention(AnnotationRetention.RUNTIME) | ||
annotation class Json(val binary: Boolean = false) | ||
|
||
|
||
|
||
@Target(AnnotationTarget.VALUE_PARAMETER) | ||
@Retention(AnnotationRetention.RUNTIME) | ||
annotation class Parameter(val name: String = "") | ||
|
||
@Target(AnnotationTarget.VALUE_PARAMETER) | ||
@Retention(AnnotationRetention.RUNTIME) | ||
annotation class KeyParameter(val name: String = "", val operation: String = " = ") | ||
|
||
@Target(AnnotationTarget.FUNCTION) | ||
@Retention(AnnotationRetention.RUNTIME) | ||
annotation class Select | ||
|
||
@Target(AnnotationTarget.FUNCTION) | ||
@Retention(AnnotationRetention.RUNTIME) | ||
annotation class Insert | ||
|
||
@Target(AnnotationTarget.FUNCTION) | ||
@Retention(AnnotationRetention.RUNTIME) | ||
annotation class Update | ||
|
||
@Target(AnnotationTarget.FUNCTION) | ||
@Retention(AnnotationRetention.RUNTIME) | ||
annotation class Upsert | ||
|
||
@Target(AnnotationTarget.FUNCTION) | ||
@Retention(AnnotationRetention.RUNTIME) | ||
annotation class Delete |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,13 +31,13 @@ class UpdateTest { | |
|
||
@Test | ||
fun updateName() { | ||
assertEquals(1, table.update(UserDao::name, value("Test"), where = property(UserDao::id) isEqualTo value(1)).value) | ||
assertEquals(1, table.update(property(UserDao::name) to value("Test"), where = property(UserDao::id) isEqualTo value(1)).value) | ||
assertEquals("Test", table.selectValue(property(UserDao::name), where = property(UserDao::id) isEqualTo value(1)).first()) | ||
} | ||
|
||
@Test | ||
fun updateConflict() { | ||
val result = table.update(UserDao::email, value("[email protected]"), where = property(UserDao::id) isEqualTo value(1)) | ||
val result = table.update(property(UserDao::email) to value("[email protected]"), where = property(UserDao::id) isEqualTo value(1)) | ||
|
||
assertTrue(result.isError()) | ||
assertTrue(result.uniqueViolation) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.