update exposed version

This commit is contained in:
InsanusMokrassar 2024-01-11 23:09:17 +06:00
parent 805ab32b24
commit 7651388b5c
11 changed files with 25 additions and 23 deletions

View File

@ -2,6 +2,8 @@
## 0.20.26 ## 0.20.26
* `Versions`:
* `Exposed`: `0.45.0` -> `0.46.0`. **This update brinds new api deprecations in exposed**
* `Resources`: * `Resources`:
* Add opportunity to get default translation by passing `null` as `IetfLang` argument * Add opportunity to get default translation by passing `null` as `IetfLang` argument
* Add several useful extensions to get translations in `JS` target * Add several useful extensions to get translations in `JS` target

View File

@ -7,7 +7,7 @@ kt-coroutines = "1.7.3"
kslog = "1.3.1" kslog = "1.3.1"
jb-compose = "1.5.11" jb-compose = "1.5.11"
jb-exposed = "0.45.0" jb-exposed = "0.46.0"
jb-dokka = "1.9.10" jb-dokka = "1.9.10"
korlibs = "5.3.0" korlibs = "5.3.0"
@ -26,7 +26,7 @@ kotlin-poet = "1.15.3"
versions = "0.50.0" versions = "0.50.0"
android-gradle = "8.2.0" android-gradle = "8.2.1"
dexcount = "4.0.0" dexcount = "4.0.0"
android-coreKtx = "1.12.0" android-coreKtx = "1.12.0"

View File

@ -35,14 +35,14 @@ abstract class AbstractExposedReadCRUDRepo<ObjectType, IdType>(
} }
override suspend fun getById(id: IdType): ObjectType? { override suspend fun getById(id: IdType): ObjectType? {
return transaction(db = database) { return transaction(db = database) {
select { selectAll().where {
selectById(id) selectById(id)
}.limit(1).firstOrNull() ?.asObject }.limit(1).firstOrNull() ?.asObject
} }
} }
override suspend fun contains(id: IdType): Boolean = transaction(db = database) { override suspend fun contains(id: IdType): Boolean = transaction(db = database) {
select { selectById(id) }.limit(1).any() selectAll().where { selectById(id) }.limit(1).any()
} }
override suspend fun getAll(): Map<IdType, ObjectType> = transaction(database) { override suspend fun getAll(): Map<IdType, ObjectType> = transaction(database) {

View File

@ -101,7 +101,7 @@ abstract class AbstractExposedWriteCRUDRepo<ObjectType, IdType, InputValueType>(
}.let { }.let {
if (it > 0) { if (it > 0) {
transaction(db = database) { transaction(db = database) {
select { selectAll().where {
selectById(this, id) selectById(this, id)
}.limit(1).firstOrNull() ?.asObject }.limit(1).firstOrNull() ?.asObject
} }
@ -142,7 +142,7 @@ abstract class AbstractExposedWriteCRUDRepo<ObjectType, IdType, InputValueType>(
ids ids
} else { } else {
ids.filter { ids.filter {
select { selectById(it) }.limit(1).none() selectAll().where { selectById(it) }.limit(1).none()
} }
} }
}.forEach { }.forEach {

View File

@ -65,7 +65,7 @@ abstract class AbstractExposedKeyValueRepo<Key, Value>(
override suspend fun unsetWithValues(toUnset: List<Value>) { override suspend fun unsetWithValues(toUnset: List<Value>) {
transaction(database) { transaction(database) {
toUnset.flatMap { toUnset.flatMap {
val keys = select { selectByValue(it) }.mapNotNull { it.asKey } val keys = selectAll().where { selectByValue(it) }.mapNotNull { it.asKey }
deleteWhere { selectByIds(it, keys) } deleteWhere { selectByIds(it, keys) }
keys keys
} }

View File

@ -24,11 +24,11 @@ abstract class AbstractExposedReadKeyValueRepo<Key, Value>(
abstract val selectByValue: ISqlExpressionBuilder.(Value) -> Op<Boolean> abstract val selectByValue: ISqlExpressionBuilder.(Value) -> Op<Boolean>
override suspend fun get(k: Key): Value? = transaction(database) { override suspend fun get(k: Key): Value? = transaction(database) {
select { selectById(k) }.limit(1).firstOrNull() ?.asObject selectAll().where { selectById(k) }.limit(1).firstOrNull() ?.asObject
} }
override suspend fun contains(key: Key): Boolean = transaction(database) { override suspend fun contains(key: Key): Boolean = transaction(database) {
select { selectById(key) }.limit(1).any() selectAll().where { selectById(key) }.limit(1).any()
} }
override suspend fun getAll(): Map<Key, Value> = transaction(database) { selectAll().associate { it.asKey to it.asObject } } override suspend fun getAll(): Map<Key, Value> = transaction(database) { selectAll().associate { it.asKey to it.asObject } }
@ -46,7 +46,7 @@ abstract class AbstractExposedReadKeyValueRepo<Key, Value>(
} }
override suspend fun keys(v: Value, pagination: Pagination, reversed: Boolean): PaginationResult<Key> = transaction(database) { override suspend fun keys(v: Value, pagination: Pagination, reversed: Boolean): PaginationResult<Key> = transaction(database) {
select { selectByValue(v) }.selectPaginated( selectAll().where { selectByValue(v) }.selectPaginated(
pagination, pagination,
keyColumn, keyColumn,
reversed reversed

View File

@ -65,7 +65,7 @@ open class ExposedKeyValueRepo<Key, Value>(
override suspend fun unsetWithValues(toUnset: List<Value>) { override suspend fun unsetWithValues(toUnset: List<Value>) {
transaction(database) { transaction(database) {
toUnset.flatMap { toUnset.flatMap {
val keys = select { valueColumn.eq(it) }.mapNotNull { it[keyColumn] } val keys = selectAll().where { valueColumn.eq(it) }.mapNotNull { it[keyColumn] }
deleteWhere { keyColumn.inList(keys) } deleteWhere { keyColumn.inList(keys) }
keys keys
} }

View File

@ -29,7 +29,7 @@ abstract class AbstractExposedKeyValuesRepo<Key, Value>(
transaction(database) { transaction(database) {
toAdd.keys.flatMap { k -> toAdd.keys.flatMap { k ->
toAdd[k] ?.mapNotNull { v -> toAdd[k] ?.mapNotNull { v ->
if (select { selectById(k).and(selectByValue(v)) }.limit(1).any()) { if (selectAll().where { selectById(k).and(selectByValue(v)) }.limit(1).any()) {
return@mapNotNull null return@mapNotNull null
} }
val insertResult = insert { val insertResult = insert {

View File

@ -19,7 +19,7 @@ abstract class AbstractExposedReadKeyValuesRepo<Key, Value>(
get() = asKey get() = asKey
abstract val selectByValue: ISqlExpressionBuilder.(Value) -> Op<Boolean> abstract val selectByValue: ISqlExpressionBuilder.(Value) -> Op<Boolean>
override suspend fun count(k: Key): Long = transaction(database) { select { selectById(k) }.count() } override suspend fun count(k: Key): Long = transaction(database) { selectAll().where { selectById(k) }.count() }
override suspend fun count(): Long = transaction(database) { selectAll().count() } override suspend fun count(): Long = transaction(database) { selectAll().count() }
@ -28,7 +28,7 @@ abstract class AbstractExposedReadKeyValuesRepo<Key, Value>(
pagination: Pagination, pagination: Pagination,
reversed: Boolean reversed: Boolean
): PaginationResult<Value> = transaction(database) { ): PaginationResult<Value> = transaction(database) {
select { selectById(k) }.selectPaginated( selectAll().where { selectById(k) }.selectPaginated(
pagination, pagination,
keyColumn, keyColumn,
reversed reversed
@ -55,7 +55,7 @@ abstract class AbstractExposedReadKeyValuesRepo<Key, Value>(
pagination: Pagination, pagination: Pagination,
reversed: Boolean reversed: Boolean
): PaginationResult<Key> = transaction(database) { ): PaginationResult<Key> = transaction(database) {
select { selectByValue(v) }.selectPaginated( selectAll().where { selectByValue(v) }.selectPaginated(
pagination, pagination,
keyColumn, keyColumn,
reversed reversed
@ -65,11 +65,11 @@ abstract class AbstractExposedReadKeyValuesRepo<Key, Value>(
} }
override suspend fun contains(k: Key): Boolean = transaction(database) { override suspend fun contains(k: Key): Boolean = transaction(database) {
select { selectById(k) }.limit(1).any() selectAll().where { selectById(k) }.limit(1).any()
} }
override suspend fun contains(k: Key, v: Value): Boolean = transaction(database) { override suspend fun contains(k: Key, v: Value): Boolean = transaction(database) {
select { selectById(k).and(selectByValue(v)) }.limit(1).any() selectAll().where { selectById(k).and(selectByValue(v)) }.limit(1).any()
} }
override suspend fun getAll(reverseLists: Boolean): Map<Key, List<Value>> = transaction(database) { override suspend fun getAll(reverseLists: Boolean): Map<Key, List<Value>> = transaction(database) {
@ -85,9 +85,9 @@ abstract class AbstractExposedReadKeyValuesRepo<Key, Value>(
override suspend fun getAll(k: Key, reverseLists: Boolean): List<Value> = transaction(database) { override suspend fun getAll(k: Key, reverseLists: Boolean): List<Value> = transaction(database) {
val query = if (reverseLists) { val query = if (reverseLists) {
select { selectById(k) }.orderBy(keyColumn, SortOrder.DESC) selectAll().where { selectById(k) }.orderBy(keyColumn, SortOrder.DESC)
} else { } else {
select { selectById(k) } selectAll().where { selectById(k) }
} }
query.map { query.map {
it.asObject it.asObject

View File

@ -34,7 +34,7 @@ open class ExposedKeyValuesRepo<Key, Value>(
transaction(database) { transaction(database) {
toAdd.keys.flatMap { k -> toAdd.keys.flatMap { k ->
toAdd[k] ?.mapNotNull { v -> toAdd[k] ?.mapNotNull { v ->
if (select { keyColumn.eq(k).and(valueColumn.eq(v)) }.limit(1).count() > 0) { if (selectAll().where { keyColumn.eq(k).and(valueColumn.eq(v)) }.limit(1).count() > 0) {
return@mapNotNull null return@mapNotNull null
} }
val insertResult = insert { val insertResult = insert {
@ -69,7 +69,7 @@ open class ExposedKeyValuesRepo<Key, Value>(
override suspend fun removeWithValue(v: Value) { override suspend fun removeWithValue(v: Value) {
transaction(database) { transaction(database) {
val keys = select { selectByValue(v) }.map { it.asKey } val keys = selectAll().where { selectByValue(v) }.map { it.asKey }
deleteWhere { SqlExpressionBuilder.selectByValue(v) } deleteWhere { SqlExpressionBuilder.selectByValue(v) }
keys keys
}.forEach { }.forEach {
@ -85,7 +85,7 @@ open class ExposedKeyValuesRepo<Key, Value>(
override suspend fun clearWithValue(v: Value) { override suspend fun clearWithValue(v: Value) {
transaction(database) { transaction(database) {
val toClear = select { selectByValue(v) } val toClear = selectAll().where { selectByValue(v) }
.asSequence() .asSequence()
.map { it.asKey to it.asObject } .map { it.asKey to it.asObject }
.groupBy { it.first } .groupBy { it.first }

View File

@ -26,7 +26,7 @@ class ExposedStandardVersionsRepoProxy(
} }
override suspend fun getTableVersion(tableName: String): Int? = transaction(database) { override suspend fun getTableVersion(tableName: String): Int? = transaction(database) {
select { tableNameColumn.eq(tableName) }.limit(1).firstOrNull() ?.getOrNull(tableVersionColumn) selectAll().where { tableNameColumn.eq(tableName) }.limit(1).firstOrNull() ?.getOrNull(tableVersionColumn)
} }
override suspend fun updateTableVersion(tableName: String, version: Int) { override suspend fun updateTableVersion(tableName: String, version: Int) {