From 29658c70a05826b5f9d05032fb715a6fab4a665a Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 17 Oct 2022 14:35:16 +0600 Subject: [PATCH 1/3] start 0.13.1 --- CHANGELOG.md | 2 ++ gradle.properties | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a223279e462..1f85e97d9a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog +## 0.13.1 + ## 0.13.0 **ALL DEPRECATIONS HAVE BEEN REMOVED** diff --git a/gradle.properties b/gradle.properties index 6934f01096a..845b5348644 100644 --- a/gradle.properties +++ b/gradle.properties @@ -14,5 +14,5 @@ crypto_js_version=4.1.1 # Project data group=dev.inmo -version=0.13.0 -android_code_version=158 +version=0.13.1 +android_code_version=159 From 2511e18d694e6599f12dd9d0f8f00bba98377129 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 17 Oct 2022 14:42:53 +0600 Subject: [PATCH 2/3] AbstractExposedWriteCRUDRepo#createAndInsertId now is optional and returns nullable value --- CHANGELOG.md | 4 ++++ .../exposed/AbstractExposedWriteCRUDRepo.kt | 20 +++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f85e97d9a0..ceb2dccd838 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## 0.13.1 +* `Repos`: + * `Exposed`: + * `AbstractExposedWriteCRUDRepo#createAndInsertId` now is optional and returns nullable value + ## 0.13.0 **ALL DEPRECATIONS HAVE BEEN REMOVED** diff --git a/repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed/AbstractExposedWriteCRUDRepo.kt b/repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed/AbstractExposedWriteCRUDRepo.kt index 1440b5cfaf1..50530bfd24f 100644 --- a/repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed/AbstractExposedWriteCRUDRepo.kt +++ b/repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed/AbstractExposedWriteCRUDRepo.kt @@ -27,8 +27,24 @@ abstract class AbstractExposedWriteCRUDRepo( protected abstract fun InsertStatement.asObject(value: InputValueType): ObjectType - protected abstract fun update(id: IdType, value: InputValueType, it: UpdateBuilder) - protected abstract fun createAndInsertId(value: InputValueType, it: InsertStatement): IdType + /** + * @param id Can be null only if [createAndInsertId] have returned null (it can be useful when you have + * autoincrement identifier) + * @param it Will be [UpdateStatement] when it is called from [update] method or [InsertStatement] from the [create] + * one. Anyway, it is main method where you should put the logic of table filling by [value] data + * + * @see createAndInsertId + */ + protected abstract fun update(id: IdType?, value: InputValueType, it: UpdateBuilder) + + /** + * Override this method to interact with [it] ([InsertStatement]) and put there new id with [IdType]. + * + * By default, have null value due to the fact that in the most cases users have [autoIncrement]ing id columns + * + * @return In case when id for the model has been created new [IdType] should be returned + */ + protected abstract fun createAndInsertId(value: InputValueType, it: InsertStatement): IdType? protected open fun insert(value: InputValueType, it: InsertStatement) { val id = createAndInsertId(value, it) From babbfc55e4a565006a43864885127546cb1ce80a Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 17 Oct 2022 15:31:27 +0600 Subject: [PATCH 3/3] update default of AbstractExposedWriteCRUDRepo --- .../micro_utils/repos/exposed/AbstractExposedWriteCRUDRepo.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed/AbstractExposedWriteCRUDRepo.kt b/repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed/AbstractExposedWriteCRUDRepo.kt index 50530bfd24f..289adb04f8b 100644 --- a/repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed/AbstractExposedWriteCRUDRepo.kt +++ b/repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed/AbstractExposedWriteCRUDRepo.kt @@ -44,7 +44,7 @@ abstract class AbstractExposedWriteCRUDRepo( * * @return In case when id for the model has been created new [IdType] should be returned */ - protected abstract fun createAndInsertId(value: InputValueType, it: InsertStatement): IdType? + protected open fun createAndInsertId(value: InputValueType, it: InsertStatement): IdType? = null protected open fun insert(value: InputValueType, it: InsertStatement) { val id = createAndInsertId(value, it)