From b143516cb97abfc9ed62a0020c9de6ea4b9f1888 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Fri, 14 Oct 2022 16:25:25 +0800 Subject: [PATCH 01/59] Add a more generic simple ORM prototype implementation for Exposed with being tested and update the project version --- .../main/kotlin/VersionsAndDependencies.kt | 2 +- .../com/huanshankeji/exposed/SimpleOrm.kt | 260 ++++++++++++++++-- 2 files changed, 234 insertions(+), 28 deletions(-) diff --git a/buildSrc/src/main/kotlin/VersionsAndDependencies.kt b/buildSrc/src/main/kotlin/VersionsAndDependencies.kt index cfd5e0b..49b2c3a 100644 --- a/buildSrc/src/main/kotlin/VersionsAndDependencies.kt +++ b/buildSrc/src/main/kotlin/VersionsAndDependencies.kt @@ -2,7 +2,7 @@ import com.huanshankeji.CommonDependencies import com.huanshankeji.CommonGradleClasspathDependencies import com.huanshankeji.CommonVersions -val projectVersion = "0.2.4-SNAPSHOT" +val projectVersion = "0.3.0-SNAPSHOT" val commonVersions = CommonVersions() val commonDependencies = CommonDependencies(commonVersions) diff --git a/exposed/src/main/kotlin/com/huanshankeji/exposed/SimpleOrm.kt b/exposed/src/main/kotlin/com/huanshankeji/exposed/SimpleOrm.kt index c5c8dd9..f1d2c4d 100644 --- a/exposed/src/main/kotlin/com/huanshankeji/exposed/SimpleOrm.kt +++ b/exposed/src/main/kotlin/com/huanshankeji/exposed/SimpleOrm.kt @@ -1,64 +1,80 @@ package com.huanshankeji.exposed +import com.huanshankeji.exposed.OnDuplicateColumnPropertyNames.* +import com.huanshankeji.exposed.PropertyColumnMapping.* import org.jetbrains.exposed.dao.id.EntityID import org.jetbrains.exposed.sql.Alias import org.jetbrains.exposed.sql.Column import org.jetbrains.exposed.sql.ResultRow import org.jetbrains.exposed.sql.Table import org.jetbrains.exposed.sql.statements.UpdateBuilder -import kotlin.reflect.KFunction -import kotlin.reflect.KProperty1 +import kotlin.reflect.* import kotlin.reflect.full.memberProperties import kotlin.reflect.full.primaryConstructor +import kotlin.reflect.full.withNullability // Our own simple ORM implementation using reflection which should be adapted using annotation processors and code generation in the future. -interface SimpleOrm { - fun resultRowToData(resultRow: ResultRow): D - fun updateBuilderSetter(data: D): T.(UpdateBuilder) -> Unit +interface SimpleOrm { + fun resultRowToData(resultRow: ResultRow): Data + fun updateBuilderSetter(data: Data): TableT.(UpdateBuilder) -> Unit } -interface ReflectionBasedSimpleOrm : SimpleOrm { - val propertyAndColumnPairs: List, Column<*>>> - val dPrimaryConstructor: KFunction +fun ResultRow.getValue(column: Column<*>): Any? = + this[column].let { + if (it is EntityID<*>) it.value else it + } - override fun resultRowToData(resultRow: ResultRow): D { - val params = propertyAndColumnPairs.map { (_, tColumn) -> - resultRow[tColumn].let { - if (it is EntityID<*>) it.value else it - } - } - return dPrimaryConstructor.call(*params.toTypedArray()) +interface ReflectionBasedSimpleOrm : SimpleOrm { + val propertyAndColumnPairs: List, Column<*>>> + val dataPrimaryConstructor: KFunction + + override fun resultRowToData(resultRow: ResultRow): Data { + val params = propertyAndColumnPairs.map { (_, column) -> resultRow.getValue(column) } + return dataPrimaryConstructor.call(*params.toTypedArray()) } - override fun updateBuilderSetter(data: D): T.(UpdateBuilder) -> Unit = { - for ((dProperty, tColumn) in propertyAndColumnPairs) + override fun updateBuilderSetter(data: Data): TableT.(UpdateBuilder) -> Unit = { + for ((property, column) in propertyAndColumnPairs) @Suppress("UNCHECKED_CAST") - it[tColumn as Column] = dProperty(data) + it[column as Column] = property(data) } } -inline fun reflectionBasedSimpleOrm(table: T): ReflectionBasedSimpleOrm = - object : ReflectionBasedSimpleOrm { - val dClass = D::class - override val dPrimaryConstructor = dClass.primaryConstructor!! +inline fun reflectionBasedSimpleOrm(table: TableT): ReflectionBasedSimpleOrm = + object : ReflectionBasedSimpleOrm { + private val clazz = Data::class override val propertyAndColumnPairs = run { //require(dClass.isData) - val dMemberPropertyMap = dClass.memberProperties.associateBy { it.name } - val tMemberPropertyMap = T::class.memberProperties.associateBy { it.name } - dPrimaryConstructor.parameters.map { + val dataMemberPropertyMap = clazz.memberProperties.associateBy { it.name } + val columnMap = getColumnByPropertyNameMapWithTypeParameter(table) + dataPrimaryConstructor.parameters.map { val name = it.name!! - dMemberPropertyMap.getValue(name) to tMemberPropertyMap.getValue(name)(table) as Column<*> + dataMemberPropertyMap.getValue(name) to columnMap.getValue(name) } } + override val dataPrimaryConstructor = clazz.primaryConstructor!! } +@Suppress("UNCHECKED_CAST") +fun getColumnProperties(clazz: KClass): Sequence>> = + clazz.memberProperties.asSequence() + .filter { it.returnType.classifier == Column::class } + as Sequence>> + +fun getColumnPropertyByNameMap(clazz: KClass): Map>> = + getColumnProperties(clazz).associateBy { it.name } + +inline fun getColumnByPropertyNameMapWithTypeParameter(table: TableT): Map> = + getColumnPropertyByNameMap(TableT::class) + .mapValues { it.value(table) } + inline fun reflectionBasedSimpleOrmForAlias( tableOrm: ReflectionBasedSimpleOrm, alias: Alias ): ReflectionBasedSimpleOrm = object : ReflectionBasedSimpleOrm { - override val dPrimaryConstructor = tableOrm.dPrimaryConstructor + override val dataPrimaryConstructor = tableOrm.dataPrimaryConstructor override val propertyAndColumnPairs = tableOrm.propertyAndColumnPairs.map { it.first to alias[it.second] } } @@ -91,3 +107,193 @@ inline fun leftJoinResultRowToData( if (it[onColumn3] !== null) resultRowToData3(it) else null ) } + + +typealias PropertyColumnMappings = List> +//typealias LessStrictlyTypedPropertyColumnMappings = List> +/** In the order of the constructor arguments. */ +typealias ClassColumnMappings = PropertyColumnMappings + +sealed class PropertyColumnMapping(val property: KProperty1) { + class SqlPrimitive( + property: KProperty1, + val column: Column + ) : PropertyColumnMapping(property) + + class NestedClass( + property: KProperty1, + //val nullabilityDependentColumn: Column<*>, + val nestedMappings: ClassColumnMappings + ) : PropertyColumnMapping(property) +} + + +// see: https://kotlinlang.org/docs/basic-types.html, https://www.postgresql.org/docs/current/datatype.html +// Types that are commented out are not ensured to work yet. +val defaultSqlNotNullPrimitiveTypes = listOf( + typeOf(), typeOf(), typeOf(), typeOf(), /*typeOf(),*/ + typeOf(), typeOf(), typeOf(), typeOf(), + typeOf(), typeOf(), /*typeOf(),*/ + typeOf(), + typeOf(), + //typeOf(), + typeOf(), + // types related to time and date +) + +class ColumnWithPropertyName(val propertyName: String, val column: Column<*>) + +fun getColumnsWithPropertyNamesWithoutTypeParameter( + table: Table, clazz: KClass = table::class +): Sequence = + getColumnProperties(clazz).map { + @Suppress("UNCHECKED_CAST") + ColumnWithPropertyName(it.name, (it as KProperty1>)(table)) + } + +enum class OnDuplicateColumnPropertyNames { + CHOOSE_FIRST, THROW +} + +fun getColumnByPropertyNameMap( + tables: List, + onDuplicateColumnPropertyNames: OnDuplicateColumnPropertyNames = CHOOSE_FIRST // defaults to `CHOOSE_FIRST` because there are very likely to be duplicate columns when joining table +): Map> { + val columnsMap = tables.asSequence() + .flatMap { table -> getColumnsWithPropertyNamesWithoutTypeParameter(table) } + .groupBy { it.propertyName } + return columnsMap.mapValues { + it.value.run { + when (onDuplicateColumnPropertyNames) { + CHOOSE_FIRST -> first() + THROW -> single() + } + .column + } + } +} + + +fun getDefaultClassColumnMappings( + clazz: KClass, + columnByPropertyNameMap: Map>, + customMappings: PropertyColumnMappings = listOf() +): ClassColumnMappings { + val customMappingProperties = customMappings.asSequence().map { it.property }.toSet() + val dataMemberPropertyMap = + (clazz.memberProperties.toSet() - customMappingProperties).associateBy { it.name } + + return clazz.primaryConstructor!!.parameters.map { + val name = it.name!! + val property = dataMemberPropertyMap[name] + val notNullType = it.type.withNullability(false) + @Suppress("UNCHECKED_CAST") + if (notNullType in defaultSqlNotNullPrimitiveTypes) + SqlPrimitive(property as KProperty1, columnByPropertyNameMap.getValue(name) as Column) + else + NestedClass( + property as KProperty1, + getDefaultClassColumnMappings( + notNullType.classifier as KClass<*>, columnByPropertyNameMap + ) as ClassColumnMappings + ) + } +} + +fun getDefaultClassColumnMappings( + clazz: KClass, + tables: List
, + customMappings: PropertyColumnMappings = listOf(), + onDuplicateColumnPropertyNames: OnDuplicateColumnPropertyNames = CHOOSE_FIRST +): ClassColumnMappings = + getDefaultClassColumnMappings( + clazz, getColumnByPropertyNameMap(tables, onDuplicateColumnPropertyNames), customMappings + ) + +interface GenericSimpleOrm : SimpleOrm { + val neededColumns: List> +} + +/** Supports classes with nested composite class properties and multiple tables */ +class ReflectionBasedGenericSimpleOrm( + val clazz: KClass, + val classColumnMappings: ClassColumnMappings, +) : GenericSimpleOrm { + override val neededColumns = classColumnMappings.getNeededColumns() + override fun resultRowToData(resultRow: ResultRow): Data = + constructDataWithResultRow(clazz, classColumnMappings, resultRow) + + override fun updateBuilderSetter(data: Data): Table.(UpdateBuilder) -> Unit = { + setUpdateBuilder(classColumnMappings, data, it) + } +} + +fun constructDataWithResultRow( + clazz: KClass, classColumnMappings: ClassColumnMappings, resultRow: ResultRow +): Data = + clazz.primaryConstructor!!.call(*classColumnMappings.map { + when (it) { + is SqlPrimitive -> resultRow.getValue(it.column) + is NestedClass -> + // TODO: the nullable case is not implemented yet + @Suppress("UNCHECKED_CAST") + constructDataWithResultRow( + it.property.returnType.classifier as KClass, + it.nestedMappings as ClassColumnMappings, + resultRow + ) + } + }.toTypedArray()) + +fun setUpdateBuilder( + classColumnMappings: ClassColumnMappings, data: Data, updateBuilder: UpdateBuilder +) { + for (propertyColumnMapping in classColumnMappings) + when (propertyColumnMapping) { + is SqlPrimitive -> + @Suppress("UNCHECKED_CAST") + updateBuilder[propertyColumnMapping.column as Column] = propertyColumnMapping.property(data) + + is NestedClass -> { + @Suppress("NAME_SHADOWING", "UNCHECKED_CAST") + val propertyColumnMapping = propertyColumnMapping as NestedClass + val nestedMappings = propertyColumnMapping.nestedMappings + propertyColumnMapping.property(data)?.let { + setUpdateBuilder(nestedMappings, it, updateBuilder) + } + ?: setUpdateBuilderToNulls(nestedMappings, updateBuilder) + } + } +} + +fun ClassColumnMappings<*>.forEachColumn(block: (Column<*>) -> Unit) { + for (propertyColumnMapping in this) + when (propertyColumnMapping) { + is SqlPrimitive -> block(propertyColumnMapping.column) + is NestedClass -> { + propertyColumnMapping.nestedMappings.forEachColumn(block) + } + } +} + +fun setUpdateBuilderToNulls( + classColumnMappings: ClassColumnMappings, updateBuilder: UpdateBuilder +) = + classColumnMappings.forEachColumn { + @Suppress("UNCHECKED_CAST") + updateBuilder[it as Column] = null + } + +fun ClassColumnMappings<*>.getNeededColumns(): List> = + buildList { forEachColumn { add(it) } } + +inline fun reflectionBasedGenericSimpleOrm( + tables: List
, + customMappings: PropertyColumnMappings = listOf(), + onDuplicateColumnPropertyNames: OnDuplicateColumnPropertyNames = CHOOSE_FIRST +): ReflectionBasedGenericSimpleOrm { + val clazz = Data::class + return ReflectionBasedGenericSimpleOrm( + clazz, getDefaultClassColumnMappings(clazz, tables, customMappings, onDuplicateColumnPropertyNames) + ) +} From 136357521c72c07f76db58cca800ab71e1fdaec3 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Fri, 14 Oct 2022 20:16:13 +0800 Subject: [PATCH 02/59] Support enum types in the generic simple ORM implementation --- .../com/huanshankeji/exposed/SimpleOrm.kt | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/exposed/src/main/kotlin/com/huanshankeji/exposed/SimpleOrm.kt b/exposed/src/main/kotlin/com/huanshankeji/exposed/SimpleOrm.kt index f1d2c4d..983b7a2 100644 --- a/exposed/src/main/kotlin/com/huanshankeji/exposed/SimpleOrm.kt +++ b/exposed/src/main/kotlin/com/huanshankeji/exposed/SimpleOrm.kt @@ -9,6 +9,7 @@ import org.jetbrains.exposed.sql.ResultRow import org.jetbrains.exposed.sql.Table import org.jetbrains.exposed.sql.statements.UpdateBuilder import kotlin.reflect.* +import kotlin.reflect.full.isSubtypeOf import kotlin.reflect.full.memberProperties import kotlin.reflect.full.primaryConstructor import kotlin.reflect.full.withNullability @@ -115,7 +116,7 @@ typealias PropertyColumnMappings = List> typealias ClassColumnMappings = PropertyColumnMappings sealed class PropertyColumnMapping(val property: KProperty1) { - class SqlPrimitive( + class ExposedSqlPrimitive( property: KProperty1, val column: Column ) : PropertyColumnMapping(property) @@ -130,7 +131,7 @@ sealed class PropertyColumnMapping(val property: KPro // see: https://kotlinlang.org/docs/basic-types.html, https://www.postgresql.org/docs/current/datatype.html // Types that are commented out are not ensured to work yet. -val defaultSqlNotNullPrimitiveTypes = listOf( +val defaultNotNullExposedSqlPrimitiveTypes = listOf( typeOf(), typeOf(), typeOf(), typeOf(), /*typeOf(),*/ typeOf(), typeOf(), typeOf(), typeOf(), typeOf(), typeOf(), /*typeOf(),*/ @@ -141,6 +142,10 @@ val defaultSqlNotNullPrimitiveTypes = listOf( // types related to time and date ) +val enumType = typeOf>() +fun KType.notNullTypeIsExposedSqlPrimitiveType(): Boolean = + this in defaultNotNullExposedSqlPrimitiveTypes || isSubtypeOf(enumType) + class ColumnWithPropertyName(val propertyName: String, val column: Column<*>) fun getColumnsWithPropertyNamesWithoutTypeParameter( @@ -188,8 +193,11 @@ fun getDefaultClassColumnMappings( val property = dataMemberPropertyMap[name] val notNullType = it.type.withNullability(false) @Suppress("UNCHECKED_CAST") - if (notNullType in defaultSqlNotNullPrimitiveTypes) - SqlPrimitive(property as KProperty1, columnByPropertyNameMap.getValue(name) as Column) + if (notNullType.notNullTypeIsExposedSqlPrimitiveType()) + ExposedSqlPrimitive( + property as KProperty1, + columnByPropertyNameMap.getValue(name) as Column + ) else NestedClass( property as KProperty1, @@ -233,7 +241,7 @@ fun constructDataWithResultRow( ): Data = clazz.primaryConstructor!!.call(*classColumnMappings.map { when (it) { - is SqlPrimitive -> resultRow.getValue(it.column) + is ExposedSqlPrimitive -> resultRow.getValue(it.column) is NestedClass -> // TODO: the nullable case is not implemented yet @Suppress("UNCHECKED_CAST") @@ -250,7 +258,7 @@ fun setUpdateBuilder( ) { for (propertyColumnMapping in classColumnMappings) when (propertyColumnMapping) { - is SqlPrimitive -> + is ExposedSqlPrimitive -> @Suppress("UNCHECKED_CAST") updateBuilder[propertyColumnMapping.column as Column] = propertyColumnMapping.property(data) @@ -269,7 +277,7 @@ fun setUpdateBuilder( fun ClassColumnMappings<*>.forEachColumn(block: (Column<*>) -> Unit) { for (propertyColumnMapping in this) when (propertyColumnMapping) { - is SqlPrimitive -> block(propertyColumnMapping.column) + is ExposedSqlPrimitive -> block(propertyColumnMapping.column) is NestedClass -> { propertyColumnMapping.nestedMappings.forEachColumn(block) } From 9d7123dcc1d4d8668c26c8ac3f860ab13fe46e1a Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Fri, 14 Oct 2022 20:50:52 +0800 Subject: [PATCH 03/59] Replace some `listOf`s with `emptyList`s --- .../src/main/kotlin/com/huanshankeji/exposed/SimpleOrm.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/exposed/src/main/kotlin/com/huanshankeji/exposed/SimpleOrm.kt b/exposed/src/main/kotlin/com/huanshankeji/exposed/SimpleOrm.kt index 983b7a2..46f5419 100644 --- a/exposed/src/main/kotlin/com/huanshankeji/exposed/SimpleOrm.kt +++ b/exposed/src/main/kotlin/com/huanshankeji/exposed/SimpleOrm.kt @@ -182,7 +182,7 @@ fun getColumnByPropertyNameMap( fun getDefaultClassColumnMappings( clazz: KClass, columnByPropertyNameMap: Map>, - customMappings: PropertyColumnMappings = listOf() + customMappings: PropertyColumnMappings = emptyList() ): ClassColumnMappings { val customMappingProperties = customMappings.asSequence().map { it.property }.toSet() val dataMemberPropertyMap = @@ -211,7 +211,7 @@ fun getDefaultClassColumnMappings( fun getDefaultClassColumnMappings( clazz: KClass, tables: List
, - customMappings: PropertyColumnMappings = listOf(), + customMappings: PropertyColumnMappings = emptyList(), onDuplicateColumnPropertyNames: OnDuplicateColumnPropertyNames = CHOOSE_FIRST ): ClassColumnMappings = getDefaultClassColumnMappings( @@ -297,7 +297,7 @@ fun ClassColumnMappings<*>.getNeededColumns(): List> = inline fun reflectionBasedGenericSimpleOrm( tables: List
, - customMappings: PropertyColumnMappings = listOf(), + customMappings: PropertyColumnMappings = emptyList(), onDuplicateColumnPropertyNames: OnDuplicateColumnPropertyNames = CHOOSE_FIRST ): ReflectionBasedGenericSimpleOrm { val clazz = Data::class From 1625e2023d5eaca708a9f922dbc29a9139273622 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Fri, 14 Oct 2022 21:04:00 +0800 Subject: [PATCH 04/59] Add the `Skip` case for `PropertyColumnMapping` --- .../kotlin/com/huanshankeji/exposed/SimpleOrm.kt | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/exposed/src/main/kotlin/com/huanshankeji/exposed/SimpleOrm.kt b/exposed/src/main/kotlin/com/huanshankeji/exposed/SimpleOrm.kt index 46f5419..badaf08 100644 --- a/exposed/src/main/kotlin/com/huanshankeji/exposed/SimpleOrm.kt +++ b/exposed/src/main/kotlin/com/huanshankeji/exposed/SimpleOrm.kt @@ -126,6 +126,9 @@ sealed class PropertyColumnMapping(val property: KPro //val nullabilityDependentColumn: Column<*>, val nestedMappings: ClassColumnMappings ) : PropertyColumnMapping(property) + + class Skip(property: KProperty1) : + PropertyColumnMapping(property) } @@ -250,6 +253,8 @@ fun constructDataWithResultRow( it.nestedMappings as ClassColumnMappings, resultRow ) + + is Skip -> null } }.toTypedArray()) @@ -271,6 +276,8 @@ fun setUpdateBuilder( } ?: setUpdateBuilderToNulls(nestedMappings, updateBuilder) } + + is Skip -> {} } } @@ -278,9 +285,8 @@ fun ClassColumnMappings<*>.forEachColumn(block: (Column<*>) -> Unit) { for (propertyColumnMapping in this) when (propertyColumnMapping) { is ExposedSqlPrimitive -> block(propertyColumnMapping.column) - is NestedClass -> { - propertyColumnMapping.nestedMappings.forEachColumn(block) - } + is NestedClass -> propertyColumnMapping.nestedMappings.forEachColumn(block) + is Skip -> {} } } From b64ca0133e0deb3381ed01b77eaa7e985569eba3 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Sun, 16 Oct 2022 02:33:12 +0800 Subject: [PATCH 05/59] Replace `UpdateBuilder` with `UpdateBuilder<*>` --- .../main/kotlin/com/huanshankeji/exposed/SimpleOrm.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/exposed/src/main/kotlin/com/huanshankeji/exposed/SimpleOrm.kt b/exposed/src/main/kotlin/com/huanshankeji/exposed/SimpleOrm.kt index badaf08..92318e8 100644 --- a/exposed/src/main/kotlin/com/huanshankeji/exposed/SimpleOrm.kt +++ b/exposed/src/main/kotlin/com/huanshankeji/exposed/SimpleOrm.kt @@ -19,7 +19,7 @@ import kotlin.reflect.full.withNullability interface SimpleOrm { fun resultRowToData(resultRow: ResultRow): Data - fun updateBuilderSetter(data: Data): TableT.(UpdateBuilder) -> Unit + fun updateBuilderSetter(data: Data): TableT.(UpdateBuilder<*>) -> Unit } fun ResultRow.getValue(column: Column<*>): Any? = @@ -36,7 +36,7 @@ interface ReflectionBasedSimpleOrm : SimpleOrm) -> Unit = { + override fun updateBuilderSetter(data: Data): TableT.(UpdateBuilder<*>) -> Unit = { for ((property, column) in propertyAndColumnPairs) @Suppress("UNCHECKED_CAST") it[column as Column] = property(data) @@ -234,7 +234,7 @@ class ReflectionBasedGenericSimpleOrm( override fun resultRowToData(resultRow: ResultRow): Data = constructDataWithResultRow(clazz, classColumnMappings, resultRow) - override fun updateBuilderSetter(data: Data): Table.(UpdateBuilder) -> Unit = { + override fun updateBuilderSetter(data: Data): Table.(UpdateBuilder<*>) -> Unit = { setUpdateBuilder(classColumnMappings, data, it) } } @@ -259,7 +259,7 @@ fun constructDataWithResultRow( }.toTypedArray()) fun setUpdateBuilder( - classColumnMappings: ClassColumnMappings, data: Data, updateBuilder: UpdateBuilder + classColumnMappings: ClassColumnMappings, data: Data, updateBuilder: UpdateBuilder<*> ) { for (propertyColumnMapping in classColumnMappings) when (propertyColumnMapping) { @@ -291,7 +291,7 @@ fun ClassColumnMappings<*>.forEachColumn(block: (Column<*>) -> Unit) { } fun setUpdateBuilderToNulls( - classColumnMappings: ClassColumnMappings, updateBuilder: UpdateBuilder + classColumnMappings: ClassColumnMappings, updateBuilder: UpdateBuilder<*> ) = classColumnMappings.forEachColumn { @Suppress("UNCHECKED_CAST") From 24a83924a78d72210695b7f090006bbd819cec64 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Mon, 17 Oct 2022 17:54:18 +0800 Subject: [PATCH 06/59] Move `SimpleOrm` into the `classmapping` package --- .../huanshankeji/exposed/{ => classmapping}/SimpleOrm.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename exposed/src/main/kotlin/com/huanshankeji/exposed/{ => classmapping}/SimpleOrm.kt (98%) diff --git a/exposed/src/main/kotlin/com/huanshankeji/exposed/SimpleOrm.kt b/exposed/src/main/kotlin/com/huanshankeji/exposed/classmapping/SimpleOrm.kt similarity index 98% rename from exposed/src/main/kotlin/com/huanshankeji/exposed/SimpleOrm.kt rename to exposed/src/main/kotlin/com/huanshankeji/exposed/classmapping/SimpleOrm.kt index 92318e8..135e4f2 100644 --- a/exposed/src/main/kotlin/com/huanshankeji/exposed/SimpleOrm.kt +++ b/exposed/src/main/kotlin/com/huanshankeji/exposed/classmapping/SimpleOrm.kt @@ -1,7 +1,7 @@ -package com.huanshankeji.exposed +package com.huanshankeji.exposed.classmapping -import com.huanshankeji.exposed.OnDuplicateColumnPropertyNames.* -import com.huanshankeji.exposed.PropertyColumnMapping.* +import com.huanshankeji.exposed.classmapping.OnDuplicateColumnPropertyNames.* +import com.huanshankeji.exposed.classmapping.PropertyColumnMapping.* import org.jetbrains.exposed.dao.id.EntityID import org.jetbrains.exposed.sql.Alias import org.jetbrains.exposed.sql.Column From f95d35fb597e1567f33fff65073883a8a2f5d53a Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Mon, 17 Oct 2022 18:01:17 +0800 Subject: [PATCH 07/59] Rename `SimpleOrm` to `ClassPropertyMapping` and `ClassPropertyMapper` --- .../ClassPropertyMapping.kt} | 41 ++++++++++--------- 1 file changed, 21 insertions(+), 20 deletions(-) rename exposed/src/main/kotlin/com/huanshankeji/exposed/{classmapping/SimpleOrm.kt => classpropertymapping/ClassPropertyMapping.kt} (88%) diff --git a/exposed/src/main/kotlin/com/huanshankeji/exposed/classmapping/SimpleOrm.kt b/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/ClassPropertyMapping.kt similarity index 88% rename from exposed/src/main/kotlin/com/huanshankeji/exposed/classmapping/SimpleOrm.kt rename to exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/ClassPropertyMapping.kt index 135e4f2..1e75d32 100644 --- a/exposed/src/main/kotlin/com/huanshankeji/exposed/classmapping/SimpleOrm.kt +++ b/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/ClassPropertyMapping.kt @@ -1,7 +1,7 @@ -package com.huanshankeji.exposed.classmapping +package com.huanshankeji.exposed.classpropertymapping -import com.huanshankeji.exposed.classmapping.OnDuplicateColumnPropertyNames.* -import com.huanshankeji.exposed.classmapping.PropertyColumnMapping.* +import com.huanshankeji.exposed.classpropertymapping.OnDuplicateColumnPropertyNames.* +import com.huanshankeji.exposed.classpropertymapping.PropertyColumnMapping.* import org.jetbrains.exposed.dao.id.EntityID import org.jetbrains.exposed.sql.Alias import org.jetbrains.exposed.sql.Column @@ -14,10 +14,10 @@ import kotlin.reflect.full.memberProperties import kotlin.reflect.full.primaryConstructor import kotlin.reflect.full.withNullability -// Our own simple ORM implementation using reflection which should be adapted using annotation processors and code generation in the future. +// Our own class mapping implementation using reflection which should be adapted using annotation processors and code generation in the future. -interface SimpleOrm { +interface ClassPropertyMapper { fun resultRowToData(resultRow: ResultRow): Data fun updateBuilderSetter(data: Data): TableT.(UpdateBuilder<*>) -> Unit } @@ -27,7 +27,7 @@ fun ResultRow.getValue(column: Column<*>): Any? = if (it is EntityID<*>) it.value else it } -interface ReflectionBasedSimpleOrm : SimpleOrm { +interface ReflectionBasedClassPropertyMapper : ClassPropertyMapper { val propertyAndColumnPairs: List, Column<*>>> val dataPrimaryConstructor: KFunction @@ -43,8 +43,8 @@ interface ReflectionBasedSimpleOrm : SimpleOrm reflectionBasedSimpleOrm(table: TableT): ReflectionBasedSimpleOrm = - object : ReflectionBasedSimpleOrm { +inline fun reflectionBasedClassPropertyMapper(table: TableT): ReflectionBasedClassPropertyMapper = + object : ReflectionBasedClassPropertyMapper { private val clazz = Data::class override val propertyAndColumnPairs = run { //require(dClass.isData) @@ -71,12 +71,13 @@ inline fun getColumnByPropertyNameMapWithTypeParameter( getColumnPropertyByNameMap(TableT::class) .mapValues { it.value(table) } -inline fun reflectionBasedSimpleOrmForAlias( - tableOrm: ReflectionBasedSimpleOrm, alias: Alias -): ReflectionBasedSimpleOrm = - object : ReflectionBasedSimpleOrm { - override val dataPrimaryConstructor = tableOrm.dataPrimaryConstructor - override val propertyAndColumnPairs = tableOrm.propertyAndColumnPairs.map { it.first to alias[it.second] } +inline fun reflectionBasedClassPropertyMapperForAlias( + tableClassPropertyMapper: ReflectionBasedClassPropertyMapper, alias: Alias +): ReflectionBasedClassPropertyMapper = + object : ReflectionBasedClassPropertyMapper { + override val dataPrimaryConstructor = tableClassPropertyMapper.dataPrimaryConstructor + override val propertyAndColumnPairs = + tableClassPropertyMapper.propertyAndColumnPairs.map { it.first to alias[it.second] } } @@ -221,15 +222,15 @@ fun getDefaultClassColumnMappings( clazz, getColumnByPropertyNameMap(tables, onDuplicateColumnPropertyNames), customMappings ) -interface GenericSimpleOrm : SimpleOrm { +interface GenericClassPropertyMapper : ClassPropertyMapper { val neededColumns: List> } /** Supports classes with nested composite class properties and multiple tables */ -class ReflectionBasedGenericSimpleOrm( +class ReflectionBasedGenericClassPropertyMapper( val clazz: KClass, val classColumnMappings: ClassColumnMappings, -) : GenericSimpleOrm { +) : GenericClassPropertyMapper { override val neededColumns = classColumnMappings.getNeededColumns() override fun resultRowToData(resultRow: ResultRow): Data = constructDataWithResultRow(clazz, classColumnMappings, resultRow) @@ -301,13 +302,13 @@ fun setUpdateBuilderToNulls( fun ClassColumnMappings<*>.getNeededColumns(): List> = buildList { forEachColumn { add(it) } } -inline fun reflectionBasedGenericSimpleOrm( +inline fun reflectionBasedGenericClassPropertyMapper( tables: List
, customMappings: PropertyColumnMappings = emptyList(), onDuplicateColumnPropertyNames: OnDuplicateColumnPropertyNames = CHOOSE_FIRST -): ReflectionBasedGenericSimpleOrm { +): ReflectionBasedGenericClassPropertyMapper { val clazz = Data::class - return ReflectionBasedGenericSimpleOrm( + return ReflectionBasedGenericClassPropertyMapper( clazz, getDefaultClassColumnMappings(clazz, tables, customMappings, onDuplicateColumnPropertyNames) ) } From 13ec021901e09e08d4fc4246f0aa4cb6465db97e Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Mon, 17 Oct 2022 18:23:15 +0800 Subject: [PATCH 08/59] Rename `ClassPropertyMapper` into `SimpleClassPropertyMapper` and `GenericClassPropertyMapper` into `ClassPropertyMapper` --- .../ClassPropertyMapping.kt | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/ClassPropertyMapping.kt b/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/ClassPropertyMapping.kt index 1e75d32..0da9c9f 100644 --- a/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/ClassPropertyMapping.kt +++ b/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/ClassPropertyMapping.kt @@ -17,7 +17,7 @@ import kotlin.reflect.full.withNullability // Our own class mapping implementation using reflection which should be adapted using annotation processors and code generation in the future. -interface ClassPropertyMapper { +interface SimpleClassPropertyMapper { fun resultRowToData(resultRow: ResultRow): Data fun updateBuilderSetter(data: Data): TableT.(UpdateBuilder<*>) -> Unit } @@ -27,7 +27,9 @@ fun ResultRow.getValue(column: Column<*>): Any? = if (it is EntityID<*>) it.value else it } -interface ReflectionBasedClassPropertyMapper : ClassPropertyMapper { +/** Nested classes are not supported. */ +interface ReflectionBasedSimpleClassPropertyMapper : + SimpleClassPropertyMapper { val propertyAndColumnPairs: List, Column<*>>> val dataPrimaryConstructor: KFunction @@ -43,8 +45,8 @@ interface ReflectionBasedClassPropertyMapper : Class } } -inline fun reflectionBasedClassPropertyMapper(table: TableT): ReflectionBasedClassPropertyMapper = - object : ReflectionBasedClassPropertyMapper { +inline fun reflectionBasedSimpleClassPropertyMapper(table: TableT): ReflectionBasedSimpleClassPropertyMapper = + object : ReflectionBasedSimpleClassPropertyMapper { private val clazz = Data::class override val propertyAndColumnPairs = run { //require(dClass.isData) @@ -71,10 +73,10 @@ inline fun getColumnByPropertyNameMapWithTypeParameter( getColumnPropertyByNameMap(TableT::class) .mapValues { it.value(table) } -inline fun reflectionBasedClassPropertyMapperForAlias( - tableClassPropertyMapper: ReflectionBasedClassPropertyMapper, alias: Alias -): ReflectionBasedClassPropertyMapper = - object : ReflectionBasedClassPropertyMapper { +inline fun reflectionBasedSimpleClassPropertyMapperForAlias( + tableClassPropertyMapper: ReflectionBasedSimpleClassPropertyMapper, alias: Alias +): ReflectionBasedSimpleClassPropertyMapper = + object : ReflectionBasedSimpleClassPropertyMapper { override val dataPrimaryConstructor = tableClassPropertyMapper.dataPrimaryConstructor override val propertyAndColumnPairs = tableClassPropertyMapper.propertyAndColumnPairs.map { it.first to alias[it.second] } @@ -222,15 +224,15 @@ fun getDefaultClassColumnMappings( clazz, getColumnByPropertyNameMap(tables, onDuplicateColumnPropertyNames), customMappings ) -interface GenericClassPropertyMapper : ClassPropertyMapper { +interface ClassPropertyMapper : SimpleClassPropertyMapper { val neededColumns: List> } /** Supports classes with nested composite class properties and multiple tables */ -class ReflectionBasedGenericClassPropertyMapper( +class ReflectionBasedClassPropertyMapper( val clazz: KClass, val classColumnMappings: ClassColumnMappings, -) : GenericClassPropertyMapper { +) : ClassPropertyMapper { override val neededColumns = classColumnMappings.getNeededColumns() override fun resultRowToData(resultRow: ResultRow): Data = constructDataWithResultRow(clazz, classColumnMappings, resultRow) @@ -302,13 +304,13 @@ fun setUpdateBuilderToNulls( fun ClassColumnMappings<*>.getNeededColumns(): List> = buildList { forEachColumn { add(it) } } -inline fun reflectionBasedGenericClassPropertyMapper( +inline fun reflectionBasedClassPropertyMapper( tables: List
, customMappings: PropertyColumnMappings = emptyList(), onDuplicateColumnPropertyNames: OnDuplicateColumnPropertyNames = CHOOSE_FIRST -): ReflectionBasedGenericClassPropertyMapper { +): ReflectionBasedClassPropertyMapper { val clazz = Data::class - return ReflectionBasedGenericClassPropertyMapper( + return ReflectionBasedClassPropertyMapper( clazz, getDefaultClassColumnMappings(clazz, tables, customMappings, onDuplicateColumnPropertyNames) ) } From aa2dd26794c0160033e33f6945f6cade7834226b Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Mon, 17 Oct 2022 18:26:01 +0800 Subject: [PATCH 09/59] Move code related to `SimpleClassPropertyMapper` into a separate file --- .../ClassPropertyMapping.kt | 98 ---------------- .../SimpleClassPropertyMapping.kt | 108 ++++++++++++++++++ 2 files changed, 108 insertions(+), 98 deletions(-) create mode 100644 exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/SimpleClassPropertyMapping.kt diff --git a/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/ClassPropertyMapping.kt b/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/ClassPropertyMapping.kt index 0da9c9f..9885c2b 100644 --- a/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/ClassPropertyMapping.kt +++ b/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/ClassPropertyMapping.kt @@ -2,8 +2,6 @@ package com.huanshankeji.exposed.classpropertymapping import com.huanshankeji.exposed.classpropertymapping.OnDuplicateColumnPropertyNames.* import com.huanshankeji.exposed.classpropertymapping.PropertyColumnMapping.* -import org.jetbrains.exposed.dao.id.EntityID -import org.jetbrains.exposed.sql.Alias import org.jetbrains.exposed.sql.Column import org.jetbrains.exposed.sql.ResultRow import org.jetbrains.exposed.sql.Table @@ -17,102 +15,6 @@ import kotlin.reflect.full.withNullability // Our own class mapping implementation using reflection which should be adapted using annotation processors and code generation in the future. -interface SimpleClassPropertyMapper { - fun resultRowToData(resultRow: ResultRow): Data - fun updateBuilderSetter(data: Data): TableT.(UpdateBuilder<*>) -> Unit -} - -fun ResultRow.getValue(column: Column<*>): Any? = - this[column].let { - if (it is EntityID<*>) it.value else it - } - -/** Nested classes are not supported. */ -interface ReflectionBasedSimpleClassPropertyMapper : - SimpleClassPropertyMapper { - val propertyAndColumnPairs: List, Column<*>>> - val dataPrimaryConstructor: KFunction - - override fun resultRowToData(resultRow: ResultRow): Data { - val params = propertyAndColumnPairs.map { (_, column) -> resultRow.getValue(column) } - return dataPrimaryConstructor.call(*params.toTypedArray()) - } - - override fun updateBuilderSetter(data: Data): TableT.(UpdateBuilder<*>) -> Unit = { - for ((property, column) in propertyAndColumnPairs) - @Suppress("UNCHECKED_CAST") - it[column as Column] = property(data) - } -} - -inline fun reflectionBasedSimpleClassPropertyMapper(table: TableT): ReflectionBasedSimpleClassPropertyMapper = - object : ReflectionBasedSimpleClassPropertyMapper { - private val clazz = Data::class - override val propertyAndColumnPairs = run { - //require(dClass.isData) - val dataMemberPropertyMap = clazz.memberProperties.associateBy { it.name } - val columnMap = getColumnByPropertyNameMapWithTypeParameter(table) - dataPrimaryConstructor.parameters.map { - val name = it.name!! - dataMemberPropertyMap.getValue(name) to columnMap.getValue(name) - } - } - override val dataPrimaryConstructor = clazz.primaryConstructor!! - } - -@Suppress("UNCHECKED_CAST") -fun getColumnProperties(clazz: KClass): Sequence>> = - clazz.memberProperties.asSequence() - .filter { it.returnType.classifier == Column::class } - as Sequence>> - -fun getColumnPropertyByNameMap(clazz: KClass): Map>> = - getColumnProperties(clazz).associateBy { it.name } - -inline fun getColumnByPropertyNameMapWithTypeParameter(table: TableT): Map> = - getColumnPropertyByNameMap(TableT::class) - .mapValues { it.value(table) } - -inline fun reflectionBasedSimpleClassPropertyMapperForAlias( - tableClassPropertyMapper: ReflectionBasedSimpleClassPropertyMapper, alias: Alias -): ReflectionBasedSimpleClassPropertyMapper = - object : ReflectionBasedSimpleClassPropertyMapper { - override val dataPrimaryConstructor = tableClassPropertyMapper.dataPrimaryConstructor - override val propertyAndColumnPairs = - tableClassPropertyMapper.propertyAndColumnPairs.map { it.first to alias[it.second] } - } - - -inline fun innerJoinResultRowToData( - crossinline resultRowToData1: (ResultRow) -> D1, crossinline resultRowToData2: (ResultRow) -> D2 -): (ResultRow) -> Pair = { - resultRowToData1(it) to resultRowToData2(it) -} - -inline fun leftJoinResultRowToData( - crossinline resultRowToData1: (ResultRow) -> D1, crossinline resultRowToData2: (ResultRow) -> D2, - onColumn: Column<*> -): (ResultRow) -> Pair = { - // `it.hasValue` returns true here but the value is `null` - resultRowToData1(it) to if (it[onColumn] !== null) resultRowToData2(it) else null -} - -inline fun leftJoinResultRowToData( - crossinline resultRowToData1: (ResultRow) -> D1, - crossinline resultRowToData2: (ResultRow) -> D2, - crossinline resultRowToData3: (ResultRow) -> D3, - onColumn2: Column<*>, - onColumn3: Column<*> -): (ResultRow) -> Triple = { - // `it.hasValue` returns `true` here but the value is `null` - Triple( - resultRowToData1(it), - if (it[onColumn2] !== null) resultRowToData2(it) else null, - if (it[onColumn3] !== null) resultRowToData3(it) else null - ) -} - - typealias PropertyColumnMappings = List> //typealias LessStrictlyTypedPropertyColumnMappings = List> /** In the order of the constructor arguments. */ diff --git a/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/SimpleClassPropertyMapping.kt b/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/SimpleClassPropertyMapping.kt new file mode 100644 index 0000000..2560f16 --- /dev/null +++ b/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/SimpleClassPropertyMapping.kt @@ -0,0 +1,108 @@ +package com.huanshankeji.exposed.classpropertymapping + +import org.jetbrains.exposed.dao.id.EntityID +import org.jetbrains.exposed.sql.Alias +import org.jetbrains.exposed.sql.Column +import org.jetbrains.exposed.sql.ResultRow +import org.jetbrains.exposed.sql.Table +import org.jetbrains.exposed.sql.statements.UpdateBuilder +import kotlin.reflect.KClass +import kotlin.reflect.KFunction +import kotlin.reflect.KProperty1 +import kotlin.reflect.full.memberProperties +import kotlin.reflect.full.primaryConstructor + +interface SimpleClassPropertyMapper { + fun resultRowToData(resultRow: ResultRow): Data + fun updateBuilderSetter(data: Data): TableT.(UpdateBuilder<*>) -> Unit +} + +fun ResultRow.getValue(column: Column<*>): Any? = + this[column].let { + if (it is EntityID<*>) it.value else it + } + +/** Nested classes are not supported. */ +interface ReflectionBasedSimpleClassPropertyMapper : + SimpleClassPropertyMapper { + val propertyAndColumnPairs: List, Column<*>>> + val dataPrimaryConstructor: KFunction + + override fun resultRowToData(resultRow: ResultRow): Data { + val params = propertyAndColumnPairs.map { (_, column) -> resultRow.getValue(column) } + return dataPrimaryConstructor.call(*params.toTypedArray()) + } + + override fun updateBuilderSetter(data: Data): TableT.(UpdateBuilder<*>) -> Unit = { + for ((property, column) in propertyAndColumnPairs) + @Suppress("UNCHECKED_CAST") + it[column as Column] = property(data) + } +} + +inline fun reflectionBasedSimpleClassPropertyMapper(table: TableT): ReflectionBasedSimpleClassPropertyMapper = + object : ReflectionBasedSimpleClassPropertyMapper { + private val clazz = Data::class + override val propertyAndColumnPairs = run { + //require(dClass.isData) + val dataMemberPropertyMap = clazz.memberProperties.associateBy { it.name } + val columnMap = getColumnByPropertyNameMapWithTypeParameter(table) + dataPrimaryConstructor.parameters.map { + val name = it.name!! + dataMemberPropertyMap.getValue(name) to columnMap.getValue(name) + } + } + override val dataPrimaryConstructor = clazz.primaryConstructor!! + } + +@Suppress("UNCHECKED_CAST") +fun getColumnProperties(clazz: KClass): Sequence>> = + clazz.memberProperties.asSequence() + .filter { it.returnType.classifier == Column::class } + as Sequence>> + +fun getColumnPropertyByNameMap(clazz: KClass): Map>> = + getColumnProperties(clazz).associateBy { it.name } + +inline fun getColumnByPropertyNameMapWithTypeParameter(table: TableT): Map> = + getColumnPropertyByNameMap(TableT::class) + .mapValues { it.value(table) } + +inline fun reflectionBasedSimpleClassPropertyMapperForAlias( + tableClassPropertyMapper: ReflectionBasedSimpleClassPropertyMapper, alias: Alias +): ReflectionBasedSimpleClassPropertyMapper = + object : ReflectionBasedSimpleClassPropertyMapper { + override val dataPrimaryConstructor = tableClassPropertyMapper.dataPrimaryConstructor + override val propertyAndColumnPairs = + tableClassPropertyMapper.propertyAndColumnPairs.map { it.first to alias[it.second] } + } + + +inline fun innerJoinResultRowToData( + crossinline resultRowToData1: (ResultRow) -> D1, crossinline resultRowToData2: (ResultRow) -> D2 +): (ResultRow) -> Pair = { + resultRowToData1(it) to resultRowToData2(it) +} + +inline fun leftJoinResultRowToData( + crossinline resultRowToData1: (ResultRow) -> D1, crossinline resultRowToData2: (ResultRow) -> D2, + onColumn: Column<*> +): (ResultRow) -> Pair = { + // `it.hasValue` returns true here but the value is `null` + resultRowToData1(it) to if (it[onColumn] !== null) resultRowToData2(it) else null +} + +inline fun leftJoinResultRowToData( + crossinline resultRowToData1: (ResultRow) -> D1, + crossinline resultRowToData2: (ResultRow) -> D2, + crossinline resultRowToData3: (ResultRow) -> D3, + onColumn2: Column<*>, + onColumn3: Column<*> +): (ResultRow) -> Triple = { + // `it.hasValue` returns `true` here but the value is `null` + Triple( + resultRowToData1(it), + if (it[onColumn2] !== null) resultRowToData2(it) else null, + if (it[onColumn3] !== null) resultRowToData3(it) else null + ) +} From ffb69e3f27faca54dee247076f6989534f0abd1c Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Mon, 17 Oct 2022 18:59:00 +0800 Subject: [PATCH 10/59] Rename `ClassColumnMappings` to `ClassPropertyColumnMappings` --- .../ClassPropertyMapping.kt | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/ClassPropertyMapping.kt b/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/ClassPropertyMapping.kt index 9885c2b..f36bc4d 100644 --- a/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/ClassPropertyMapping.kt +++ b/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/ClassPropertyMapping.kt @@ -18,7 +18,7 @@ import kotlin.reflect.full.withNullability typealias PropertyColumnMappings = List> //typealias LessStrictlyTypedPropertyColumnMappings = List> /** In the order of the constructor arguments. */ -typealias ClassColumnMappings = PropertyColumnMappings +typealias ClassPropertyColumnMappings = PropertyColumnMappings sealed class PropertyColumnMapping(val property: KProperty1) { class ExposedSqlPrimitive( @@ -29,7 +29,7 @@ sealed class PropertyColumnMapping(val property: KPro class NestedClass( property: KProperty1, //val nullabilityDependentColumn: Column<*>, - val nestedMappings: ClassColumnMappings + val nestedMappings: ClassPropertyColumnMappings ) : PropertyColumnMapping(property) class Skip(property: KProperty1) : @@ -91,7 +91,7 @@ fun getDefaultClassColumnMappings( clazz: KClass, columnByPropertyNameMap: Map>, customMappings: PropertyColumnMappings = emptyList() -): ClassColumnMappings { +): ClassPropertyColumnMappings { val customMappingProperties = customMappings.asSequence().map { it.property }.toSet() val dataMemberPropertyMap = (clazz.memberProperties.toSet() - customMappingProperties).associateBy { it.name } @@ -111,7 +111,7 @@ fun getDefaultClassColumnMappings( property as KProperty1, getDefaultClassColumnMappings( notNullType.classifier as KClass<*>, columnByPropertyNameMap - ) as ClassColumnMappings + ) as ClassPropertyColumnMappings ) } } @@ -121,7 +121,7 @@ fun getDefaultClassColumnMappings( tables: List
, customMappings: PropertyColumnMappings = emptyList(), onDuplicateColumnPropertyNames: OnDuplicateColumnPropertyNames = CHOOSE_FIRST -): ClassColumnMappings = +): ClassPropertyColumnMappings = getDefaultClassColumnMappings( clazz, getColumnByPropertyNameMap(tables, onDuplicateColumnPropertyNames), customMappings ) @@ -133,21 +133,21 @@ interface ClassPropertyMapper : SimpleClassPropertyMapper( val clazz: KClass, - val classColumnMappings: ClassColumnMappings, + val classPropertyColumnMappings: ClassPropertyColumnMappings, ) : ClassPropertyMapper { - override val neededColumns = classColumnMappings.getNeededColumns() + override val neededColumns = classPropertyColumnMappings.getNeededColumns() override fun resultRowToData(resultRow: ResultRow): Data = - constructDataWithResultRow(clazz, classColumnMappings, resultRow) + constructDataWithResultRow(clazz, classPropertyColumnMappings, resultRow) override fun updateBuilderSetter(data: Data): Table.(UpdateBuilder<*>) -> Unit = { - setUpdateBuilder(classColumnMappings, data, it) + setUpdateBuilder(classPropertyColumnMappings, data, it) } } fun constructDataWithResultRow( - clazz: KClass, classColumnMappings: ClassColumnMappings, resultRow: ResultRow + clazz: KClass, classPropertyColumnMappings: ClassPropertyColumnMappings, resultRow: ResultRow ): Data = - clazz.primaryConstructor!!.call(*classColumnMappings.map { + clazz.primaryConstructor!!.call(*classPropertyColumnMappings.map { when (it) { is ExposedSqlPrimitive -> resultRow.getValue(it.column) is NestedClass -> @@ -155,7 +155,7 @@ fun constructDataWithResultRow( @Suppress("UNCHECKED_CAST") constructDataWithResultRow( it.property.returnType.classifier as KClass, - it.nestedMappings as ClassColumnMappings, + it.nestedMappings as ClassPropertyColumnMappings, resultRow ) @@ -164,9 +164,9 @@ fun constructDataWithResultRow( }.toTypedArray()) fun setUpdateBuilder( - classColumnMappings: ClassColumnMappings, data: Data, updateBuilder: UpdateBuilder<*> + classPropertyColumnMappings: ClassPropertyColumnMappings, data: Data, updateBuilder: UpdateBuilder<*> ) { - for (propertyColumnMapping in classColumnMappings) + for (propertyColumnMapping in classPropertyColumnMappings) when (propertyColumnMapping) { is ExposedSqlPrimitive -> @Suppress("UNCHECKED_CAST") @@ -186,7 +186,7 @@ fun setUpdateBuilder( } } -fun ClassColumnMappings<*>.forEachColumn(block: (Column<*>) -> Unit) { +fun ClassPropertyColumnMappings<*>.forEachColumn(block: (Column<*>) -> Unit) { for (propertyColumnMapping in this) when (propertyColumnMapping) { is ExposedSqlPrimitive -> block(propertyColumnMapping.column) @@ -196,14 +196,14 @@ fun ClassColumnMappings<*>.forEachColumn(block: (Column<*>) -> Unit) { } fun setUpdateBuilderToNulls( - classColumnMappings: ClassColumnMappings, updateBuilder: UpdateBuilder<*> + classPropertyColumnMappings: ClassPropertyColumnMappings, updateBuilder: UpdateBuilder<*> ) = - classColumnMappings.forEachColumn { + classPropertyColumnMappings.forEachColumn { @Suppress("UNCHECKED_CAST") updateBuilder[it as Column] = null } -fun ClassColumnMappings<*>.getNeededColumns(): List> = +fun ClassPropertyColumnMappings<*>.getNeededColumns(): List> = buildList { forEachColumn { add(it) } } inline fun reflectionBasedClassPropertyMapper( From d25931de68fa0aa09b4188e55199fda33d0f0e2e Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Tue, 18 Oct 2022 18:57:36 +0800 Subject: [PATCH 11/59] Add `insertSelectStatement` --- .../kotlin/com/huanshankeji/exposed/Statements.kt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/exposed/src/main/kotlin/com/huanshankeji/exposed/Statements.kt b/exposed/src/main/kotlin/com/huanshankeji/exposed/Statements.kt index 5a9a1cb..651c3bb 100644 --- a/exposed/src/main/kotlin/com/huanshankeji/exposed/Statements.kt +++ b/exposed/src/main/kotlin/com/huanshankeji/exposed/Statements.kt @@ -17,6 +17,7 @@ fun Table.deleteWhereStatement( ): DeleteStatement = DeleteStatement(this, SqlExpressionBuilder.op(), false, limit, offset) +// TODO: is this needed anymore? class HelperInsertStatement(table: Table, isIgnore: Boolean = false) : InsertStatement(table, isIgnore) { public override var arguments: List, Any?>>>? @@ -42,6 +43,16 @@ fun T.insertIgnoreStatement(body: T.(InsertStatement) -> Uni body(this) } +/** + * Adapted from [org.jetbrains.exposed.sql.insert]. + */ +fun T.insertSelectStatement( + selectQuery: AbstractQuery<*>, + columns: List> = this.columns.filter { !it.columnType.isAutoInc || it.autoIncColumnType?.nextValExpression != null }, + isIgnore: Boolean = false +): InsertSelectStatement = + InsertSelectStatement(columns, selectQuery, isIgnore) + /** * Adapted from [org.jetbrains.exposed.sql.update]. */ From 1e2cc2fb83ace2f9030d48e8d29b0ccc68adb7c1 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Wed, 19 Oct 2022 17:39:59 +0800 Subject: [PATCH 12/59] Fix the newly introduced bug that `dataPrimaryConstructor` is initialized after `propertyAndColumnPairs` in `reflectionBasedSimpleClassPropertyMapper` --- .../classpropertymapping/SimpleClassPropertyMapping.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/SimpleClassPropertyMapping.kt b/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/SimpleClassPropertyMapping.kt index 2560f16..cc39b1b 100644 --- a/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/SimpleClassPropertyMapping.kt +++ b/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/SimpleClassPropertyMapping.kt @@ -43,6 +43,9 @@ interface ReflectionBasedSimpleClassPropertyMapper : inline fun reflectionBasedSimpleClassPropertyMapper(table: TableT): ReflectionBasedSimpleClassPropertyMapper = object : ReflectionBasedSimpleClassPropertyMapper { private val clazz = Data::class + + // This property needs to initialize first. + override val dataPrimaryConstructor = clazz.primaryConstructor!! override val propertyAndColumnPairs = run { //require(dClass.isData) val dataMemberPropertyMap = clazz.memberProperties.associateBy { it.name } @@ -52,7 +55,6 @@ inline fun reflectionBasedSimpleCla dataMemberPropertyMap.getValue(name) to columnMap.getValue(name) } } - override val dataPrimaryConstructor = clazz.primaryConstructor!! } @Suppress("UNCHECKED_CAST") From 5eb75d0dd171fd4ab3a10e76b6379d91b90726ce Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Thu, 20 Oct 2022 23:09:57 +0800 Subject: [PATCH 13/59] Add a new overloaded `reflectionBasedClassPropertyMapper` for a single `Table` --- .../exposed/classpropertymapping/ClassPropertyMapping.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/ClassPropertyMapping.kt b/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/ClassPropertyMapping.kt index f36bc4d..00186c4 100644 --- a/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/ClassPropertyMapping.kt +++ b/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/ClassPropertyMapping.kt @@ -216,3 +216,9 @@ inline fun reflectionBasedClassPropertyMapper( clazz, getDefaultClassColumnMappings(clazz, tables, customMappings, onDuplicateColumnPropertyNames) ) } + +inline fun reflectionBasedClassPropertyMapper( + table: Table, + customMappings: PropertyColumnMappings = emptyList() +) = + reflectionBasedClassPropertyMapper(listOf(table), customMappings, THROW) From d5973571eebe416a78b079425b3ec9c65e6e803c Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Thu, 20 Oct 2022 23:30:02 +0800 Subject: [PATCH 14/59] Fix a bug that nullable columns are included when filtering `Column` properties in `getColumnProperties`, for example `Table.autoIncColumn` --- .../exposed/classpropertymapping/SimpleClassPropertyMapping.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/SimpleClassPropertyMapping.kt b/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/SimpleClassPropertyMapping.kt index cc39b1b..ba5f206 100644 --- a/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/SimpleClassPropertyMapping.kt +++ b/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/SimpleClassPropertyMapping.kt @@ -60,7 +60,7 @@ inline fun reflectionBasedSimpleCla @Suppress("UNCHECKED_CAST") fun getColumnProperties(clazz: KClass): Sequence>> = clazz.memberProperties.asSequence() - .filter { it.returnType.classifier == Column::class } + .filter { it.returnType.run { classifier == Column::class && !isMarkedNullable } } as Sequence>> fun getColumnPropertyByNameMap(clazz: KClass): Map>> = From 572b4c3992ce335c87f07395461d7b484485e4c3 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Sat, 22 Oct 2022 05:42:06 +0800 Subject: [PATCH 15/59] Resolve a TODO comment --- exposed/src/main/kotlin/com/huanshankeji/exposed/Statements.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exposed/src/main/kotlin/com/huanshankeji/exposed/Statements.kt b/exposed/src/main/kotlin/com/huanshankeji/exposed/Statements.kt index 651c3bb..eb9ef7e 100644 --- a/exposed/src/main/kotlin/com/huanshankeji/exposed/Statements.kt +++ b/exposed/src/main/kotlin/com/huanshankeji/exposed/Statements.kt @@ -17,7 +17,7 @@ fun Table.deleteWhereStatement( ): DeleteStatement = DeleteStatement(this, SqlExpressionBuilder.op(), false, limit, offset) -// TODO: is this needed anymore? +// to access the protected `arguments` in the super class class HelperInsertStatement(table: Table, isIgnore: Boolean = false) : InsertStatement(table, isIgnore) { public override var arguments: List, Any?>>>? From 2f84363eae1a1900f88d0696e8e9cde0f55b752f Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Fri, 28 Oct 2022 02:55:58 +0800 Subject: [PATCH 16/59] Support nullability and algebraic types (mainly sum types, aka sealed and abstract classes) in properties in `ClassPropertyMapping.kt` The changes have not been tested yet. Some other related changes: 1. Fix a not revealed potential bug that the `customMappings` argument is not used 1. Split the `ClassPropertyMapper` interface and related interfaces into 2 kinds respectively related to query and update. 1. Use `KClass` to judge whether a type is a SQL primitive type instead of `KType` for better performance. --- .../main/kotlin/VersionsAndDependencies.kt | 7 + exposed/build.gradle.kts | 2 + .../ClassPropertyMapping.kt | 472 +++++++++++++++--- .../SimpleClassPropertyMapping.kt | 24 +- 4 files changed, 415 insertions(+), 90 deletions(-) diff --git a/buildSrc/src/main/kotlin/VersionsAndDependencies.kt b/buildSrc/src/main/kotlin/VersionsAndDependencies.kt index 49b2c3a..e752ac5 100644 --- a/buildSrc/src/main/kotlin/VersionsAndDependencies.kt +++ b/buildSrc/src/main/kotlin/VersionsAndDependencies.kt @@ -7,3 +7,10 @@ val projectVersion = "0.3.0-SNAPSHOT" val commonVersions = CommonVersions() val commonDependencies = CommonDependencies(commonVersions) val commonGradleClasspathDependencies = CommonGradleClasspathDependencies(commonVersions) + +// TODO: remove +/* +object DependencyVersions { + const val guava = "31.1-jre" +} +*/ diff --git a/exposed/build.gradle.kts b/exposed/build.gradle.kts index f471d4b..7e72836 100644 --- a/exposed/build.gradle.kts +++ b/exposed/build.gradle.kts @@ -4,4 +4,6 @@ plugins { dependencies { implementation(commonDependencies.exposed.core()) + // TODO: remove + //implementation("com.google.guava:guava:${DependencyVersions.guava}") } diff --git a/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/ClassPropertyMapping.kt b/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/ClassPropertyMapping.kt index 00186c4..5491b92 100644 --- a/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/ClassPropertyMapping.kt +++ b/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/ClassPropertyMapping.kt @@ -2,15 +2,12 @@ package com.huanshankeji.exposed.classpropertymapping import com.huanshankeji.exposed.classpropertymapping.OnDuplicateColumnPropertyNames.* import com.huanshankeji.exposed.classpropertymapping.PropertyColumnMapping.* -import org.jetbrains.exposed.sql.Column -import org.jetbrains.exposed.sql.ResultRow -import org.jetbrains.exposed.sql.Table +import org.jetbrains.exposed.sql.* import org.jetbrains.exposed.sql.statements.UpdateBuilder +import org.slf4j.LoggerFactory import kotlin.reflect.* -import kotlin.reflect.full.isSubtypeOf -import kotlin.reflect.full.memberProperties -import kotlin.reflect.full.primaryConstructor -import kotlin.reflect.full.withNullability +import kotlin.reflect.full.* +import kotlin.sequences.Sequence // Our own class mapping implementation using reflection which should be adapted using annotation processors and code generation in the future. @@ -20,39 +17,74 @@ typealias PropertyColumnMappings = List> /** In the order of the constructor arguments. */ typealias ClassPropertyColumnMappings = PropertyColumnMappings -sealed class PropertyColumnMapping(val property: KProperty1) { +// TODO: decouple/remove `property` and `Data` from this class. +sealed class PropertyColumnMapping(val property: KProperty1) { + // TODO: rename all occurrences of "PrimitiveValue" to "PropertyData". class ExposedSqlPrimitive( property: KProperty1, val column: Column ) : PropertyColumnMapping(property) + // TODO: rename all occurrences of "NestedData" to "PropertyData". class NestedClass( property: KProperty1, - //val nullabilityDependentColumn: Column<*>, - val nestedMappings: ClassPropertyColumnMappings - ) : PropertyColumnMapping(property) + val nullability: Nullability, + val adt: Adt + ) : PropertyColumnMapping(property) { + sealed class Nullability { + class NonNullable : Nullability() + class Nullable(val nullDependentColumn: Column<*>) : + Nullability() + } + + // ADT: algebraic data type + sealed class Adt { + class Product(val nestedMappings: ClassPropertyColumnMappings) : + Adt() + + class Sum( + // I first used the Guava BiMap but then realized it's not necessary. TODO: remove this comment + val subclassMap: Map, Product>, + val sumTypeCaseConfig: SumTypeCaseConfig + ) : Adt() + } + + } - class Skip(property: KProperty1) : - PropertyColumnMapping(property) + // TODO: remove the temporary workaround `& Any` if and when the `Any` upper bound is removed. + class Custom( + property: KProperty1, val classPropertyMapper: ClassPropertyMapper + ) : PropertyColumnMapping(property) + + class Skip(property: KProperty1) : + PropertyColumnMapping(property) } +class SumTypeCaseConfig( + val caseValueColumn: Column, + val caseValueToClass: (Case) -> KClass, + val classToCaseValue: (KClass?) -> Case +) + // see: https://kotlinlang.org/docs/basic-types.html, https://www.postgresql.org/docs/current/datatype.html // Types that are commented out are not ensured to work yet. -val defaultNotNullExposedSqlPrimitiveTypes = listOf( - typeOf(), typeOf(), typeOf(), typeOf(), /*typeOf(),*/ - typeOf(), typeOf(), typeOf(), typeOf(), - typeOf(), typeOf(), /*typeOf(),*/ - typeOf(), - typeOf(), - //typeOf(), - typeOf(), +val defaultNotNullExposedSqlPrimitiveClasses = listOf( + Byte::class, Short::class, Int::class, Long::class, /*BigInteger::class,*/ + UByte::class, UShort::class, UInt::class, ULong::class, + Float::class, Double::class, /*BigDecimal::class,*/ + Boolean::class, + ByteArray::class, + //Char::class, + String::class, // types related to time and date ) -val enumType = typeOf>() -fun KType.notNullTypeIsExposedSqlPrimitiveType(): Boolean = - this in defaultNotNullExposedSqlPrimitiveTypes || isSubtypeOf(enumType) +fun KClass<*>.isExposedSqlPrimitiveType(): Boolean = + this in defaultNotNullExposedSqlPrimitiveClasses || isSubclassOf(Enum::class) + +fun KType.isExposedSqlPrimitiveType() = + (classifier as KClass<*>).isExposedSqlPrimitiveType() class ColumnWithPropertyName(val propertyName: String, val column: Column<*>) @@ -86,50 +118,244 @@ fun getColumnByPropertyNameMap( } } +val logger = LoggerFactory.getLogger("class property mapping") + +/** + * @param skip both writing and reading. Note that the property type need not be nullable if it's only used for writing. + * @param nullDependentColumn required for nullable properties. + */ +class PropertyColumnMappingConfig

( + type: KType, + usedForQuery: Boolean = true, + val skip: Boolean = false, + val differentColumnPropertyName: String? = null, + val nullDependentColumn: Column<*>? = null, // for query + val adt: Adt

? = null, // for query and update +) { + init { + // perform the checks + + if (type.isMarkedNullable) { + if (skip && nullDependentColumn !== null || adt !== null) + logger.warn("${::nullDependentColumn.name} and ${::adt.name} are unnecessary when ${::skip.name} is configured to true.") + } else { + // Non-nullable properties can be skipped when updating but not when querying. + if (usedForQuery) + require(!skip) + require(nullDependentColumn === null) + } -fun getDefaultClassColumnMappings( + + if (type.isExposedSqlPrimitiveType() && nullDependentColumn === null && adt === null) + logger.warn("${::nullDependentColumn} or ${::adt} is set for a primitive type $type and will be ignored.") + + @Suppress("UNCHECKED_CAST") + val clazz = type.classifier as KClass

+ when (adt) { + is Adt.Product -> require(!clazz.isAbstract) + is Adt.Sum<*, *> -> require(clazz.isOpen) + null -> {} + } + } + + companion object { + inline fun create( + skip: Boolean = false, + usedForQuery: Boolean = true, + columnPropertyName: String? = null, + nullDependentColumn: Column<*>? = null, + adt: Adt? = null + ) = + PropertyColumnMappingConfig( + typeOf(), skip, usedForQuery, columnPropertyName, nullDependentColumn, adt + ) + } + + // ADT: algebraic data type + sealed class Adt { + class Product(val nestedConfigMap: PropertyColumnMappingConfigMap) : + Adt() + + class Sum( + clazz: KClass, + val subclassProductConfigMapOrOverride: Map, Product>, + val sumTypeCaseConfig: SumTypeCaseConfig + ) : Adt() { + init { + require(subclassProductConfigMapOrOverride.keys.all { !it.isAbstract && it.isSubclassOf(clazz) }) + } + + companion object { + inline fun createForSealed( + subclassProductConfigMapOverride: Map, Product> = emptyMap(), + sumTypeCaseConfig: SumTypeCaseConfig + ): Sum { + val clazz = Data::class + require(clazz.isSealed) + return Sum(clazz, subclassProductConfigMapOverride, sumTypeCaseConfig) + } + + inline fun createForAbstractNotSealed( + subclassProductConfigMap: Map, Product>, + sumTypeCaseConfig: SumTypeCaseConfig + ): Sum { + val clazz = Data::class + require(clazz.isAbstract && !clazz.isSealed) + return Sum(clazz, subclassProductConfigMap, sumTypeCaseConfig) + } + } + } + } +} + +typealias PropertyColumnMappingConfigMap = Map, PropertyColumnMappingConfig<*>> + +fun getDefaultClassPropertyColumnMappings( clazz: KClass, columnByPropertyNameMap: Map>, + propertyColumnMappingConfigMapOverride: PropertyColumnMappingConfigMap = emptyMap(), customMappings: PropertyColumnMappings = emptyList() ): ClassPropertyColumnMappings { val customMappingProperties = customMappings.asSequence().map { it.property }.toSet() val dataMemberPropertyMap = (clazz.memberProperties.toSet() - customMappingProperties).associateBy { it.name } + val customMappingMap = customMappings.associateBy { it.property.name } return clazz.primaryConstructor!!.parameters.map { val name = it.name!! - val property = dataMemberPropertyMap[name] - val notNullType = it.type.withNullability(false) - @Suppress("UNCHECKED_CAST") - if (notNullType.notNullTypeIsExposedSqlPrimitiveType()) - ExposedSqlPrimitive( - property as KProperty1, - columnByPropertyNameMap.getValue(name) as Column - ) - else - NestedClass( - property as KProperty1, - getDefaultClassColumnMappings( - notNullType.classifier as KClass<*>, columnByPropertyNameMap - ) as ClassPropertyColumnMappings - ) + + val customMapping = customMappingMap[name] + if (customMapping !== null) + return@map customMapping + + val property = dataMemberPropertyMap.getValue(name) + require(it.type == property.returnType) + + // This function is added to introduce a new type parameter `PropertyData` to constrain the types better. + fun typeParameterHelper(property: KProperty1): PropertyColumnMapping { + val config = propertyColumnMappingConfigMapOverride[property] + if (config?.skip == true) + return Skip(property) + + val columnPropertyName = config?.differentColumnPropertyName ?: name + val type = property.returnType + + @Suppress("UNCHECKED_CAST") + val propertyClazz = type.classifier as KClass<*> as KClass + return if (propertyClazz.isExposedSqlPrimitiveType()) + @Suppress("UNCHECKED_CAST") + ExposedSqlPrimitive( + property, columnByPropertyNameMap.getValue(columnPropertyName) as Column + ) + else { + val isNullable = type.isMarkedNullable + + @Suppress("UNCHECKED_CAST") + val nullability = + ( + if (isNullable) + /* + I first had the idea of finding a default `nullDependentColumn` but it seems difficult to cover all kinds of cases. + + There are 3 ways I can think of to find the default `nullDependentColumn` in the corresponding columns mapped by the properties: + 1. find the first non-nullable column; + 1. find the first column that's a primary key; + 1. find the first non-nullable column with the suffix "id". + + They all have their drawbacks. + The first approach is too unpredictable, adding or removing properties can affect which column to choose. + Both the second and the third approach can't deal with the case where the column is not within the mapped columns, + which happens when selecting a small portion of the fields as data. + */ + NestedClass.Nullability.Nullable(config?.nullDependentColumn!!) + else + NestedClass.Nullability.NonNullable() + ) + as NestedClass.Nullability + + + @Suppress("UNCHECKED_CAST") + val adtConfig = config?.adt as PropertyColumnMappingConfig.Adt? + val adt = if (propertyClazz.isAbstract) { + //requireNotNull(adtConfig) + require(adtConfig is PropertyColumnMappingConfig.Adt.Sum<*, *>) + adtConfig as PropertyColumnMappingConfig.Adt.Sum + val subclassProductConfigMapOrOverride = adtConfig.subclassProductConfigMapOrOverride + + + val subclassProductNestedConfigMapMapOrOverride = + subclassProductConfigMapOrOverride.mapValues { it.value.nestedConfigMap } + val subclassProductNestedConfigMapMap = + if (propertyClazz.isSealed) + propertyClazz.sealedLeafSubclasses().associateWith { + emptyMap, PropertyColumnMappingConfig<*>>() + } + subclassProductNestedConfigMapMapOrOverride + else { + require(subclassProductConfigMapOrOverride.isNotEmpty()) { "A custom config needs to be specified for a non-sealed abstract class" } + subclassProductNestedConfigMapMapOrOverride + } + + NestedClass.Adt.Sum( + subclassProductNestedConfigMapMap.mapValues { + fun typeParameterHelper( + clazz: KClass, configMap: PropertyColumnMappingConfigMap + ): NestedClass.Adt.Product = + NestedClass.Adt.Product( + getDefaultClassPropertyColumnMappings(clazz, columnByPropertyNameMap, configMap) + ) + @Suppress("UNCHECKED_CAST") + typeParameterHelper( + it.key as KClass, + it.value as PropertyColumnMappingConfigMap + ) + }, + adtConfig.sumTypeCaseConfig + ) + } else { + require(adtConfig is PropertyColumnMappingConfig.Adt.Product?) + NestedClass.Adt.Product( + getDefaultClassPropertyColumnMappings( + propertyClazz, + columnByPropertyNameMap, + (adtConfig?.nestedConfigMap ?: emptyMap()) + ) + ) + } + + NestedClass(property, nullability, adt) + } + } + typeParameterHelper(property) } } -fun getDefaultClassColumnMappings( +// This implementation currently has poor performance (O(depth * size) time complexity). +fun KClass.sealedLeafSubclasses(): List> = + if (isSealed) sealedSubclasses.flatMap { it.sealedLeafSubclasses() } + else listOf(this) + +fun getDefaultClassPropertyColumnMappings( clazz: KClass, - tables: List

, + tables: List
, onDuplicateColumnPropertyNames: OnDuplicateColumnPropertyNames = CHOOSE_FIRST, customMappings: PropertyColumnMappings = emptyList(), - onDuplicateColumnPropertyNames: OnDuplicateColumnPropertyNames = CHOOSE_FIRST + propertyColumnMappingConfigMapOverride: PropertyColumnMappingConfigMap = emptyMap() ): ClassPropertyColumnMappings = - getDefaultClassColumnMappings( - clazz, getColumnByPropertyNameMap(tables, onDuplicateColumnPropertyNames), customMappings + getDefaultClassPropertyColumnMappings( + clazz, + getColumnByPropertyNameMap(tables, onDuplicateColumnPropertyNames), + propertyColumnMappingConfigMapOverride, + customMappings ) -interface ClassPropertyMapper : SimpleClassPropertyMapper { +interface ClassPropertyQueryMapper : SimpleClassPropertyQueryMapper { val neededColumns: List> } +typealias ClassPropertyUpdateMapper = ClassPropertyQueryMapper + +interface ClassPropertyMapper : ClassPropertyQueryMapper, SimpleClassPropertyMapper + +// TODO: decouple query mapper and update mapper. /** Supports classes with nested composite class properties and multiple tables */ class ReflectionBasedClassPropertyMapper( val clazz: KClass, @@ -139,8 +365,8 @@ class ReflectionBasedClassPropertyMapper( override fun resultRowToData(resultRow: ResultRow): Data = constructDataWithResultRow(clazz, classPropertyColumnMappings, resultRow) - override fun updateBuilderSetter(data: Data): Table.(UpdateBuilder<*>) -> Unit = { - setUpdateBuilder(classPropertyColumnMappings, data, it) + override fun setUpdateBuilder(data: Data, updateBuilder: UpdateBuilder<*>) { + setUpdateBuilder(classPropertyColumnMappings, data, updateBuilder) } } @@ -148,55 +374,137 @@ fun constructDataWithResultRow( clazz: KClass, classPropertyColumnMappings: ClassPropertyColumnMappings, resultRow: ResultRow ): Data = clazz.primaryConstructor!!.call(*classPropertyColumnMappings.map { - when (it) { - is ExposedSqlPrimitive -> resultRow.getValue(it.column) - is NestedClass -> - // TODO: the nullable case is not implemented yet - @Suppress("UNCHECKED_CAST") - constructDataWithResultRow( - it.property.returnType.classifier as KClass, - it.nestedMappings as ClassPropertyColumnMappings, - resultRow - ) + fun typeParameterHelper( + propertyColumnMapping: PropertyColumnMapping, + nestedClass: KClass + ) = + when (propertyColumnMapping) { + is ExposedSqlPrimitive -> resultRow.getValue(propertyColumnMapping.column) + is NestedClass -> { + fun constructNotNullData() = + when (val adt = propertyColumnMapping.adt) { + is NestedClass.Adt.Product -> + constructDataWithResultRow(nestedClass, adt.nestedMappings, resultRow) - is Skip -> null - } + is NestedClass.Adt.Sum -> { + fun typeParameterHelper(sum: NestedClass.Adt.Sum): SubclassData { + val subclass = with(sum.sumTypeCaseConfig) { + caseValueToClass(resultRow[caseValueColumn]) + } + @Suppress("UNCHECKED_CAST") + return constructDataWithResultRow( + subclass as KClass, + sum.subclassMap.getValue(subclass).nestedMappings as ClassPropertyColumnMappings, + resultRow + ) + } + typeParameterHelper(adt) + } + } + + when (val nullability = propertyColumnMapping.nullability) { + is NestedClass.Nullability.NonNullable -> constructNotNullData() + is NestedClass.Nullability.Nullable<*> -> if (resultRow[nullability.nullDependentColumn] !== null) constructNotNullData() else null + } + } + + is Custom -> propertyColumnMapping.classPropertyMapper.resultRowToData(resultRow) + is Skip -> null + } + @Suppress("UNCHECKED_CAST") + typeParameterHelper(it as PropertyColumnMapping, it.property.returnType.classifier as KClass) }.toTypedArray()) fun setUpdateBuilder( classPropertyColumnMappings: ClassPropertyColumnMappings, data: Data, updateBuilder: UpdateBuilder<*> ) { - for (propertyColumnMapping in classPropertyColumnMappings) - when (propertyColumnMapping) { - is ExposedSqlPrimitive -> - @Suppress("UNCHECKED_CAST") - updateBuilder[propertyColumnMapping.column as Column] = propertyColumnMapping.property(data) - - is NestedClass -> { - @Suppress("NAME_SHADOWING", "UNCHECKED_CAST") - val propertyColumnMapping = propertyColumnMapping as NestedClass - val nestedMappings = propertyColumnMapping.nestedMappings - propertyColumnMapping.property(data)?.let { - setUpdateBuilder(nestedMappings, it, updateBuilder) + for (propertyColumnMapping in classPropertyColumnMappings) { + fun typeParameterHelper(propertyColumnMapping: PropertyColumnMapping) { + val propertyData = propertyColumnMapping.property(data) + when (propertyColumnMapping) { + is ExposedSqlPrimitive -> + updateBuilder[propertyColumnMapping.column] = propertyData + + is NestedClass -> { + // `propertyColumnMapping.nullability` is not needed here + when (val adt = propertyColumnMapping.adt) { + is NestedClass.Adt.Product -> { + val nestedMappings = adt.nestedMappings + if (propertyData !== null) + setUpdateBuilder(nestedMappings, propertyData, updateBuilder) + else + setUpdateBuilderToNulls(nestedMappings, updateBuilder) + } + + is NestedClass.Adt.Sum -> { + fun typeParameterHelper() { + @Suppress("UNCHECKED_CAST") + adt as NestedClass.Adt.Sum + val sumTypeCaseConfig = adt.sumTypeCaseConfig + val subclassMap = adt.subclassMap + if (propertyData !== null) { + // TODO: it seems to be a compiler bug that the non-null assertion is needed here. + val propertyDataClass = propertyData!!::class + with(sumTypeCaseConfig) { + updateBuilder[caseValueColumn] = classToCaseValue(propertyDataClass) + } + fun typeParameterHelper( + subclassMapping: NestedClass.Adt.Product, + propertyData: SubclassData + ) = + setUpdateBuilder(subclassMapping.nestedMappings, propertyData, updateBuilder) + @Suppress("UNCHECKED_CAST") + typeParameterHelper( + subclassMap.getValue(propertyDataClass) as NestedClass.Adt.Product, + propertyData + ) + } else { + with(sumTypeCaseConfig) { + updateBuilder[caseValueColumn] = classToCaseValue(null) + } + // TODO: pre-process the combined columns and eliminate duplicates. + for (product in subclassMap.values) + setUpdateBuilderToNulls(product.nestedMappings, updateBuilder) + } + } + typeParameterHelper() + } + } } - ?: setUpdateBuilderToNulls(nestedMappings, updateBuilder) - } - is Skip -> {} + is Custom -> + // TODO: remove this cast if and when not only non-nullable data are supported. + propertyColumnMapping.classPropertyMapper.setUpdateBuilder( + propertyData as (PropertyData & Any), updateBuilder + ) + + is Skip -> {} + } } + + typeParameterHelper(propertyColumnMapping) + } } fun ClassPropertyColumnMappings<*>.forEachColumn(block: (Column<*>) -> Unit) { for (propertyColumnMapping in this) when (propertyColumnMapping) { is ExposedSqlPrimitive -> block(propertyColumnMapping.column) - is NestedClass -> propertyColumnMapping.nestedMappings.forEachColumn(block) + is NestedClass -> when (val adt = propertyColumnMapping.adt) { + is NestedClass.Adt.Product -> adt.nestedMappings.forEachColumn(block) + is NestedClass.Adt.Sum<*, *> -> { + block(adt.sumTypeCaseConfig.caseValueColumn) + adt.subclassMap.values.forEach { it.nestedMappings.forEachColumn(block) } + } + } + + is Custom -> propertyColumnMapping.classPropertyMapper.neededColumns.forEach(block) is Skip -> {} } } -fun setUpdateBuilderToNulls( - classPropertyColumnMappings: ClassPropertyColumnMappings, updateBuilder: UpdateBuilder<*> +fun setUpdateBuilderToNulls( + classPropertyColumnMappings: ClassPropertyColumnMappings<*>, updateBuilder: UpdateBuilder<*> ) = classPropertyColumnMappings.forEachColumn { @Suppress("UNCHECKED_CAST") @@ -208,12 +516,12 @@ fun ClassPropertyColumnMappings<*>.getNeededColumns(): List> = inline fun reflectionBasedClassPropertyMapper( tables: List
, - customMappings: PropertyColumnMappings = emptyList(), - onDuplicateColumnPropertyNames: OnDuplicateColumnPropertyNames = CHOOSE_FIRST + onDuplicateColumnPropertyNames: OnDuplicateColumnPropertyNames = CHOOSE_FIRST, + customMappings: PropertyColumnMappings = emptyList() ): ReflectionBasedClassPropertyMapper { val clazz = Data::class return ReflectionBasedClassPropertyMapper( - clazz, getDefaultClassColumnMappings(clazz, tables, customMappings, onDuplicateColumnPropertyNames) + clazz, getDefaultClassPropertyColumnMappings(clazz, tables, onDuplicateColumnPropertyNames, customMappings) ) } @@ -221,4 +529,4 @@ inline fun reflectionBasedClassProperty table: Table, customMappings: PropertyColumnMappings = emptyList() ) = - reflectionBasedClassPropertyMapper(listOf(table), customMappings, THROW) + reflectionBasedClassPropertyMapper(listOf(table), THROW, customMappings) diff --git a/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/SimpleClassPropertyMapping.kt b/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/SimpleClassPropertyMapping.kt index ba5f206..85f7b01 100644 --- a/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/SimpleClassPropertyMapping.kt +++ b/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/SimpleClassPropertyMapping.kt @@ -1,22 +1,30 @@ package com.huanshankeji.exposed.classpropertymapping import org.jetbrains.exposed.dao.id.EntityID -import org.jetbrains.exposed.sql.Alias -import org.jetbrains.exposed.sql.Column -import org.jetbrains.exposed.sql.ResultRow -import org.jetbrains.exposed.sql.Table +import org.jetbrains.exposed.sql.* import org.jetbrains.exposed.sql.statements.UpdateBuilder import kotlin.reflect.KClass import kotlin.reflect.KFunction import kotlin.reflect.KProperty1 import kotlin.reflect.full.memberProperties import kotlin.reflect.full.primaryConstructor +import kotlin.sequences.Sequence -interface SimpleClassPropertyMapper { +fun interface SimpleClassPropertyQueryMapper { fun resultRowToData(resultRow: ResultRow): Data - fun updateBuilderSetter(data: Data): TableT.(UpdateBuilder<*>) -> Unit } +fun interface SimpleClassPropertyUpdateMapper { + fun updateBuilderSetter(data: Data): ColumnSetT.(UpdateBuilder<*>) -> Unit = { + setUpdateBuilder(data, it) + } + + fun setUpdateBuilder(data: Data, updateBuilder: UpdateBuilder<*>) +} + +interface SimpleClassPropertyMapper : + SimpleClassPropertyQueryMapper, SimpleClassPropertyUpdateMapper + fun ResultRow.getValue(column: Column<*>): Any? = this[column].let { if (it is EntityID<*>) it.value else it @@ -33,10 +41,10 @@ interface ReflectionBasedSimpleClassPropertyMapper : return dataPrimaryConstructor.call(*params.toTypedArray()) } - override fun updateBuilderSetter(data: Data): TableT.(UpdateBuilder<*>) -> Unit = { + override fun setUpdateBuilder(data: Data, updateBuilder: UpdateBuilder<*>) { for ((property, column) in propertyAndColumnPairs) @Suppress("UNCHECKED_CAST") - it[column as Column] = property(data) + updateBuilder[column as Column] = property(data) } } From deb59a06fd7b52b3797a1a32dda3fb9ba387d82e Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Fri, 28 Oct 2022 16:35:52 +0800 Subject: [PATCH 17/59] Remove some comments marked to be removed in the previous commit --- buildSrc/src/main/kotlin/VersionsAndDependencies.kt | 7 ------- exposed/build.gradle.kts | 2 -- .../exposed/classpropertymapping/ClassPropertyMapping.kt | 1 - 3 files changed, 10 deletions(-) diff --git a/buildSrc/src/main/kotlin/VersionsAndDependencies.kt b/buildSrc/src/main/kotlin/VersionsAndDependencies.kt index e752ac5..49b2c3a 100644 --- a/buildSrc/src/main/kotlin/VersionsAndDependencies.kt +++ b/buildSrc/src/main/kotlin/VersionsAndDependencies.kt @@ -7,10 +7,3 @@ val projectVersion = "0.3.0-SNAPSHOT" val commonVersions = CommonVersions() val commonDependencies = CommonDependencies(commonVersions) val commonGradleClasspathDependencies = CommonGradleClasspathDependencies(commonVersions) - -// TODO: remove -/* -object DependencyVersions { - const val guava = "31.1-jre" -} -*/ diff --git a/exposed/build.gradle.kts b/exposed/build.gradle.kts index 7e72836..f471d4b 100644 --- a/exposed/build.gradle.kts +++ b/exposed/build.gradle.kts @@ -4,6 +4,4 @@ plugins { dependencies { implementation(commonDependencies.exposed.core()) - // TODO: remove - //implementation("com.google.guava:guava:${DependencyVersions.guava}") } diff --git a/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/ClassPropertyMapping.kt b/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/ClassPropertyMapping.kt index 5491b92..464f5e9 100644 --- a/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/ClassPropertyMapping.kt +++ b/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/ClassPropertyMapping.kt @@ -43,7 +43,6 @@ sealed class PropertyColumnMapping(val property: KProp Adt() class Sum( - // I first used the Guava BiMap but then realized it's not necessary. TODO: remove this comment val subclassMap: Map, Product>, val sumTypeCaseConfig: SumTypeCaseConfig ) : Adt() From 60282aaac9f67e395e10ae9f370845265fbde1d5 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Fri, 28 Oct 2022 16:45:06 +0800 Subject: [PATCH 18/59] Rename some type parameters to make their names more consistent, resolving 2 TODOs --- .../ClassPropertyMapping.kt | 54 +++++++++---------- 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/ClassPropertyMapping.kt b/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/ClassPropertyMapping.kt index 464f5e9..d4f62a2 100644 --- a/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/ClassPropertyMapping.kt +++ b/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/ClassPropertyMapping.kt @@ -19,33 +19,31 @@ typealias ClassPropertyColumnMappings = PropertyColumnMappings // TODO: decouple/remove `property` and `Data` from this class. sealed class PropertyColumnMapping(val property: KProperty1) { - // TODO: rename all occurrences of "PrimitiveValue" to "PropertyData". - class ExposedSqlPrimitive( - property: KProperty1, - val column: Column - ) : PropertyColumnMapping(property) - - // TODO: rename all occurrences of "NestedData" to "PropertyData". - class NestedClass( - property: KProperty1, - val nullability: Nullability, - val adt: Adt - ) : PropertyColumnMapping(property) { - sealed class Nullability { - class NonNullable : Nullability() - class Nullable(val nullDependentColumn: Column<*>) : - Nullability() + class ExposedSqlPrimitive( + property: KProperty1, + val column: Column + ) : PropertyColumnMapping(property) + + class NestedClass( + property: KProperty1, + val nullability: Nullability, + val adt: Adt + ) : PropertyColumnMapping(property) { + sealed class Nullability { + class NonNullable : Nullability() + class Nullable(val nullDependentColumn: Column<*>) : + Nullability() } // ADT: algebraic data type - sealed class Adt { - class Product(val nestedMappings: ClassPropertyColumnMappings) : - Adt() - - class Sum( - val subclassMap: Map, Product>, - val sumTypeCaseConfig: SumTypeCaseConfig - ) : Adt() + sealed class Adt { + class Product(val nestedMappings: ClassPropertyColumnMappings) : + Adt() + + class Sum( + val subclassMap: Map, Product>, + val sumTypeCaseConfig: SumTypeCaseConfig + ) : Adt() } } @@ -59,10 +57,10 @@ sealed class PropertyColumnMapping(val property: KProp PropertyColumnMapping(property) } -class SumTypeCaseConfig( - val caseValueColumn: Column, - val caseValueToClass: (Case) -> KClass, - val classToCaseValue: (KClass?) -> Case +class SumTypeCaseConfig( + val caseValueColumn: Column, + val caseValueToClass: (CaseValue) -> KClass, + val classToCaseValue: (KClass?) -> CaseValue ) From 8168ba8420006cd4af09a207d99541aefd09c067 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Fri, 28 Oct 2022 17:05:05 +0800 Subject: [PATCH 19/59] Include `nullDependentColumn` in `forEachColumn` and eliminate duplicates in `getNeededColumns` which is renamed to `getNeededColumnSet` --- .../ClassPropertyMapping.kt | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/ClassPropertyMapping.kt b/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/ClassPropertyMapping.kt index d4f62a2..84cd797 100644 --- a/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/ClassPropertyMapping.kt +++ b/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/ClassPropertyMapping.kt @@ -358,7 +358,7 @@ class ReflectionBasedClassPropertyMapper( val clazz: KClass, val classPropertyColumnMappings: ClassPropertyColumnMappings, ) : ClassPropertyMapper { - override val neededColumns = classPropertyColumnMappings.getNeededColumns() + override val neededColumns = classPropertyColumnMappings.getNeededColumnSet().toList() override fun resultRowToData(resultRow: ResultRow): Data = constructDataWithResultRow(clazz, classPropertyColumnMappings, resultRow) @@ -487,11 +487,17 @@ fun ClassPropertyColumnMappings<*>.forEachColumn(block: (Column<*>) -> Unit) { for (propertyColumnMapping in this) when (propertyColumnMapping) { is ExposedSqlPrimitive -> block(propertyColumnMapping.column) - is NestedClass -> when (val adt = propertyColumnMapping.adt) { - is NestedClass.Adt.Product -> adt.nestedMappings.forEachColumn(block) - is NestedClass.Adt.Sum<*, *> -> { - block(adt.sumTypeCaseConfig.caseValueColumn) - adt.subclassMap.values.forEach { it.nestedMappings.forEachColumn(block) } + is NestedClass -> { + when (val nullability = propertyColumnMapping.nullability) { + is NestedClass.Nullability.NonNullable -> {} + is NestedClass.Nullability.Nullable -> block(nullability.nullDependentColumn) + } + when (val adt = propertyColumnMapping.adt) { + is NestedClass.Adt.Product -> adt.nestedMappings.forEachColumn(block) + is NestedClass.Adt.Sum<*, *> -> { + block(adt.sumTypeCaseConfig.caseValueColumn) + adt.subclassMap.values.forEach { it.nestedMappings.forEachColumn(block) } + } } } @@ -508,8 +514,8 @@ fun setUpdateBuilderToNulls( updateBuilder[it as Column] = null } -fun ClassPropertyColumnMappings<*>.getNeededColumns(): List> = - buildList { forEachColumn { add(it) } } +fun ClassPropertyColumnMappings<*>.getNeededColumnSet(): Set> = + buildSet { forEachColumn { add(it) } } inline fun reflectionBasedClassPropertyMapper( tables: List
, From eeae589658c899cc94637c21c1fda4a2e3e7843a Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Fri, 28 Oct 2022 17:50:02 +0800 Subject: [PATCH 20/59] Pre-process distinct `columnsForAllSubclasses` in `PropertyColumnMapping.NestedClass.Adt.Sum`, refactor related functions, and resolve a related TODO --- .../ClassPropertyMapping.kt | 105 ++++++++++-------- 1 file changed, 59 insertions(+), 46 deletions(-) diff --git a/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/ClassPropertyMapping.kt b/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/ClassPropertyMapping.kt index 84cd797..6660fe2 100644 --- a/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/ClassPropertyMapping.kt +++ b/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/ClassPropertyMapping.kt @@ -43,9 +43,13 @@ sealed class PropertyColumnMapping(val property: KProp class Sum( val subclassMap: Map, Product>, val sumTypeCaseConfig: SumTypeCaseConfig - ) : Adt() + ) : Adt() { + val columnsForAllSubclasses = subclassMap.values.asSequence() + .flatMap { it.nestedMappings.getNeededColumnSet() } + .toSet() // Using `toSet` seems to be faster than `distinct`. + .toList() + } } - } // TODO: remove the temporary workaround `& Any` if and when the `Any` upper bound is removed. @@ -430,38 +434,38 @@ fun setUpdateBuilder( if (propertyData !== null) setUpdateBuilder(nestedMappings, propertyData, updateBuilder) else - setUpdateBuilderToNulls(nestedMappings, updateBuilder) + setUpdateBuilderColumnsToNullsWithMappings(nestedMappings, updateBuilder) } is NestedClass.Adt.Sum -> { fun typeParameterHelper() { @Suppress("UNCHECKED_CAST") adt as NestedClass.Adt.Sum - val sumTypeCaseConfig = adt.sumTypeCaseConfig - val subclassMap = adt.subclassMap - if (propertyData !== null) { - // TODO: it seems to be a compiler bug that the non-null assertion is needed here. - val propertyDataClass = propertyData!!::class - with(sumTypeCaseConfig) { - updateBuilder[caseValueColumn] = classToCaseValue(propertyDataClass) - } - fun typeParameterHelper( - subclassMapping: NestedClass.Adt.Product, - propertyData: SubclassData - ) = - setUpdateBuilder(subclassMapping.nestedMappings, propertyData, updateBuilder) - @Suppress("UNCHECKED_CAST") - typeParameterHelper( - subclassMap.getValue(propertyDataClass) as NestedClass.Adt.Product, - propertyData - ) - } else { - with(sumTypeCaseConfig) { - updateBuilder[caseValueColumn] = classToCaseValue(null) + with(adt) { + if (propertyData !== null) { + // TODO: it seems to be a compiler bug that the non-null assertion is needed here. + val propertyDataClass = propertyData!!::class + with(sumTypeCaseConfig) { + updateBuilder[caseValueColumn] = classToCaseValue(propertyDataClass) + } + fun typeParameterHelper( + subclassMapping: NestedClass.Adt.Product, + propertyData: SubclassData + ) = + setUpdateBuilder( + subclassMapping.nestedMappings, propertyData, updateBuilder + ) + @Suppress("UNCHECKED_CAST") + typeParameterHelper( + subclassMap.getValue(propertyDataClass) as NestedClass.Adt.Product, + propertyData + ) + } else { + with(sumTypeCaseConfig) { + updateBuilder[caseValueColumn] = classToCaseValue(null) + } + setUpdateBuilderColumnsToNulls(columnsForAllSubclasses, updateBuilder) } - // TODO: pre-process the combined columns and eliminate duplicates. - for (product in subclassMap.values) - setUpdateBuilderToNulls(product.nestedMappings, updateBuilder) } } typeParameterHelper() @@ -483,30 +487,33 @@ fun setUpdateBuilder( } } -fun ClassPropertyColumnMappings<*>.forEachColumn(block: (Column<*>) -> Unit) { - for (propertyColumnMapping in this) - when (propertyColumnMapping) { - is ExposedSqlPrimitive -> block(propertyColumnMapping.column) - is NestedClass -> { - when (val nullability = propertyColumnMapping.nullability) { - is NestedClass.Nullability.NonNullable -> {} - is NestedClass.Nullability.Nullable -> block(nullability.nullDependentColumn) - } - when (val adt = propertyColumnMapping.adt) { - is NestedClass.Adt.Product -> adt.nestedMappings.forEachColumn(block) - is NestedClass.Adt.Sum<*, *> -> { - block(adt.sumTypeCaseConfig.caseValueColumn) - adt.subclassMap.values.forEach { it.nestedMappings.forEachColumn(block) } - } +fun PropertyColumnMapping<*, *>.forEachColumn(block: (Column<*>) -> Unit) = + when (this) { + is ExposedSqlPrimitive -> block(column) + is NestedClass -> { + when (nullability) { + is NestedClass.Nullability.NonNullable -> {} + is NestedClass.Nullability.Nullable -> block(nullability.nullDependentColumn) + } + when (adt) { + is NestedClass.Adt.Product -> adt.nestedMappings.forEachColumn(block) + is NestedClass.Adt.Sum<*, *> -> { + block(adt.sumTypeCaseConfig.caseValueColumn) + adt.subclassMap.values.forEach { it.nestedMappings.forEachColumn(block) } } } - - is Custom -> propertyColumnMapping.classPropertyMapper.neededColumns.forEach(block) - is Skip -> {} } + + is Custom -> classPropertyMapper.neededColumns.forEach(block) + is Skip -> {} + } + +fun ClassPropertyColumnMappings<*>.forEachColumn(block: (Column<*>) -> Unit) { + for (propertyColumnMapping in this) + propertyColumnMapping.forEachColumn(block) } -fun setUpdateBuilderToNulls( +fun setUpdateBuilderColumnsToNullsWithMappings( classPropertyColumnMappings: ClassPropertyColumnMappings<*>, updateBuilder: UpdateBuilder<*> ) = classPropertyColumnMappings.forEachColumn { @@ -514,6 +521,12 @@ fun setUpdateBuilderToNulls( updateBuilder[it as Column] = null } +fun setUpdateBuilderColumnsToNulls(columns: List>, updateBuilder: UpdateBuilder<*>) { + for (column in columns) + @Suppress("UNCHECKED_CAST") + updateBuilder[column as Column] = null +} + fun ClassPropertyColumnMappings<*>.getNeededColumnSet(): Set> = buildSet { forEachColumn { add(it) } } From 11b6ceccc418d768a7dec8505d1f381e301a26fc Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Fri, 28 Oct 2022 18:19:24 +0800 Subject: [PATCH 21/59] Consider whether to resolve a TODO comment and make it more specific --- .../exposed/classpropertymapping/ClassPropertyMapping.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/ClassPropertyMapping.kt b/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/ClassPropertyMapping.kt index 6660fe2..f1cafb0 100644 --- a/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/ClassPropertyMapping.kt +++ b/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/ClassPropertyMapping.kt @@ -17,7 +17,12 @@ typealias PropertyColumnMappings = List> /** In the order of the constructor arguments. */ typealias ClassPropertyColumnMappings = PropertyColumnMappings -// TODO: decouple/remove `property` and `Data` from this class. +/* +TODO: consider decoupling/removing `property` and `Data` from this class and rename it to `ColumnMapping` + and add a `PropertyColumnMapping` containing the property and the `ColumnMapping`. + However, after the refactor, `ColumnMapping` will still be coupled with `ClassPropertyColumnMappings` which is coupled with `PropertyColumnMapping`, + so I am not sure whether this is necessary. +*/ sealed class PropertyColumnMapping(val property: KProperty1) { class ExposedSqlPrimitive( property: KProperty1, From 766018989e32f9e053f3fd3e247b98502c223825 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Mon, 7 Nov 2022 20:38:15 +0800 Subject: [PATCH 22/59] Reorganize and rename the packages and interfaces, improve `columnsForAllSubclasses`, and remove the `ColumnSetT` type parameter in `SimpleDataUpdateMapper` --- .../datamapping/DataMapperInterfaces.kt | 31 ++++++++++++ .../classproperty}/ClassPropertyMapping.kt | 49 ++++++++----------- .../SimpleClassPropertyMapping.kt | 37 +++++--------- 3 files changed, 63 insertions(+), 54 deletions(-) create mode 100644 exposed/src/main/kotlin/com/huanshankeji/exposed/datamapping/DataMapperInterfaces.kt rename exposed/src/main/kotlin/com/huanshankeji/exposed/{classpropertymapping => datamapping/classproperty}/ClassPropertyMapping.kt (93%) rename exposed/src/main/kotlin/com/huanshankeji/exposed/{classpropertymapping => datamapping/classproperty}/SimpleClassPropertyMapping.kt (72%) diff --git a/exposed/src/main/kotlin/com/huanshankeji/exposed/datamapping/DataMapperInterfaces.kt b/exposed/src/main/kotlin/com/huanshankeji/exposed/datamapping/DataMapperInterfaces.kt new file mode 100644 index 0000000..c381e5c --- /dev/null +++ b/exposed/src/main/kotlin/com/huanshankeji/exposed/datamapping/DataMapperInterfaces.kt @@ -0,0 +1,31 @@ +package com.huanshankeji.exposed.datamapping + +import org.jetbrains.exposed.sql.Column +import org.jetbrains.exposed.sql.ColumnSet +import org.jetbrains.exposed.sql.ResultRow +import org.jetbrains.exposed.sql.statements.UpdateBuilder + +fun interface SimpleDataQueryMapper { + fun resultRowToData(resultRow: ResultRow): Data +} + +fun interface SimpleDataUpdateMapper { + fun setUpdateBuilder(data: Data, updateBuilder: UpdateBuilder<*>) +} + +fun SimpleDataUpdateMapper.updateBuilderSetter(data: Data): + ColumnSetT.(UpdateBuilder<*>) -> Unit = { + setUpdateBuilder(data, it) +} + +interface SimpleDataMapper : + SimpleDataQueryMapper, SimpleDataUpdateMapper + + +interface DataQueryMapper : SimpleDataQueryMapper { + val neededColumns: List> +} + +typealias DataUpdateMapper = SimpleDataUpdateMapper + +interface DataMapper : DataQueryMapper, SimpleDataMapper diff --git a/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/ClassPropertyMapping.kt b/exposed/src/main/kotlin/com/huanshankeji/exposed/datamapping/classproperty/ClassPropertyMapping.kt similarity index 93% rename from exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/ClassPropertyMapping.kt rename to exposed/src/main/kotlin/com/huanshankeji/exposed/datamapping/classproperty/ClassPropertyMapping.kt index f1cafb0..764251e 100644 --- a/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/ClassPropertyMapping.kt +++ b/exposed/src/main/kotlin/com/huanshankeji/exposed/datamapping/classproperty/ClassPropertyMapping.kt @@ -1,7 +1,8 @@ -package com.huanshankeji.exposed.classpropertymapping +package com.huanshankeji.exposed.datamapping.classproperty -import com.huanshankeji.exposed.classpropertymapping.OnDuplicateColumnPropertyNames.* -import com.huanshankeji.exposed.classpropertymapping.PropertyColumnMapping.* +import com.huanshankeji.exposed.datamapping.DataMapper +import com.huanshankeji.exposed.datamapping.classproperty.OnDuplicateColumnPropertyNames.* +import com.huanshankeji.exposed.datamapping.classproperty.PropertyColumnMapping.* import org.jetbrains.exposed.sql.* import org.jetbrains.exposed.sql.statements.UpdateBuilder import org.slf4j.LoggerFactory @@ -49,17 +50,17 @@ sealed class PropertyColumnMapping(val property: KProp val subclassMap: Map, Product>, val sumTypeCaseConfig: SumTypeCaseConfig ) : Adt() { - val columnsForAllSubclasses = subclassMap.values.asSequence() - .flatMap { it.nestedMappings.getNeededColumnSet() } - .toSet() // Using `toSet` seems to be faster than `distinct`. - .toList() + val columnsForAllSubclasses = buildSet { + for (subclassProductMapping in subclassMap.values) + addAll(subclassProductMapping.nestedMappings.getColumnSet()) + }.toList() } } } // TODO: remove the temporary workaround `& Any` if and when the `Any` upper bound is removed. class Custom( - property: KProperty1, val classPropertyMapper: ClassPropertyMapper + property: KProperty1, val dataMapper: DataMapper ) : PropertyColumnMapping(property) class Skip(property: KProperty1) : @@ -353,21 +354,13 @@ fun getDefaultClassPropertyColumnMappings( customMappings ) -interface ClassPropertyQueryMapper : SimpleClassPropertyQueryMapper { - val neededColumns: List> -} - -typealias ClassPropertyUpdateMapper = ClassPropertyQueryMapper - -interface ClassPropertyMapper : ClassPropertyQueryMapper, SimpleClassPropertyMapper - // TODO: decouple query mapper and update mapper. /** Supports classes with nested composite class properties and multiple tables */ -class ReflectionBasedClassPropertyMapper( +class ReflectionBasedClassPropertyDataMapper( val clazz: KClass, val classPropertyColumnMappings: ClassPropertyColumnMappings, -) : ClassPropertyMapper { - override val neededColumns = classPropertyColumnMappings.getNeededColumnSet().toList() +) : DataMapper { + override val neededColumns = classPropertyColumnMappings.getColumnSet().toList() override fun resultRowToData(resultRow: ResultRow): Data = constructDataWithResultRow(clazz, classPropertyColumnMappings, resultRow) @@ -414,7 +407,7 @@ fun constructDataWithResultRow( } } - is Custom -> propertyColumnMapping.classPropertyMapper.resultRowToData(resultRow) + is Custom -> propertyColumnMapping.dataMapper.resultRowToData(resultRow) is Skip -> null } @Suppress("UNCHECKED_CAST") @@ -480,7 +473,7 @@ fun setUpdateBuilder( is Custom -> // TODO: remove this cast if and when not only non-nullable data are supported. - propertyColumnMapping.classPropertyMapper.setUpdateBuilder( + propertyColumnMapping.dataMapper.setUpdateBuilder( propertyData as (PropertyData & Any), updateBuilder ) @@ -509,7 +502,7 @@ fun PropertyColumnMapping<*, *>.forEachColumn(block: (Column<*>) -> Unit) = } } - is Custom -> classPropertyMapper.neededColumns.forEach(block) + is Custom -> dataMapper.neededColumns.forEach(block) is Skip -> {} } @@ -532,22 +525,22 @@ fun setUpdateBuilderColumnsToNulls(columns: List>, updateBuilder: Upda updateBuilder[column as Column] = null } -fun ClassPropertyColumnMappings<*>.getNeededColumnSet(): Set> = +fun ClassPropertyColumnMappings<*>.getColumnSet(): Set> = buildSet { forEachColumn { add(it) } } -inline fun reflectionBasedClassPropertyMapper( +inline fun reflectionBasedClassPropertyDataMapper( tables: List
, onDuplicateColumnPropertyNames: OnDuplicateColumnPropertyNames = CHOOSE_FIRST, customMappings: PropertyColumnMappings = emptyList() -): ReflectionBasedClassPropertyMapper { +): ReflectionBasedClassPropertyDataMapper { val clazz = Data::class - return ReflectionBasedClassPropertyMapper( + return ReflectionBasedClassPropertyDataMapper( clazz, getDefaultClassPropertyColumnMappings(clazz, tables, onDuplicateColumnPropertyNames, customMappings) ) } -inline fun reflectionBasedClassPropertyMapper( +inline fun reflectionBasedClassPropertyDataMapper( table: Table, customMappings: PropertyColumnMappings = emptyList() ) = - reflectionBasedClassPropertyMapper(listOf(table), THROW, customMappings) + reflectionBasedClassPropertyDataMapper(listOf(table), THROW, customMappings) diff --git a/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/SimpleClassPropertyMapping.kt b/exposed/src/main/kotlin/com/huanshankeji/exposed/datamapping/classproperty/SimpleClassPropertyMapping.kt similarity index 72% rename from exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/SimpleClassPropertyMapping.kt rename to exposed/src/main/kotlin/com/huanshankeji/exposed/datamapping/classproperty/SimpleClassPropertyMapping.kt index 85f7b01..dd62948 100644 --- a/exposed/src/main/kotlin/com/huanshankeji/exposed/classpropertymapping/SimpleClassPropertyMapping.kt +++ b/exposed/src/main/kotlin/com/huanshankeji/exposed/datamapping/classproperty/SimpleClassPropertyMapping.kt @@ -1,5 +1,6 @@ -package com.huanshankeji.exposed.classpropertymapping +package com.huanshankeji.exposed.datamapping.classproperty +import com.huanshankeji.exposed.datamapping.SimpleDataMapper import org.jetbrains.exposed.dao.id.EntityID import org.jetbrains.exposed.sql.* import org.jetbrains.exposed.sql.statements.UpdateBuilder @@ -10,29 +11,13 @@ import kotlin.reflect.full.memberProperties import kotlin.reflect.full.primaryConstructor import kotlin.sequences.Sequence -fun interface SimpleClassPropertyQueryMapper { - fun resultRowToData(resultRow: ResultRow): Data -} - -fun interface SimpleClassPropertyUpdateMapper { - fun updateBuilderSetter(data: Data): ColumnSetT.(UpdateBuilder<*>) -> Unit = { - setUpdateBuilder(data, it) - } - - fun setUpdateBuilder(data: Data, updateBuilder: UpdateBuilder<*>) -} - -interface SimpleClassPropertyMapper : - SimpleClassPropertyQueryMapper, SimpleClassPropertyUpdateMapper - fun ResultRow.getValue(column: Column<*>): Any? = this[column].let { if (it is EntityID<*>) it.value else it } /** Nested classes are not supported. */ -interface ReflectionBasedSimpleClassPropertyMapper : - SimpleClassPropertyMapper { +interface ReflectionBasedSimpleClassPropertyDataMapper : SimpleDataMapper { val propertyAndColumnPairs: List, Column<*>>> val dataPrimaryConstructor: KFunction @@ -48,8 +33,8 @@ interface ReflectionBasedSimpleClassPropertyMapper : } } -inline fun reflectionBasedSimpleClassPropertyMapper(table: TableT): ReflectionBasedSimpleClassPropertyMapper = - object : ReflectionBasedSimpleClassPropertyMapper { +inline fun reflectionBasedSimpleClassPropertyDataMapper(table: Table): ReflectionBasedSimpleClassPropertyDataMapper = + object : ReflectionBasedSimpleClassPropertyDataMapper { private val clazz = Data::class // This property needs to initialize first. @@ -78,13 +63,13 @@ inline fun getColumnByPropertyNameMapWithTypeParameter( getColumnPropertyByNameMap(TableT::class) .mapValues { it.value(table) } -inline fun reflectionBasedSimpleClassPropertyMapperForAlias( - tableClassPropertyMapper: ReflectionBasedSimpleClassPropertyMapper, alias: Alias -): ReflectionBasedSimpleClassPropertyMapper = - object : ReflectionBasedSimpleClassPropertyMapper { - override val dataPrimaryConstructor = tableClassPropertyMapper.dataPrimaryConstructor +inline fun reflectionBasedSimpleClassPropertyDataMapperForAlias( + tableDataMapper: ReflectionBasedSimpleClassPropertyDataMapper, alias: Alias +): ReflectionBasedSimpleClassPropertyDataMapper = + object : ReflectionBasedSimpleClassPropertyDataMapper { + override val dataPrimaryConstructor = tableDataMapper.dataPrimaryConstructor override val propertyAndColumnPairs = - tableClassPropertyMapper.propertyAndColumnPairs.map { it.first to alias[it.second] } + tableDataMapper.propertyAndColumnPairs.map { it.first to alias[it.second] } } From f6ef7e6bc3ae5da5a839894e22b0c384bc990b3b Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Wed, 9 Nov 2022 12:02:03 +0800 Subject: [PATCH 23/59] Add and use nullable data mapper interfaces --- .../datamapping/DataMapperInterfaces.kt | 20 +++++++++++-------- .../classproperty/ClassPropertyMapping.kt | 13 +++++------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/exposed/src/main/kotlin/com/huanshankeji/exposed/datamapping/DataMapperInterfaces.kt b/exposed/src/main/kotlin/com/huanshankeji/exposed/datamapping/DataMapperInterfaces.kt index c381e5c..297a0cc 100644 --- a/exposed/src/main/kotlin/com/huanshankeji/exposed/datamapping/DataMapperInterfaces.kt +++ b/exposed/src/main/kotlin/com/huanshankeji/exposed/datamapping/DataMapperInterfaces.kt @@ -5,27 +5,31 @@ import org.jetbrains.exposed.sql.ColumnSet import org.jetbrains.exposed.sql.ResultRow import org.jetbrains.exposed.sql.statements.UpdateBuilder -fun interface SimpleDataQueryMapper { +fun interface SimpleNullableDataQueryMapper { fun resultRowToData(resultRow: ResultRow): Data } -fun interface SimpleDataUpdateMapper { +fun interface SimpleDataQueryMapper : SimpleNullableDataQueryMapper + +fun interface NullableDataUpdateMapper { fun setUpdateBuilder(data: Data, updateBuilder: UpdateBuilder<*>) } -fun SimpleDataUpdateMapper.updateBuilderSetter(data: Data): +fun interface DataUpdateMapper : NullableDataUpdateMapper + +fun DataUpdateMapper.updateBuilderSetter(data: Data): ColumnSetT.(UpdateBuilder<*>) -> Unit = { setUpdateBuilder(data, it) } -interface SimpleDataMapper : - SimpleDataQueryMapper, SimpleDataUpdateMapper +interface SimpleDataMapper : SimpleDataQueryMapper, DataUpdateMapper -interface DataQueryMapper : SimpleDataQueryMapper { +interface NullableDataQueryMapper : SimpleNullableDataQueryMapper { val neededColumns: List> } -typealias DataUpdateMapper = SimpleDataUpdateMapper +interface DataQueryMapper : NullableDataQueryMapper -interface DataMapper : DataQueryMapper, SimpleDataMapper +interface NullableDataMapper : NullableDataQueryMapper, NullableDataUpdateMapper +interface DataMapper : NullableDataMapper, DataQueryMapper, SimpleDataMapper diff --git a/exposed/src/main/kotlin/com/huanshankeji/exposed/datamapping/classproperty/ClassPropertyMapping.kt b/exposed/src/main/kotlin/com/huanshankeji/exposed/datamapping/classproperty/ClassPropertyMapping.kt index 764251e..89cb132 100644 --- a/exposed/src/main/kotlin/com/huanshankeji/exposed/datamapping/classproperty/ClassPropertyMapping.kt +++ b/exposed/src/main/kotlin/com/huanshankeji/exposed/datamapping/classproperty/ClassPropertyMapping.kt @@ -1,6 +1,7 @@ package com.huanshankeji.exposed.datamapping.classproperty import com.huanshankeji.exposed.datamapping.DataMapper +import com.huanshankeji.exposed.datamapping.NullableDataMapper import com.huanshankeji.exposed.datamapping.classproperty.OnDuplicateColumnPropertyNames.* import com.huanshankeji.exposed.datamapping.classproperty.PropertyColumnMapping.* import org.jetbrains.exposed.sql.* @@ -58,9 +59,8 @@ sealed class PropertyColumnMapping(val property: KProp } } - // TODO: remove the temporary workaround `& Any` if and when the `Any` upper bound is removed. class Custom( - property: KProperty1, val dataMapper: DataMapper + property: KProperty1, val nullableDataMapper: NullableDataMapper ) : PropertyColumnMapping(property) class Skip(property: KProperty1) : @@ -407,7 +407,7 @@ fun constructDataWithResultRow( } } - is Custom -> propertyColumnMapping.dataMapper.resultRowToData(resultRow) + is Custom -> propertyColumnMapping.nullableDataMapper.resultRowToData(resultRow) is Skip -> null } @Suppress("UNCHECKED_CAST") @@ -472,10 +472,7 @@ fun setUpdateBuilder( } is Custom -> - // TODO: remove this cast if and when not only non-nullable data are supported. - propertyColumnMapping.dataMapper.setUpdateBuilder( - propertyData as (PropertyData & Any), updateBuilder - ) + propertyColumnMapping.nullableDataMapper.setUpdateBuilder(propertyData, updateBuilder) is Skip -> {} } @@ -502,7 +499,7 @@ fun PropertyColumnMapping<*, *>.forEachColumn(block: (Column<*>) -> Unit) = } } - is Custom -> dataMapper.neededColumns.forEach(block) + is Custom -> nullableDataMapper.neededColumns.forEach(block) is Skip -> {} } From 912cb4b7b3542bc73f1a423dd2b33fccf4a011d5 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Thu, 10 Nov 2022 11:27:02 +0800 Subject: [PATCH 24/59] Fix a bug introduced in commit 766018989e32f9e053f3fd3e247b98502c223825 that the `TableT` reified type parameter is removed in `reflectionBasedSimpleClassPropertyDataMapper` --- .../datamapping/classproperty/SimpleClassPropertyMapping.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/exposed/src/main/kotlin/com/huanshankeji/exposed/datamapping/classproperty/SimpleClassPropertyMapping.kt b/exposed/src/main/kotlin/com/huanshankeji/exposed/datamapping/classproperty/SimpleClassPropertyMapping.kt index dd62948..8dcf713 100644 --- a/exposed/src/main/kotlin/com/huanshankeji/exposed/datamapping/classproperty/SimpleClassPropertyMapping.kt +++ b/exposed/src/main/kotlin/com/huanshankeji/exposed/datamapping/classproperty/SimpleClassPropertyMapping.kt @@ -33,7 +33,8 @@ interface ReflectionBasedSimpleClassPropertyDataMapper : SimpleDataM } } -inline fun reflectionBasedSimpleClassPropertyDataMapper(table: Table): ReflectionBasedSimpleClassPropertyDataMapper = +// The `TableT` reified type parameter is passed to the functions called and should not be removed. +inline fun reflectionBasedSimpleClassPropertyDataMapper(table: TableT): ReflectionBasedSimpleClassPropertyDataMapper = object : ReflectionBasedSimpleClassPropertyDataMapper { private val clazz = Data::class From bd444b77f5169537df840aea34d5b0435e4a9372 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Thu, 10 Nov 2022 17:35:33 +0800 Subject: [PATCH 25/59] Add the `propertyColumnMappingConfigMapOverride` argument in the overloaded functions `reflectionBasedClassPropertyDataMapper` --- .../classproperty/ClassPropertyMapping.kt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/exposed/src/main/kotlin/com/huanshankeji/exposed/datamapping/classproperty/ClassPropertyMapping.kt b/exposed/src/main/kotlin/com/huanshankeji/exposed/datamapping/classproperty/ClassPropertyMapping.kt index 89cb132..79cd8bf 100644 --- a/exposed/src/main/kotlin/com/huanshankeji/exposed/datamapping/classproperty/ClassPropertyMapping.kt +++ b/exposed/src/main/kotlin/com/huanshankeji/exposed/datamapping/classproperty/ClassPropertyMapping.kt @@ -344,8 +344,8 @@ fun KClass.sealedLeafSubclasses(): List> = fun getDefaultClassPropertyColumnMappings( clazz: KClass, tables: List
, onDuplicateColumnPropertyNames: OnDuplicateColumnPropertyNames = CHOOSE_FIRST, - customMappings: PropertyColumnMappings = emptyList(), - propertyColumnMappingConfigMapOverride: PropertyColumnMappingConfigMap = emptyMap() + propertyColumnMappingConfigMapOverride: PropertyColumnMappingConfigMap = emptyMap(), + customMappings: PropertyColumnMappings = emptyList() ): ClassPropertyColumnMappings = getDefaultClassPropertyColumnMappings( clazz, @@ -528,16 +528,20 @@ fun ClassPropertyColumnMappings<*>.getColumnSet(): Set> = inline fun reflectionBasedClassPropertyDataMapper( tables: List
, onDuplicateColumnPropertyNames: OnDuplicateColumnPropertyNames = CHOOSE_FIRST, + propertyColumnMappingConfigMapOverride: PropertyColumnMappingConfigMap = emptyMap(), customMappings: PropertyColumnMappings = emptyList() ): ReflectionBasedClassPropertyDataMapper { val clazz = Data::class return ReflectionBasedClassPropertyDataMapper( - clazz, getDefaultClassPropertyColumnMappings(clazz, tables, onDuplicateColumnPropertyNames, customMappings) + clazz, getDefaultClassPropertyColumnMappings( + clazz, tables, onDuplicateColumnPropertyNames, propertyColumnMappingConfigMapOverride, customMappings + ) ) } inline fun reflectionBasedClassPropertyDataMapper( table: Table, + propertyColumnMappingConfigMapOverride: PropertyColumnMappingConfigMap = emptyMap(), customMappings: PropertyColumnMappings = emptyList() ) = - reflectionBasedClassPropertyDataMapper(listOf(table), THROW, customMappings) + reflectionBasedClassPropertyDataMapper(listOf(table), THROW, propertyColumnMappingConfigMapOverride, customMappings) From 89064be91e0f83bceec6b95a19b206c1dcaf746c Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Fri, 11 Nov 2022 17:24:41 +0800 Subject: [PATCH 26/59] Move `areElementsDistinct` into the `commonMain` source set --- .../kotlin/com/huanshankeji/collections/Collections.kt | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename core/src/{jvmMain => commonMain}/kotlin/com/huanshankeji/collections/Collections.kt (100%) diff --git a/core/src/jvmMain/kotlin/com/huanshankeji/collections/Collections.kt b/core/src/commonMain/kotlin/com/huanshankeji/collections/Collections.kt similarity index 100% rename from core/src/jvmMain/kotlin/com/huanshankeji/collections/Collections.kt rename to core/src/commonMain/kotlin/com/huanshankeji/collections/Collections.kt From c05a4d6e9c877a4bc77f15fe72d7f8bbca88c33a Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Fri, 11 Nov 2022 18:03:58 +0800 Subject: [PATCH 27/59] Add `List.eachCount` --- .../kotlin/com/huanshankeji/collections/Collections.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/src/commonMain/kotlin/com/huanshankeji/collections/Collections.kt b/core/src/commonMain/kotlin/com/huanshankeji/collections/Collections.kt index e4ec1aa..f46d8bd 100644 --- a/core/src/commonMain/kotlin/com/huanshankeji/collections/Collections.kt +++ b/core/src/commonMain/kotlin/com/huanshankeji/collections/Collections.kt @@ -3,3 +3,8 @@ package com.huanshankeji.collections fun List<*>.areElementsDistinct() = // There is a more efficient implementation. distinct().size == size + +fun List.eachCount() = + groupBy { it }.mapValues { it.value.size } +// This is tested to be faster than the implementation below in some scenarios. +//groupingBy { it }.eachCount() From 4dc202ef6471f07cef482d9b239ce149951ea3d9 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Fri, 30 Dec 2022 00:04:45 +0800 Subject: [PATCH 28/59] Bump the Gradle Wrapper to 7.6 --- gradle/wrapper/gradle-wrapper.jar | Bin 60756 -> 61574 bytes gradle/wrapper/gradle-wrapper.properties | 3 ++- gradlew | 12 ++++++++---- gradlew.bat | 1 + 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 249e5832f090a2944b7473328c07c9755baa3196..943f0cbfa754578e88a3dae77fce6e3dea56edbf 100644 GIT binary patch delta 36524 zcmZ6yQ*&aJ*i+pKn$=zKxk7ICNNX(G9gnUwow3iT2Ov?s|4Q$^qH|&1~>6K_f6Q@z)!W6o~05E1}7HS1}Bv=ef%?3Rc##Sb1)XzucCDxr#(Nfxotv ze%V_W`66|_=BK{+dN$WOZ#V$@kI(=7e7*Y3BMEum`h#%BJi{7P9=hz5ij2k_KbUm( zhz-iBt4RTzAPma)PhcHhjxYjxR6q^N4p+V6h&tZxbs!p4m8noJ?|i)9ATc@)IUzb~ zw2p)KDi7toTFgE%JA2d_9aWv7{xD{EzTGPb{V6+C=+O-u@I~*@9Q;(P9sE>h-v@&g ztSnY;?gI0q;XWPTrOm!4!5|uwJYJVPNluyu5}^SCc1ns-U#GrGqZ1B#qCcJbqoMAc zF$xB#F!(F?RcUqZtueR`*#i7DQ2CF?hhYV&goK!o`U?+H{F-15he}`xQ!)+H>0!QM z`)D&7s@{0}iVkz$(t{mqBKP?~W4b@KcuDglktFy&<2_z)F8Q~73;QcP`+pO=L}4yjlzNuLzuvnVAO``skBd=rV%VWQTd0x6_%ddY*G(AJt06`GHq zJVxl`G*RiYAeT=`Cf(SUN$kUEju!>SqwEd8RWUIk$|8A& zAvW|Uo<=TWC~u}V?SNFv`Fq9OeF_V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dpeA8(lc@(S34_Zb8UWQ#grZQ0DFe2NZ9rT!i0zk! zwn=~iWf;)=cS6mQY*T(f2O?tGW*=4r$j+g`R~RjV6cDkW!pHy^3F1NffE2tc{%(%w zm(Y>*=>0|@ZDFM2IyNYEkQZzoB*3dO*7?XAjS|Aeqrm}OQTPSK!EEhdBwMI3qF%)T z`iN(P<_0(OvUNm(!Vm^BMgFiTn*z!Z8s^Y=qOh!OD>@{%cx%@^TZDAx?4|M410{SqTm#yXk zaz`+b=5}`aRS}nw5iBoT5F>pQ18p_@)vqMSmLEVitr{UQQs>C103t_s%W)9UbHqcy zz^Dz(!8^|pFEd3p00#ocNRWUdU^yy-mN6oPaYsxXkQvwF(gFL&y&zFP&x%v8 z2tZGupne~qFrm+d22K+yavbDi921x!@l`4^Z79|cbezQi6w3rkKKaX(1QZqt`Vs=} zvov82nkJ4U-Ju9x9${_LgxOpx$k8~DoS$tRAir=BIB5d^p>tTXMv((>^gNPf9hjRW zL5-KeK)MDvjhubYDOspG4Ma}4K=d2zWm$0{aynBxpr|aiYcstb{1^|PEdhwm5+T3ZU#=){oFze(jcj+Sc^#n7qTxTE3w{>*{h6KdY89A1M}#@vzJ3Fc VwlMN}`%er%aGR6olj~j${vQ;P=LY}) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 8fad3f5..2b22d05 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip +networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index a69d9cb..65dcd68 100755 --- a/gradlew +++ b/gradlew @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,10 +80,10 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' @@ -143,12 +143,16 @@ fi if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac diff --git a/gradlew.bat b/gradlew.bat index f127cfd..93e3f59 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -26,6 +26,7 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% From 56c771effe5097c0fffc2c56d8ad6a2c02b993b1 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Fri, 30 Dec 2022 00:12:41 +0800 Subject: [PATCH 29/59] Bump Kotlin to 1.8.0 and run `:kotlinUpgradeYarnLock` as requested --- buildSrc/build.gradle.kts | 2 +- kotlin-js-store/yarn.lock | 31 ++++++++++++++++++------------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 0201cf4..e577198 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -15,7 +15,7 @@ repositories { } dependencies { - implementation(kotlin("gradle-plugin", "1.7.10")) + implementation(kotlin("gradle-plugin", "1.8.0")) implementation("com.huanshankeji:common-gradle-dependencies:0.3.2-20220728") implementation("com.huanshankeji.team:gradle-plugins:0.3.2") } diff --git a/kotlin-js-store/yarn.lock b/kotlin-js-store/yarn.lock index 635b33e..e741ac5 100644 --- a/kotlin-js-store/yarn.lock +++ b/kotlin-js-store/yarn.lock @@ -229,11 +229,16 @@ acorn-import-assertions@^1.7.6: resolved "https://registry.yarnpkg.com/acorn-import-assertions/-/acorn-import-assertions-1.8.0.tgz#ba2b5939ce62c238db6d93d81c9b111b29b855e9" integrity sha512-m7VZ3jwz4eK6A4Vtt8Ew1/mNbP24u0FhdyfA7fSvnJR6LMdfOYnmuIrrJAgrYfYJ10F/otaHTtrtrtmHdMNzEw== -acorn@^8.4.1, acorn@^8.5.0: +acorn@^8.5.0: version "8.7.1" resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.7.1.tgz#0197122c843d1bf6d0a5e83220a788f278f63c30" integrity sha512-Xx54uLJQZ19lKygFXOWsscKUbsBZW0CPykPhVQdhIeIwrbPmJzqeASDInc8nKBnp/JT6igTs82qPXz069H8I/A== +acorn@^8.7.1: + version "8.8.1" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.8.1.tgz#0a3f9cbecc4ec3bea6f0a80b66ae8dd2da250b73" + integrity sha512-7zFpHzhnqYKrkYdUjF1HI1bzd0VygEGX8lFk4k5zVMqHEoES+P+7TKI+EvLO9WVMJ8eekdO0aDEK044xTXwPPA== + ajv-keywords@^3.5.2: version "3.5.2" resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-3.5.2.tgz#31f29da5ab6e00d1c2d329acf7b5929614d5014d" @@ -598,10 +603,10 @@ engine.io@~6.2.0: engine.io-parser "~5.0.3" ws "~8.2.3" -enhanced-resolve@^5.9.3: - version "5.10.0" - resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.10.0.tgz#0dc579c3bb2a1032e357ac45b8f3a6f3ad4fb1e6" - integrity sha512-T0yTFjdpldGY8PmuXXR0PyQ1ufZpEGiHVrp7zHKB7jdR4qlmZHhONVM5AQOAWXuF/w3dnHbEQVrNptJgt7F+cQ== +enhanced-resolve@^5.10.0: + version "5.12.0" + resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.12.0.tgz#300e1c90228f5b570c4d35babf263f6da7155634" + integrity sha512-QHTXI/sZQmko1cbDoNAa3mJ5qhWUUNAq3vR0/YiD379fWQrcfuoX1+HW2S0MTt7XmoPLapdaDKUtelUSPic7hQ== dependencies: graceful-fs "^4.2.4" tapable "^2.2.0" @@ -1720,7 +1725,7 @@ void-elements@^2.0.0: resolved "https://registry.yarnpkg.com/void-elements/-/void-elements-2.0.1.tgz#c066afb582bb1cb4128d60ea92392e94d5e9dbec" integrity sha1-wGavtYK7HLQSjWDqkjkulNXp2+w= -watchpack@^2.3.1: +watchpack@^2.4.0: version "2.4.0" resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-2.4.0.tgz#fa33032374962c78113f93c7f2fb4c54c9862a5d" integrity sha512-Lcvm7MGST/4fup+ifyKi2hjyIAwcdI4HRgtvTpIUxBRhB+RFtUh8XtDOxUfctVCnhVi+QQj49i91OyvzkJl6cg== @@ -1771,21 +1776,21 @@ webpack-sources@^3.2.3: resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-3.2.3.tgz#2d4daab8451fd4b240cc27055ff6a0c2ccea0cde" integrity sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w== -webpack@5.73.0: - version "5.73.0" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.73.0.tgz#bbd17738f8a53ee5760ea2f59dce7f3431d35d38" - integrity sha512-svjudQRPPa0YiOYa2lM/Gacw0r6PvxptHj4FuEKQ2kX05ZLkjbVc5MnPs6its5j7IZljnIqSVo/OsY2X0IpHGA== +webpack@5.74.0: + version "5.74.0" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.74.0.tgz#02a5dac19a17e0bb47093f2be67c695102a55980" + integrity sha512-A2InDwnhhGN4LYctJj6M1JEaGL7Luj6LOmyBHjcI8529cm5p6VXiTIW2sn6ffvEAKmveLzvu4jrihwXtPojlAA== dependencies: "@types/eslint-scope" "^3.7.3" "@types/estree" "^0.0.51" "@webassemblyjs/ast" "1.11.1" "@webassemblyjs/wasm-edit" "1.11.1" "@webassemblyjs/wasm-parser" "1.11.1" - acorn "^8.4.1" + acorn "^8.7.1" acorn-import-assertions "^1.7.6" browserslist "^4.14.5" chrome-trace-event "^1.0.2" - enhanced-resolve "^5.9.3" + enhanced-resolve "^5.10.0" es-module-lexer "^0.9.0" eslint-scope "5.1.1" events "^3.2.0" @@ -1798,7 +1803,7 @@ webpack@5.73.0: schema-utils "^3.1.0" tapable "^2.1.1" terser-webpack-plugin "^5.1.3" - watchpack "^2.3.1" + watchpack "^2.4.0" webpack-sources "^3.2.3" whatwg-url@^7.0.0: From affa11d007194d2be01c0a6f5cdd17d428ac345c Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Fri, 30 Dec 2022 23:01:27 +0800 Subject: [PATCH 30/59] Use `com.huanshankeji.team:gradle-plugins:0.4.0-SNAPSHOT` and bump to `com.huanshankeji:common-gradle-dependencies:0.3.3-20221230-SNAPSHOT` --- buildSrc/build.gradle.kts | 4 ++-- buildSrc/src/main/kotlin/multiplatform-conventions.gradle.kts | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index e577198..5417c8f 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -16,6 +16,6 @@ repositories { dependencies { implementation(kotlin("gradle-plugin", "1.8.0")) - implementation("com.huanshankeji:common-gradle-dependencies:0.3.2-20220728") - implementation("com.huanshankeji.team:gradle-plugins:0.3.2") + implementation("com.huanshankeji:common-gradle-dependencies:0.3.3-20221230-SNAPSHOT") // TODO: don't use a snapshot version in a main branch + implementation("com.huanshankeji.team:gradle-plugins:0.4.0-SNAPSHOT") // TODO: don't use a snapshot version in a main branch } diff --git a/buildSrc/src/main/kotlin/multiplatform-conventions.gradle.kts b/buildSrc/src/main/kotlin/multiplatform-conventions.gradle.kts index 4cd74ed..e94bc49 100644 --- a/buildSrc/src/main/kotlin/multiplatform-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/multiplatform-conventions.gradle.kts @@ -1,5 +1,6 @@ plugins { id("common-conventions-before") - id("com.huanshankeji.kotlin-multiplatform-jvm-and-js-browser-sonatype-ossrh-publish-conventions") + id("com.huanshankeji.kotlin-multiplatform-sonatype-ossrh-publish-conventions") + id("com.huanshankeji.kotlin-multiplatform-jvm-and-js-browser-conventions") id("common-conventions-after") } From 3137f09544d744e49a05ce952e5edad0a5b85568 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Mon, 16 Jan 2023 21:08:57 +0800 Subject: [PATCH 31/59] Adapt to the latest snapshot version of "com.huanshankeji.team:gradle-plugins:0.4.0-SNAPSHOT" and set `java.toolchain.languageVersion` --- buildSrc/src/main/kotlin/jvm-conventions.gradle.kts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/buildSrc/src/main/kotlin/jvm-conventions.gradle.kts b/buildSrc/src/main/kotlin/jvm-conventions.gradle.kts index 1562049..afde798 100644 --- a/buildSrc/src/main/kotlin/jvm-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/jvm-conventions.gradle.kts @@ -3,3 +3,5 @@ plugins { id("com.huanshankeji.kotlin-jvm-library-sonatype-ossrh-publish-conventions") id("common-conventions-after") } + +java.toolchain.languageVersion.set(JavaLanguageVersion.of(8)) From 15a52f2ac26a5dc2183272550bc99354263721aa Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Sat, 21 Jan 2023 00:12:23 +0800 Subject: [PATCH 32/59] Add the Kotlin version badge --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index d47c896..ebbb984 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # Huanshankeji Kotlin Common [![Maven Central](https://img.shields.io/maven-central/v/com.huanshankeji/kotlin-common-core)](https://search.maven.org/search?q=g:com.huanshankeji%20a:kotlin-common-*) +![Kotlin version](https://kotlin-version.aws.icerock.dev/kotlin-version?group=com.huanshankeji&name=kotlin-common-core) Huanshankeji's common code libraries in Kotlin From 6e1bbcbfe13c170036057042775b6a89f1079cc9 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Fri, 10 Feb 2023 20:06:55 +0800 Subject: [PATCH 33/59] Add the `Dispatchers.Unconfined` argument to Coroutine `launch`s in `Route.handler`s to reduce the context switching overhead For detailed benchmark results, check out and run the Plaintext test with or without `Dispatchers.Unconfined`. --- .../huanshankeji/vertx/kotlin/coroutines/VertxCoroutine.kt | 2 +- .../vertx/kotlin/coroutines/ext/web/CoroutineHandlers.kt | 3 ++- .../coroutines/ext/web/ExtendedWebCoroutineVerticle.kt | 5 +++-- .../vertx/kotlin/coroutines/ext/web/CoroutineHandlers.kt | 3 ++- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/vertx/src/main/kotlin/com/huanshankeji/vertx/kotlin/coroutines/VertxCoroutine.kt b/vertx/src/main/kotlin/com/huanshankeji/vertx/kotlin/coroutines/VertxCoroutine.kt index de6aa31..a373e43 100644 --- a/vertx/src/main/kotlin/com/huanshankeji/vertx/kotlin/coroutines/VertxCoroutine.kt +++ b/vertx/src/main/kotlin/com/huanshankeji/vertx/kotlin/coroutines/VertxCoroutine.kt @@ -39,7 +39,7 @@ suspend fun Vertx.awaitExecuteBlocking(blockingCode: () -> T): T = @Deprecated("This implementation is buggy. See https://github.com/vert-x3/vertx-lang-kotlin/pull/222/commits/fc3c5c5cc0c572eaddb3c2c37d07c696f75b4443#diff-162b76dc534138518a237d9a8ed527f1b3ecaca67385ea7d4357b6eff203f699R138-R217 for a fixed proposed version.") suspend fun Vertx.awaitSuspendExecuteBlocking(blockingCode: suspend () -> T): T = coroutineScope { - executeBlocking { + executeBlocking { launch { it.complete(blockingCode()) } }.await() } diff --git a/vertx/src/main/kotlin/com/huanshankeji/vertx/kotlin/coroutines/ext/web/CoroutineHandlers.kt b/vertx/src/main/kotlin/com/huanshankeji/vertx/kotlin/coroutines/ext/web/CoroutineHandlers.kt index d9c5b07..93d1159 100644 --- a/vertx/src/main/kotlin/com/huanshankeji/vertx/kotlin/coroutines/ext/web/CoroutineHandlers.kt +++ b/vertx/src/main/kotlin/com/huanshankeji/vertx/kotlin/coroutines/ext/web/CoroutineHandlers.kt @@ -4,6 +4,7 @@ import com.huanshankeji.vertx.ext.web.checkedRun import io.vertx.ext.web.Route import io.vertx.ext.web.RoutingContext import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch // workaround for context receivers @@ -11,7 +12,7 @@ fun coroutineHandler( coroutineScope: CoroutineScope, route: Route, requestHandler: suspend (RoutingContext) -> Unit ): Route = - route.handler { coroutineScope.launch { requestHandler(it) } } + route.handler { coroutineScope.launch(Dispatchers.Unconfined) { requestHandler(it) } } // workaround for context receivers fun checkedCoroutineHandler( diff --git a/vertx/src/main/kotlin/com/huanshankeji/vertx/kotlin/coroutines/ext/web/ExtendedWebCoroutineVerticle.kt b/vertx/src/main/kotlin/com/huanshankeji/vertx/kotlin/coroutines/ext/web/ExtendedWebCoroutineVerticle.kt index d890ad0..e1dd7a6 100644 --- a/vertx/src/main/kotlin/com/huanshankeji/vertx/kotlin/coroutines/ext/web/ExtendedWebCoroutineVerticle.kt +++ b/vertx/src/main/kotlin/com/huanshankeji/vertx/kotlin/coroutines/ext/web/ExtendedWebCoroutineVerticle.kt @@ -5,6 +5,7 @@ import com.huanshankeji.vertx.kotlin.coroutines.CoroutineVerticleI import io.vertx.ext.web.Route import io.vertx.ext.web.RoutingContext import io.vertx.kotlin.coroutines.CoroutineVerticle +import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch interface ExtendedWebCoroutineVerticleI : CoroutineVerticleI { @@ -12,7 +13,7 @@ interface ExtendedWebCoroutineVerticleI : CoroutineVerticleI { * Like [Route.handler] but with a suspend function as [requestHandler]. */ fun Route.coroutineHandler(requestHandler: suspend (RoutingContext) -> Unit): Route = - handler { launch { requestHandler(it) } } + handler { launch(Dispatchers.Unconfined) { requestHandler(it) } } /** * Like [coroutineHandler] and calls [RoutingContext.fail] if a [Throwable] is thrown in [requestHandler]. @@ -27,7 +28,7 @@ abstract class ExtendedWebCoroutineVerticle : CoroutineVerticle(), ExtendedWebCo * which might be slightly faster but can also make the stack trace difficult to debug. */ inline fun Route.coroutineHandlerInline(crossinline requestHandler: suspend (RoutingContext) -> Unit): Route = - handler { launch { requestHandler(it) } } + handler { launch(Dispatchers.Unconfined) { requestHandler(it) } } /** * The inline version of [checkedCoroutineHandler], diff --git a/vertx/with-context-receivers/src/main/kotlin/com/huanshankeji/vertx/kotlin/coroutines/ext/web/CoroutineHandlers.kt b/vertx/with-context-receivers/src/main/kotlin/com/huanshankeji/vertx/kotlin/coroutines/ext/web/CoroutineHandlers.kt index 5ae1586..1ac8581 100644 --- a/vertx/with-context-receivers/src/main/kotlin/com/huanshankeji/vertx/kotlin/coroutines/ext/web/CoroutineHandlers.kt +++ b/vertx/with-context-receivers/src/main/kotlin/com/huanshankeji/vertx/kotlin/coroutines/ext/web/CoroutineHandlers.kt @@ -4,6 +4,7 @@ import com.huanshankeji.vertx.ext.web.checkedRun import io.vertx.ext.web.Route import io.vertx.ext.web.RoutingContext import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch /** @@ -11,7 +12,7 @@ import kotlinx.coroutines.launch */ context(CoroutineScope, Route) fun coroutineHandler(requestHandler: suspend (RoutingContext) -> Unit): Route = - handler { launch { requestHandler(it) } } + handler { launch(Dispatchers.Unconfined) { requestHandler(it) } } /** * Like [coroutineHandler] and calls [RoutingContext.fail] if a [Throwable] is thrown in [requestHandler]. From 25fa7b2299308b9013bcbd684eb25fc648ef3352 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Sat, 11 Feb 2023 16:25:44 +0800 Subject: [PATCH 34/59] Remove a redundant inferred type parameter --- .../com/huanshankeji/vertx/kotlin/coroutines/VertxCoroutine.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vertx/src/main/kotlin/com/huanshankeji/vertx/kotlin/coroutines/VertxCoroutine.kt b/vertx/src/main/kotlin/com/huanshankeji/vertx/kotlin/coroutines/VertxCoroutine.kt index a373e43..a342c86 100644 --- a/vertx/src/main/kotlin/com/huanshankeji/vertx/kotlin/coroutines/VertxCoroutine.kt +++ b/vertx/src/main/kotlin/com/huanshankeji/vertx/kotlin/coroutines/VertxCoroutine.kt @@ -28,7 +28,7 @@ suspend inline fun Vertx.use(block: (Vertx) -> R): R = * [blockingCode] returns the result when the operation completes instead of calling [Promise.complete]. */ suspend fun Vertx.awaitExecuteBlocking(blockingCode: () -> T): T = - executeBlocking { + executeBlocking { it.complete(blockingCode()) }.await() From b677b9dee457dded36b3b7f46c4e88e0c0b1e62e Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Mon, 13 Feb 2023 22:42:53 +0800 Subject: [PATCH 35/59] Add the `CoroutineHandlerLaunchMode` argument in coroutine handler functions and add tests for it --- .../coroutines/ext/web/CoroutineHandlers.kt | 59 +++++++++++++++++-- .../ext/web/ExtendedWebCoroutineVerticle.kt | 20 +++++-- .../ext/web/CoroutineHandlersTest.kt | 54 +++++++++++++++++ .../web/ExtendedWebCoroutineVerticleTest.kt | 16 ++--- 4 files changed, 130 insertions(+), 19 deletions(-) create mode 100644 vertx/src/test/kotlin/com/huanshankeji/vertx/kotlin/coroutines/ext/web/CoroutineHandlersTest.kt diff --git a/vertx/src/main/kotlin/com/huanshankeji/vertx/kotlin/coroutines/ext/web/CoroutineHandlers.kt b/vertx/src/main/kotlin/com/huanshankeji/vertx/kotlin/coroutines/ext/web/CoroutineHandlers.kt index 93d1159..3cb2dac 100644 --- a/vertx/src/main/kotlin/com/huanshankeji/vertx/kotlin/coroutines/ext/web/CoroutineHandlers.kt +++ b/vertx/src/main/kotlin/com/huanshankeji/vertx/kotlin/coroutines/ext/web/CoroutineHandlers.kt @@ -1,22 +1,71 @@ package com.huanshankeji.vertx.kotlin.coroutines.ext.web import com.huanshankeji.vertx.ext.web.checkedRun +import com.huanshankeji.vertx.kotlin.coroutines.ext.web.CoroutineHandlerLaunchMode.DefaultOnVertxEventLoop +import com.huanshankeji.vertx.kotlin.coroutines.ext.web.CoroutineHandlerLaunchMode.Unconfined import io.vertx.ext.web.Route import io.vertx.ext.web.RoutingContext -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.launch +import io.vertx.kotlin.coroutines.CoroutineVerticle +import kotlinx.coroutines.* +import kotlin.coroutines.CoroutineContext +import kotlin.coroutines.EmptyCoroutineContext + +private fun coroutineHandler( + coroutineScope: CoroutineScope, route: Route, + context: CoroutineContext, start: CoroutineStart, + requestHandler: suspend (RoutingContext) -> Unit +): Route = + route.handler { coroutineScope.launch(context, start) { requestHandler(it) } } + +/** + * @see CoroutineContext + * @see Dispatchers + * @see CoroutineStart + */ +enum class CoroutineHandlerLaunchMode { + /** + * In this mode, the coroutine is launched in a [CoroutineScope] probably with a [CoroutineDispatcher] + * (such as a [CoroutineVerticle]) + * with the arguments [EmptyCoroutineContext] and [CoroutineStart.UNDISPATCHED]. + * After calling a suspending function that doesn't resume on the Vert.x event loop by default + * (especially and mainly non-Vert.x functions, such as [delay]), + * the coroutine is redispatched to the Vert.x event loop. + */ + DefaultOnVertxEventLoop, + + /** + * In this mode, the coroutine is launched with the argument [Dispatchers.Unconfined]. + * After calling a suspending function that doesn't resume on the Vert.x event loop by default, + * the coroutine is not redispatched to the Vert.x event loop. + * + * It reduces the context (thread) switching overhead and provides slightly better performance in cases when handler code is light. + * It's recommend when all the suspending functions called in the handler are Vert.x functions. + * + * As tested with the vertx-web-kotlinx portion of TechEmpower Framework Benchmarks, [Dispatchers.Unconfined] greatly improves the performance of the Plaintext test. + * See for more details. + */ + Unconfined +} // workaround for context receivers fun coroutineHandler( coroutineScope: CoroutineScope, route: Route, + launchMode: CoroutineHandlerLaunchMode = DefaultOnVertxEventLoop, requestHandler: suspend (RoutingContext) -> Unit ): Route = - route.handler { coroutineScope.launch(Dispatchers.Unconfined) { requestHandler(it) } } + coroutineHandler( + coroutineScope, route, + when (launchMode) { + DefaultOnVertxEventLoop -> EmptyCoroutineContext + Unconfined -> Dispatchers.Unconfined + }, + CoroutineStart.UNDISPATCHED, requestHandler + ) // workaround for context receivers fun checkedCoroutineHandler( coroutineScope: CoroutineScope, route: Route, + launchMode: CoroutineHandlerLaunchMode = DefaultOnVertxEventLoop, requestHandler: suspend (RoutingContext) -> Unit ): Route = - coroutineHandler(coroutineScope, route) { ctx -> ctx.checkedRun { requestHandler(ctx) } } + coroutineHandler(coroutineScope, route, launchMode) { ctx -> ctx.checkedRun { requestHandler(ctx) } } diff --git a/vertx/src/main/kotlin/com/huanshankeji/vertx/kotlin/coroutines/ext/web/ExtendedWebCoroutineVerticle.kt b/vertx/src/main/kotlin/com/huanshankeji/vertx/kotlin/coroutines/ext/web/ExtendedWebCoroutineVerticle.kt index e1dd7a6..ecfa171 100644 --- a/vertx/src/main/kotlin/com/huanshankeji/vertx/kotlin/coroutines/ext/web/ExtendedWebCoroutineVerticle.kt +++ b/vertx/src/main/kotlin/com/huanshankeji/vertx/kotlin/coroutines/ext/web/ExtendedWebCoroutineVerticle.kt @@ -2,33 +2,41 @@ package com.huanshankeji.vertx.kotlin.coroutines.ext.web import com.huanshankeji.vertx.ext.web.checkedRun import com.huanshankeji.vertx.kotlin.coroutines.CoroutineVerticleI +import com.huanshankeji.vertx.kotlin.coroutines.ext.web.CoroutineHandlerLaunchMode.DefaultOnVertxEventLoop import io.vertx.ext.web.Route import io.vertx.ext.web.RoutingContext import io.vertx.kotlin.coroutines.CoroutineVerticle -import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch interface ExtendedWebCoroutineVerticleI : CoroutineVerticleI { /** * Like [Route.handler] but with a suspend function as [requestHandler]. */ - fun Route.coroutineHandler(requestHandler: suspend (RoutingContext) -> Unit): Route = - handler { launch(Dispatchers.Unconfined) { requestHandler(it) } } + fun Route.coroutineHandler( + launchMode: CoroutineHandlerLaunchMode = DefaultOnVertxEventLoop, + requestHandler: suspend (RoutingContext) -> Unit + ): Route = + coroutineHandler(this@ExtendedWebCoroutineVerticleI, this, launchMode, requestHandler) /** * Like [coroutineHandler] and calls [RoutingContext.fail] if a [Throwable] is thrown in [requestHandler]. */ - fun Route.checkedCoroutineHandler(requestHandler: suspend (RoutingContext) -> Unit): Route = - coroutineHandler { ctx -> ctx.checkedRun { requestHandler(ctx) } } + fun Route.checkedCoroutineHandler( + launchMode: CoroutineHandlerLaunchMode = DefaultOnVertxEventLoop, + requestHandler: suspend (RoutingContext) -> Unit + ): Route = + checkedCoroutineHandler(this@ExtendedWebCoroutineVerticleI, this, launchMode, requestHandler) } abstract class ExtendedWebCoroutineVerticle : CoroutineVerticle(), ExtendedWebCoroutineVerticleI { + // TODO: `launchMode: CoroutineHandlerLaunchMode` is not supported in these inline versions yet + /** * The inline version of [coroutineHandler], * which might be slightly faster but can also make the stack trace difficult to debug. */ inline fun Route.coroutineHandlerInline(crossinline requestHandler: suspend (RoutingContext) -> Unit): Route = - handler { launch(Dispatchers.Unconfined) { requestHandler(it) } } + handler { launch { requestHandler(it) } } /** * The inline version of [checkedCoroutineHandler], diff --git a/vertx/src/test/kotlin/com/huanshankeji/vertx/kotlin/coroutines/ext/web/CoroutineHandlersTest.kt b/vertx/src/test/kotlin/com/huanshankeji/vertx/kotlin/coroutines/ext/web/CoroutineHandlersTest.kt new file mode 100644 index 0000000..258d0f5 --- /dev/null +++ b/vertx/src/test/kotlin/com/huanshankeji/vertx/kotlin/coroutines/ext/web/CoroutineHandlersTest.kt @@ -0,0 +1,54 @@ +package com.huanshankeji.vertx.kotlin.coroutines.ext.web + +import com.huanshankeji.kotlin.use +import com.huanshankeji.vertx.VertxBaseTest +import com.huanshankeji.vertx.kotlin.coroutines.ext.web.CoroutineHandlerLaunchMode.DefaultOnVertxEventLoop +import com.huanshankeji.vertx.kotlin.coroutines.ext.web.CoroutineHandlerLaunchMode.Unconfined +import io.vertx.ext.web.Router +import io.vertx.ext.web.client.WebClient +import io.vertx.kotlin.coroutines.await +import io.vertx.kotlin.coroutines.dispatcher +import io.vertx.kotlin.ext.web.client.webClientOptionsOf +import kotlinx.coroutines.delay +import kotlinx.coroutines.test.runTest +import kotlinx.coroutines.withContext +import kotlin.test.Test + +class CoroutineHandlersTest : VertxBaseTest() { + companion object { + val DEFAULT_PATH = "/default" + val UNCONFINED_PATH = "/unconfined" + } + + @Test + fun `test checkedCoroutineHandler`() = runTest { + val vertx = vertx + withContext(vertx.dispatcher()) { + val httpServer = vertx.createHttpServer().requestHandler(Router.router(vertx).apply { + fun isOnVertxEventLoop() = + Thread.currentThread().name.contains("vert.x-eventloop-thread-") + + fun isOnDefaultExecutor() = + Thread.currentThread().name.contains("kotlinx.coroutines.DefaultExecutor") + + coroutineHandler(this@withContext, get(DEFAULT_PATH), DefaultOnVertxEventLoop) { + assert(isOnVertxEventLoop()) + delay(1) + assert(isOnVertxEventLoop()) + it.response().end() + } + coroutineHandler(this@withContext, get(UNCONFINED_PATH), Unconfined) { + assert(isOnVertxEventLoop()) + delay(1) + assert(isOnDefaultExecutor()) + it.response().end() + } + }).listen(0).await() + + WebClient.create(vertx, webClientOptionsOf(defaultPort = httpServer.actualPort())).use({ webClient -> + webClient.get(DEFAULT_PATH).send().await() + webClient.get(UNCONFINED_PATH).send().await() + }, { close().await() }) + } + } +} \ No newline at end of file diff --git a/vertx/src/test/kotlin/com/huanshankeji/vertx/kotlin/coroutines/ext/web/ExtendedWebCoroutineVerticleTest.kt b/vertx/src/test/kotlin/com/huanshankeji/vertx/kotlin/coroutines/ext/web/ExtendedWebCoroutineVerticleTest.kt index c7912e7..8233fd4 100644 --- a/vertx/src/test/kotlin/com/huanshankeji/vertx/kotlin/coroutines/ext/web/ExtendedWebCoroutineVerticleTest.kt +++ b/vertx/src/test/kotlin/com/huanshankeji/vertx/kotlin/coroutines/ext/web/ExtendedWebCoroutineVerticleTest.kt @@ -14,7 +14,7 @@ import kotlin.test.assertEquals class ExtendedWebCoroutineVerticleTest : VertxBaseTest() { companion object { - object MethodNames { + object MemberFunctionNames { const val coroutineHandler = "coroutineHandler" const val coroutineHandlerInline = "coroutineHandlerInline" const val checkedCoroutineHandler = "checkedCoroutineHandler" @@ -34,11 +34,11 @@ class ExtendedWebCoroutineVerticleTest : VertxBaseTest() { it.end() } - with(MethodNames) { - get("/$coroutineHandler").coroutineHandler(handler) - get("/$coroutineHandlerInline").coroutineHandlerInline(handler) - get("/$checkedCoroutineHandler").checkedCoroutineHandler(handler) - get("/$checkedCoroutineHandlerInline").checkedCoroutineHandlerInline(handler) + with(MemberFunctionNames) { + get("/$coroutineHandler").coroutineHandler(requestHandler = handler) + get("/$coroutineHandlerInline").coroutineHandlerInline(requestHandler = handler) + get("/$checkedCoroutineHandler").checkedCoroutineHandler(requestHandler = handler) + get("/$checkedCoroutineHandlerInline").checkedCoroutineHandlerInline(requestHandler = handler) } }) .listen(0).await() @@ -64,12 +64,12 @@ class ExtendedWebCoroutineVerticleTest : VertxBaseTest() { assertEquals(500, webClient.get("/$methodName?throws=true").send().await().statusCode()) } - with(MethodNames) { + with(MemberFunctionNames) { listOf(coroutineHandler, coroutineHandlerInline, checkedCoroutineHandler, checkedCoroutineHandlerInline) .forEach { testOk(it) } listOf(checkedCoroutineHandler, checkedCoroutineHandlerInline).forEach { testThrowable(it) } } - }, { close() }) + }, { close().await() }) vertx.undeploy(deploymentId).await() } From 98a062faf251c0ba52715f695c29ce8fc94ffe76 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Tue, 21 Feb 2023 22:59:40 +0800 Subject: [PATCH 36/59] Add `sort*AndExecuteBatch` functions for `PreparedQuery`, an `Untested` opt-in requirement annotation, and a related `LexicographicOrderListComparable` class and its tests --- .../kotlin/com/huanshankeji/Untested.kt | 20 ++++++++++ .../LexicographicOrderListComparable.kt | 27 +++++++++++++ .../LexicographicOrderListComparableTest.kt | 26 ++++++++++++ .../sqlclient/PreparedQueryBatchExecution.kt | 40 +++++++++++++++++++ 4 files changed, 113 insertions(+) create mode 100644 core/src/commonMain/kotlin/com/huanshankeji/Untested.kt create mode 100644 core/src/commonMain/kotlin/com/huanshankeji/collections/LexicographicOrderListComparable.kt create mode 100644 core/src/commonTest/kotlin/com/huanshankeji/collections/LexicographicOrderListComparableTest.kt create mode 100644 vertx/src/main/kotlin/com/huanshankeji/vertx/sqlclient/PreparedQueryBatchExecution.kt diff --git a/core/src/commonMain/kotlin/com/huanshankeji/Untested.kt b/core/src/commonMain/kotlin/com/huanshankeji/Untested.kt new file mode 100644 index 0000000..4874f85 --- /dev/null +++ b/core/src/commonMain/kotlin/com/huanshankeji/Untested.kt @@ -0,0 +1,20 @@ +package com.huanshankeji + +import kotlin.annotation.AnnotationTarget.* + +@RequiresOptIn("This API is untested.", RequiresOptIn.Level.WARNING) +@Retention(AnnotationRetention.BINARY) +// The ones commented out are what I think may be used in very few use cases. +@Target( + CLASS, + //ANNOTATION_CLASS, + PROPERTY, + //FIELD, + //VALUE_PARAMETER, + CONSTRUCTOR, + FUNCTION, + PROPERTY_GETTER, + PROPERTY_SETTER, + //TYPEALIAS +) +annotation class Untested \ No newline at end of file diff --git a/core/src/commonMain/kotlin/com/huanshankeji/collections/LexicographicOrderListComparable.kt b/core/src/commonMain/kotlin/com/huanshankeji/collections/LexicographicOrderListComparable.kt new file mode 100644 index 0000000..8d0c73c --- /dev/null +++ b/core/src/commonMain/kotlin/com/huanshankeji/collections/LexicographicOrderListComparable.kt @@ -0,0 +1,27 @@ +package com.huanshankeji.collections + +class LexicographicOrderListComparable> internal constructor(val list: List) : + Comparable> { + override fun compareTo(other: LexicographicOrderListComparable): Int { + val otherList = other.list + tailrec fun helper(index: Int): Int { + val a = list.getOrNull(index) + val b = otherList.getOrNull(index) + return if (a === null) + if (b === null) 0 + else -1 + else + if (b === null) 1 + else { + val elementCompareResult = a.compareTo(b) + if (elementCompareResult != 0) elementCompareResult + else helper(index + 1) + } + } + + return helper(0) + } +} + +fun > List.lexicographicOrderComparable() = + LexicographicOrderListComparable(this) diff --git a/core/src/commonTest/kotlin/com/huanshankeji/collections/LexicographicOrderListComparableTest.kt b/core/src/commonTest/kotlin/com/huanshankeji/collections/LexicographicOrderListComparableTest.kt new file mode 100644 index 0000000..e0c59a1 --- /dev/null +++ b/core/src/commonTest/kotlin/com/huanshankeji/collections/LexicographicOrderListComparableTest.kt @@ -0,0 +1,26 @@ +package com.huanshankeji.collections + +import io.kotest.property.Arb +import io.kotest.property.arbitrary.pair +import io.kotest.property.arbitrary.string +import io.kotest.property.checkAll +import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.test.runTest +import kotlin.math.sign +import kotlin.test.Test +import kotlin.test.assertEquals + +class LexicographicOrderListComparableTest { + @Test + @OptIn(ExperimentalCoroutinesApi::class) + fun testLexicographicOrderListComparable() = runTest { + val stringArb = Arb.string() + checkAll(Arb.pair(stringArb, stringArb)) { (a, b) -> + assertEquals( + (a compareTo b).sign, + (a.toCharArray().asList().lexicographicOrderComparable() compareTo + b.toCharArray().asList().lexicographicOrderComparable()).sign + ) + } + } +} \ No newline at end of file diff --git a/vertx/src/main/kotlin/com/huanshankeji/vertx/sqlclient/PreparedQueryBatchExecution.kt b/vertx/src/main/kotlin/com/huanshankeji/vertx/sqlclient/PreparedQueryBatchExecution.kt new file mode 100644 index 0000000..4dbdd18 --- /dev/null +++ b/vertx/src/main/kotlin/com/huanshankeji/vertx/sqlclient/PreparedQueryBatchExecution.kt @@ -0,0 +1,40 @@ +package com.huanshankeji.vertx.sqlclient + +import com.huanshankeji.Untested +import com.huanshankeji.collections.lexicographicOrderComparable +import io.vertx.sqlclient.PreparedQuery +import io.vertx.sqlclient.Tuple + +/** + * There can easily be deadlocks when batch-updating data concurrently in multiple event loops + * if they are overlapped and unsorted. + */ +@Untested +fun > PreparedQuery.sortDataAndExecuteBatch( + dataList: List, selector: (DataT) -> SelectorResultT, toTuple: DataT.() -> Tuple +) = + executeBatch(dataList.sortedBy(selector = selector).map(toTuple)) + + +@Untested +inline fun > PreparedQuery.sortTuplesAndExecuteBatch( + batch: List, crossinline selector: (Tuple) -> SelectorResultT +) = + executeBatch(batch.sortedBy(selector)) + + +@Untested +inline fun > PreparedQuery.sortTuplesAndExecuteBatch( + batch: List, selectorPosition: Int +) = + sortTuplesAndExecuteBatch(batch) { it.get(SelectorResultT::class.java, selectorPosition) } + +@Untested +fun PreparedQuery.sortTuplesAndExecuteBatch( + batch: List, selectorPositions: List +) = + sortTuplesAndExecuteBatch(batch) { tuple -> + val listSelector = selectorPositions.map { i -> tuple.getValue(i) } + @Suppress("UNCHECKED_CAST") + (listSelector as List>).lexicographicOrderComparable() + } From ad58a55f001ea281cc185b46c2979f4e17f4a5df Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Thu, 23 Feb 2023 12:16:22 +0800 Subject: [PATCH 37/59] Update the project version --- buildSrc/src/main/kotlin/VersionsAndDependencies.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/src/main/kotlin/VersionsAndDependencies.kt b/buildSrc/src/main/kotlin/VersionsAndDependencies.kt index cfd5e0b..49b2c3a 100644 --- a/buildSrc/src/main/kotlin/VersionsAndDependencies.kt +++ b/buildSrc/src/main/kotlin/VersionsAndDependencies.kt @@ -2,7 +2,7 @@ import com.huanshankeji.CommonDependencies import com.huanshankeji.CommonGradleClasspathDependencies import com.huanshankeji.CommonVersions -val projectVersion = "0.2.4-SNAPSHOT" +val projectVersion = "0.3.0-SNAPSHOT" val commonVersions = CommonVersions() val commonDependencies = CommonDependencies(commonVersions) From 828ff70e986600ff4e235f360f189a1a7c451d01 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Thu, 23 Feb 2023 12:16:47 +0800 Subject: [PATCH 38/59] Update the project version --- buildSrc/src/main/kotlin/VersionsAndDependencies.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/src/main/kotlin/VersionsAndDependencies.kt b/buildSrc/src/main/kotlin/VersionsAndDependencies.kt index cfd5e0b..49b2c3a 100644 --- a/buildSrc/src/main/kotlin/VersionsAndDependencies.kt +++ b/buildSrc/src/main/kotlin/VersionsAndDependencies.kt @@ -2,7 +2,7 @@ import com.huanshankeji.CommonDependencies import com.huanshankeji.CommonGradleClasspathDependencies import com.huanshankeji.CommonVersions -val projectVersion = "0.2.4-SNAPSHOT" +val projectVersion = "0.3.0-SNAPSHOT" val commonVersions = CommonVersions() val commonDependencies = CommonDependencies(commonVersions) From 40da07dece65e08900798b8579dd4356d1513182 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Thu, 23 Feb 2023 12:25:11 +0800 Subject: [PATCH 39/59] Update the project snapshot version to distinguish from other branches --- buildSrc/src/main/kotlin/VersionsAndDependencies.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/src/main/kotlin/VersionsAndDependencies.kt b/buildSrc/src/main/kotlin/VersionsAndDependencies.kt index 49b2c3a..10dc532 100644 --- a/buildSrc/src/main/kotlin/VersionsAndDependencies.kt +++ b/buildSrc/src/main/kotlin/VersionsAndDependencies.kt @@ -2,7 +2,7 @@ import com.huanshankeji.CommonDependencies import com.huanshankeji.CommonGradleClasspathDependencies import com.huanshankeji.CommonVersions -val projectVersion = "0.3.0-SNAPSHOT" +val projectVersion = "0.3.0-generic-exposed-class-property-mapping-SNAPSHOT" val commonVersions = CommonVersions() val commonDependencies = CommonDependencies(commonVersions) From 2325a61ae0b0fc901151da653dc3736bb92268fb Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Fri, 24 Feb 2023 04:19:56 +0800 Subject: [PATCH 40/59] Add a link to a related issue in a comment --- .../exposed/datamapping/classproperty/ClassPropertyMapping.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exposed/src/main/kotlin/com/huanshankeji/exposed/datamapping/classproperty/ClassPropertyMapping.kt b/exposed/src/main/kotlin/com/huanshankeji/exposed/datamapping/classproperty/ClassPropertyMapping.kt index 79cd8bf..c933bad 100644 --- a/exposed/src/main/kotlin/com/huanshankeji/exposed/datamapping/classproperty/ClassPropertyMapping.kt +++ b/exposed/src/main/kotlin/com/huanshankeji/exposed/datamapping/classproperty/ClassPropertyMapping.kt @@ -441,7 +441,7 @@ fun setUpdateBuilder( adt as NestedClass.Adt.Sum with(adt) { if (propertyData !== null) { - // TODO: it seems to be a compiler bug that the non-null assertion is needed here. + // TODO: it seems to be a compiler bug that the non-null assertion is needed here. see: https://youtrack.jetbrains.com/issue/KT-37878/No-Smart-cast-for-class-literal-reference-of-nullable-generic-type. val propertyDataClass = propertyData!!::class with(sumTypeCaseConfig) { updateBuilder[caseValueColumn] = classToCaseValue(propertyDataClass) From 31962a58320b566fabf5e842196608ac3b0c5cb0 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Fri, 24 Feb 2023 07:50:53 +0800 Subject: [PATCH 41/59] Update the Gradle Wrapper to 8.0.1 --- .../main/kotlin/jvm-conventions.gradle.kts | 2 +- .../multiplatform-conventions.gradle.kts | 2 ++ gradle/wrapper/gradle-wrapper.jar | Bin 61574 -> 61608 bytes gradle/wrapper/gradle-wrapper.properties | 2 +- gradlew | 4 ++-- 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/buildSrc/src/main/kotlin/jvm-conventions.gradle.kts b/buildSrc/src/main/kotlin/jvm-conventions.gradle.kts index afde798..accbc57 100644 --- a/buildSrc/src/main/kotlin/jvm-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/jvm-conventions.gradle.kts @@ -4,4 +4,4 @@ plugins { id("common-conventions-after") } -java.toolchain.languageVersion.set(JavaLanguageVersion.of(8)) +kotlin.jvmToolchain(8) diff --git a/buildSrc/src/main/kotlin/multiplatform-conventions.gradle.kts b/buildSrc/src/main/kotlin/multiplatform-conventions.gradle.kts index e94bc49..d74ced8 100644 --- a/buildSrc/src/main/kotlin/multiplatform-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/multiplatform-conventions.gradle.kts @@ -4,3 +4,5 @@ plugins { id("com.huanshankeji.kotlin-multiplatform-jvm-and-js-browser-conventions") id("common-conventions-after") } + +kotlin.jvmToolchain(8) diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 943f0cbfa754578e88a3dae77fce6e3dea56edbf..ccebba7710deaf9f98673a68957ea02138b60d0a 100644 GIT binary patch delta 5094 zcmZu#c|6qH|DG9RA4`noBZNWrC2N)tSqjO%%aX0^O4dPAB*iC6_9R<`apl^#h-_oY z)(k_0v8Fxp{fyi9-uwN%e)GpU&v~BrS>~KG^PF=MNmQjIDr&QHR7f-kM{%U_u*1=5 zGC}ae5(^Rrg9QY8$x^}oiJ0d2O9YW{J~$dD1ovlvh&0B4L)!4S=z;Hac>K{#9q9cKq;>>BtKo1!+gw`yqE zSK8x^jC|B!qmSW#uyb@T^CkB9qRd{N3V-rEi}AEgoU_J27lw_0X`}c0&m9JhxM;RK z54_gdZ(u?R5`B3}NeVal2NTHqlktM`2eTF28%6BZCWW$-shf0l-BOVSm)hU58MTPy zDcY-5777j;ccU!Yba8wH=X6OdPJ8O5Kp^3gUNo>!b=xb6T2F&LiC2eBJj8KuLPW!4 zw3V^NnAKZm^D?tmliCvzi>UtoDH%V#%SM0d*NS+m%4}qO<)M1E{OpQ(v&ZN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apper.properties index 2b22d05..6ec1567 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-all.zip networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 65dcd68..79a61d4 100755 --- a/gradlew +++ b/gradlew @@ -144,7 +144,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac @@ -152,7 +152,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then '' | soft) :;; #( *) # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac From 3d494eca7acae5a98fb8cd8358223fb97f79d2fe Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Fri, 3 Mar 2023 19:11:56 +0800 Subject: [PATCH 42/59] Initially add the `awaitAny` and `joinAny` Coroutine functions --- coroutines/build.gradle.kts | 4 +++- .../huanshankeji/kotlinx/coroutine/Await.kt | 22 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 coroutines/src/commonMain/kotlin/com/huanshankeji/kotlinx/coroutine/Await.kt diff --git a/coroutines/build.gradle.kts b/coroutines/build.gradle.kts index ce375e0..acf52ff 100644 --- a/coroutines/build.gradle.kts +++ b/coroutines/build.gradle.kts @@ -1,12 +1,14 @@ +import com.huanshankeji.cpnProject + plugins { id("multiplatform-conventions") } - kotlin { sourceSets { val commonMain by getting { dependencies { implementation(commonDependencies.kotlinx.coroutines.core()) + implementation(cpnProject(project, ":core")) } } } diff --git a/coroutines/src/commonMain/kotlin/com/huanshankeji/kotlinx/coroutine/Await.kt b/coroutines/src/commonMain/kotlin/com/huanshankeji/kotlinx/coroutine/Await.kt new file mode 100644 index 0000000..a095485 --- /dev/null +++ b/coroutines/src/commonMain/kotlin/com/huanshankeji/kotlinx/coroutine/Await.kt @@ -0,0 +1,22 @@ +package com.huanshankeji.kotlinx.coroutine + +import com.huanshankeji.Untested +import kotlinx.coroutines.Deferred +import kotlinx.coroutines.Job +import kotlinx.coroutines.selects.select + +@Untested +suspend fun awaitAny(vararg deferreds: Deferred): T = + select { deferreds.forEach { it.onAwait { it } } } + +@Untested +suspend fun Collection>.awaitAny(): T = + select { forEach { it.onAwait { it } } } + +@Untested +suspend fun joinAny(vararg jobs: Job): Unit = + select { jobs.forEach { it.onJoin { it } } } + +@Untested +suspend fun Collection.joinAny(): Unit = + select { forEach { it.onJoin { it } } } From e64be88b529c299fdce8f3fb50c0ecc74d0186fa Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Wed, 8 Mar 2023 00:29:35 +0800 Subject: [PATCH 43/59] Add some simple tests for `awaitAny` and `joinAny` --- coroutines/build.gradle.kts | 8 ++- .../kotlinx/coroutine/AwaitTest.kt | 55 +++++++++++++++++++ 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 coroutines/src/commonTest/kotlin/com/huanshankeji/kotlinx/coroutine/AwaitTest.kt diff --git a/coroutines/build.gradle.kts b/coroutines/build.gradle.kts index acf52ff..74e7bc3 100644 --- a/coroutines/build.gradle.kts +++ b/coroutines/build.gradle.kts @@ -5,11 +5,17 @@ plugins { } kotlin { sourceSets { - val commonMain by getting { + commonMain { dependencies { implementation(commonDependencies.kotlinx.coroutines.core()) implementation(cpnProject(project, ":core")) } } + commonTest { + dependencies { + implementation(kotlin("test")) + implementation(commonDependencies.kotlinx.coroutines.test()) + } + } } } diff --git a/coroutines/src/commonTest/kotlin/com/huanshankeji/kotlinx/coroutine/AwaitTest.kt b/coroutines/src/commonTest/kotlin/com/huanshankeji/kotlinx/coroutine/AwaitTest.kt new file mode 100644 index 0000000..b04ca95 --- /dev/null +++ b/coroutines/src/commonTest/kotlin/com/huanshankeji/kotlinx/coroutine/AwaitTest.kt @@ -0,0 +1,55 @@ +package com.huanshankeji.kotlinx.coroutine + +import kotlinx.coroutines.async +import kotlinx.coroutines.launch +import kotlinx.coroutines.sync.Mutex +import kotlinx.coroutines.sync.withLock +import kotlinx.coroutines.test.runTest +import kotlin.test.Test +import kotlin.test.assertEquals + +class AwaitTest { + @Test + fun simplyTestAwaitAnyAndJoinAny() = runTest { + val mutex = Mutex() + mutex.withLock { + fun asyncOf(value: Int) = async { value } + fun asyncSuspendUtilEnd() = async { mutex.withLock { } } + + fun deferredArray0() = arrayOf(asyncOf(0), asyncSuspendUtilEnd()) + fun deferredArray1() = arrayOf(asyncSuspendUtilEnd(), asyncOf(1)) + assertEquals(0, awaitAny(*deferredArray0())) + assertEquals(1, awaitAny(*deferredArray1())) + assertEquals(0, deferredArray0().asList().awaitAny()) + assertEquals(1, deferredArray1().asList().awaitAny()) + + + var value: Int? + + fun launchSetOf(newValue: Int) = launch { value = newValue } + fun launchSuspendUtilEndAndSetOf(newValue: Int) = launch { + mutex.withLock { } + value = newValue + } + + fun jobArray0() = arrayOf(launchSetOf(0), launchSuspendUtilEndAndSetOf(1)) + fun jobArray1() = arrayOf(launchSuspendUtilEndAndSetOf(0), launchSetOf(1)) + + value = null + joinAny(*jobArray0()) + assertEquals(0, value) + + value = null + joinAny(*jobArray1()) + assertEquals(1, value) + + value = null + jobArray0().asList().joinAny() + assertEquals(0, value) + + value = null + jobArray1().asList().joinAny() + assertEquals(1, value) + } + } +} \ No newline at end of file From 919033a8a03d4bfd8bc3045fac5a038e6d0226ea Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Wed, 8 Mar 2023 18:26:40 +0800 Subject: [PATCH 44/59] Remove the `@Untested` annotations as should be done in the previous commit and fix a bug --- .../kotlin/com/huanshankeji/kotlinx/coroutine/Await.kt | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/coroutines/src/commonMain/kotlin/com/huanshankeji/kotlinx/coroutine/Await.kt b/coroutines/src/commonMain/kotlin/com/huanshankeji/kotlinx/coroutine/Await.kt index a095485..2b0bf8a 100644 --- a/coroutines/src/commonMain/kotlin/com/huanshankeji/kotlinx/coroutine/Await.kt +++ b/coroutines/src/commonMain/kotlin/com/huanshankeji/kotlinx/coroutine/Await.kt @@ -1,22 +1,17 @@ package com.huanshankeji.kotlinx.coroutine -import com.huanshankeji.Untested import kotlinx.coroutines.Deferred import kotlinx.coroutines.Job import kotlinx.coroutines.selects.select -@Untested suspend fun awaitAny(vararg deferreds: Deferred): T = select { deferreds.forEach { it.onAwait { it } } } -@Untested suspend fun Collection>.awaitAny(): T = select { forEach { it.onAwait { it } } } -@Untested suspend fun joinAny(vararg jobs: Job): Unit = - select { jobs.forEach { it.onJoin { it } } } + select { jobs.forEach { it.onJoin { } } } -@Untested suspend fun Collection.joinAny(): Unit = - select { forEach { it.onJoin { it } } } + select { forEach { it.onJoin { } } } From b400a6ee025bf03ea2c256c0ecfcc124b6d5305f Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Wed, 8 Mar 2023 18:49:58 +0800 Subject: [PATCH 45/59] Add `awaitAnyAndCancelOthers` and test it --- .../kotlin/com/huanshankeji/kotlinx/coroutine/Await.kt | 7 +++++++ .../com/huanshankeji/kotlinx/coroutine/AwaitTest.kt | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/coroutines/src/commonMain/kotlin/com/huanshankeji/kotlinx/coroutine/Await.kt b/coroutines/src/commonMain/kotlin/com/huanshankeji/kotlinx/coroutine/Await.kt index 2b0bf8a..dae3f9e 100644 --- a/coroutines/src/commonMain/kotlin/com/huanshankeji/kotlinx/coroutine/Await.kt +++ b/coroutines/src/commonMain/kotlin/com/huanshankeji/kotlinx/coroutine/Await.kt @@ -10,6 +10,13 @@ suspend fun awaitAny(vararg deferreds: Deferred): T = suspend fun Collection>.awaitAny(): T = select { forEach { it.onAwait { it } } } +suspend fun Collection>.awaitAnyAndCancelOthers(): T { + val firstAwaited = select { forEachIndexed { index, deferred -> deferred.onAwait { IndexedValue(index, it) } } } + val firstAwaitedIndex = firstAwaited.index + forEachIndexed { index, deferred -> if (index != firstAwaitedIndex) deferred.cancel() } + return firstAwaited.value +} + suspend fun joinAny(vararg jobs: Job): Unit = select { jobs.forEach { it.onJoin { } } } diff --git a/coroutines/src/commonTest/kotlin/com/huanshankeji/kotlinx/coroutine/AwaitTest.kt b/coroutines/src/commonTest/kotlin/com/huanshankeji/kotlinx/coroutine/AwaitTest.kt index b04ca95..b296551 100644 --- a/coroutines/src/commonTest/kotlin/com/huanshankeji/kotlinx/coroutine/AwaitTest.kt +++ b/coroutines/src/commonTest/kotlin/com/huanshankeji/kotlinx/coroutine/AwaitTest.kt @@ -1,5 +1,6 @@ package com.huanshankeji.kotlinx.coroutine +import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.async import kotlinx.coroutines.launch import kotlinx.coroutines.sync.Mutex @@ -7,8 +8,11 @@ import kotlinx.coroutines.sync.withLock import kotlinx.coroutines.test.runTest import kotlin.test.Test import kotlin.test.assertEquals +import kotlin.test.assertFalse +import kotlin.test.assertTrue class AwaitTest { + @OptIn(ExperimentalCoroutinesApi::class) @Test fun simplyTestAwaitAnyAndJoinAny() = runTest { val mutex = Mutex() @@ -24,6 +28,12 @@ class AwaitTest { assertEquals(1, deferredArray1().asList().awaitAny()) + val deffereds = deferredArray0() + assertFalse(deffereds[1].isCancelled) + assertEquals(0, deffereds.asList().awaitAnyAndCancelOthers()) + assertTrue(deffereds[1].isCancelled) + + var value: Int? fun launchSetOf(newValue: Int) = launch { value = newValue } From cae2df3f7f4eed7b2fe3000fb57fb1616175c0b6 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Thu, 9 Mar 2023 17:10:20 +0800 Subject: [PATCH 46/59] Add the non-empty argument requirements to the `awaitAny` and `joinAny` functions and add tests --- .../huanshankeji/kotlinx/coroutine/Await.kt | 21 +++++++++++++------ .../kotlinx/coroutine/AwaitTest.kt | 20 +++++++++++++----- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/coroutines/src/commonMain/kotlin/com/huanshankeji/kotlinx/coroutine/Await.kt b/coroutines/src/commonMain/kotlin/com/huanshankeji/kotlinx/coroutine/Await.kt index dae3f9e..8c4e560 100644 --- a/coroutines/src/commonMain/kotlin/com/huanshankeji/kotlinx/coroutine/Await.kt +++ b/coroutines/src/commonMain/kotlin/com/huanshankeji/kotlinx/coroutine/Await.kt @@ -4,21 +4,30 @@ import kotlinx.coroutines.Deferred import kotlinx.coroutines.Job import kotlinx.coroutines.selects.select -suspend fun awaitAny(vararg deferreds: Deferred): T = - select { deferreds.forEach { it.onAwait { it } } } +suspend fun awaitAny(vararg deferreds: Deferred): T { + require(deferreds.isNotEmpty()) + return select { deferreds.forEach { it.onAwait { it } } } +} -suspend fun Collection>.awaitAny(): T = - select { forEach { it.onAwait { it } } } +suspend fun Collection>.awaitAny(): T { + require(isNotEmpty()) + return select { forEach { it.onAwait { it } } } +} suspend fun Collection>.awaitAnyAndCancelOthers(): T { + require(isNotEmpty()) val firstAwaited = select { forEachIndexed { index, deferred -> deferred.onAwait { IndexedValue(index, it) } } } val firstAwaitedIndex = firstAwaited.index forEachIndexed { index, deferred -> if (index != firstAwaitedIndex) deferred.cancel() } return firstAwaited.value } -suspend fun joinAny(vararg jobs: Job): Unit = +suspend fun joinAny(vararg jobs: Job) { + require(jobs.isNotEmpty()) select { jobs.forEach { it.onJoin { } } } +} -suspend fun Collection.joinAny(): Unit = +suspend fun Collection.joinAny() { + require(isNotEmpty()) select { forEach { it.onJoin { } } } +} diff --git a/coroutines/src/commonTest/kotlin/com/huanshankeji/kotlinx/coroutine/AwaitTest.kt b/coroutines/src/commonTest/kotlin/com/huanshankeji/kotlinx/coroutine/AwaitTest.kt index b296551..6537ec1 100644 --- a/coroutines/src/commonTest/kotlin/com/huanshankeji/kotlinx/coroutine/AwaitTest.kt +++ b/coroutines/src/commonTest/kotlin/com/huanshankeji/kotlinx/coroutine/AwaitTest.kt @@ -6,13 +6,10 @@ import kotlinx.coroutines.launch import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock import kotlinx.coroutines.test.runTest -import kotlin.test.Test -import kotlin.test.assertEquals -import kotlin.test.assertFalse -import kotlin.test.assertTrue +import kotlin.test.* +@OptIn(ExperimentalCoroutinesApi::class) class AwaitTest { - @OptIn(ExperimentalCoroutinesApi::class) @Test fun simplyTestAwaitAnyAndJoinAny() = runTest { val mutex = Mutex() @@ -62,4 +59,17 @@ class AwaitTest { assertEquals(1, value) } } + + private inline fun assertFailsWithIae(block: () -> Unit) = + assertFailsWith(block = block) + + @Test + fun simplyTestAwaitAnyAndJoinAnyWithNoTarget() = runTest { + val emptyList = emptyList() + assertFailsWithIae { awaitAny() } + assertFailsWithIae { emptyList.awaitAny() } + assertFailsWithIae { emptyList.awaitAnyAndCancelOthers() } + assertFailsWithIae { joinAny() } + assertFailsWithIae { emptyList.joinAny() } + } } \ No newline at end of file From 86d040301965b71b391f3691f3b2bbf3815fafd0 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Sun, 12 Mar 2023 19:23:07 +0800 Subject: [PATCH 47/59] Upgrade the Huanshankeji Gradle build dependencies to the latest release versions --- buildSrc/build.gradle.kts | 6 +++--- .../src/main/kotlin/multiplatform-conventions.gradle.kts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 5417c8f..859345b 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -15,7 +15,7 @@ repositories { } dependencies { - implementation(kotlin("gradle-plugin", "1.8.0")) - implementation("com.huanshankeji:common-gradle-dependencies:0.3.3-20221230-SNAPSHOT") // TODO: don't use a snapshot version in a main branch - implementation("com.huanshankeji.team:gradle-plugins:0.4.0-SNAPSHOT") // TODO: don't use a snapshot version in a main branch + implementation(kotlin("gradle-plugin", "1.8.10")) + implementation("com.huanshankeji:common-gradle-dependencies:0.5.0-20230310") + implementation("com.huanshankeji.team:gradle-plugins:0.4.0") } diff --git a/buildSrc/src/main/kotlin/multiplatform-conventions.gradle.kts b/buildSrc/src/main/kotlin/multiplatform-conventions.gradle.kts index d74ced8..b8a929c 100644 --- a/buildSrc/src/main/kotlin/multiplatform-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/multiplatform-conventions.gradle.kts @@ -1,7 +1,7 @@ plugins { id("common-conventions-before") - id("com.huanshankeji.kotlin-multiplatform-sonatype-ossrh-publish-conventions") id("com.huanshankeji.kotlin-multiplatform-jvm-and-js-browser-conventions") + id("com.huanshankeji.kotlin-multiplatform-sonatype-ossrh-publish-conventions") id("common-conventions-after") } From 6e70fa37884447cfb992212df7d57e6098684216 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Mon, 13 Mar 2023 18:21:54 +0800 Subject: [PATCH 48/59] Move `ProtoBufSerializationTest` here from an internal project --- serialization/build.gradle.kts | 8 ++++++- .../protobuf/ProtoBufSerializationTest.kt | 23 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 serialization/src/commonTest/kotlin/com/huanshankeji/kotlinx/serialization/protobuf/ProtoBufSerializationTest.kt diff --git a/serialization/build.gradle.kts b/serialization/build.gradle.kts index 60b6f20..c1f0871 100644 --- a/serialization/build.gradle.kts +++ b/serialization/build.gradle.kts @@ -5,7 +5,7 @@ plugins { kotlin { sourceSets { - val commonMain by getting { + commonMain { dependencies { with(commonDependencies.kotlinx.serialization) { implementation(core()) @@ -13,5 +13,11 @@ kotlin { } } } + + commonTest { + dependencies { + implementation(kotlin("test")) + } + } } } diff --git a/serialization/src/commonTest/kotlin/com/huanshankeji/kotlinx/serialization/protobuf/ProtoBufSerializationTest.kt b/serialization/src/commonTest/kotlin/com/huanshankeji/kotlinx/serialization/protobuf/ProtoBufSerializationTest.kt new file mode 100644 index 0000000..56d37cc --- /dev/null +++ b/serialization/src/commonTest/kotlin/com/huanshankeji/kotlinx/serialization/protobuf/ProtoBufSerializationTest.kt @@ -0,0 +1,23 @@ +package com.huanshankeji.kotlinx.serialization.protobuf + +import kotlinx.serialization.ExperimentalSerializationApi +import kotlinx.serialization.Serializable +import kotlinx.serialization.protobuf.ProtoBuf +import kotlinx.serialization.protobuf.ProtoNumber +import kotlin.test.Test +import kotlin.test.assertContentEquals +import kotlin.test.assertEquals + +@OptIn(ExperimentalStdlibApi::class, ExperimentalSerializationApi::class) +class ProtoBufSerializationTest { + @Serializable + data class TestData(@ProtoNumber(1) val field: T?) + + @Test + fun testNothingField() { + val testData = TestData(null) + val encoded = ProtoBuf.encodeToByteArrayNothingWorkaround(testData) + assertContentEquals(ByteArray(0), encoded) + assertEquals(testData, ProtoBuf.decodeFromByteArrayNothingWorkaround(encoded)) + } +} \ No newline at end of file From 4b919c72e5dc761a77bb2f98a282827d7ba5b62b Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Thu, 16 Mar 2023 18:34:15 +0800 Subject: [PATCH 49/59] Remove a redundant usage of a named argument --- .../huanshankeji/vertx/sqlclient/PreparedQueryBatchExecution.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vertx/src/main/kotlin/com/huanshankeji/vertx/sqlclient/PreparedQueryBatchExecution.kt b/vertx/src/main/kotlin/com/huanshankeji/vertx/sqlclient/PreparedQueryBatchExecution.kt index 4dbdd18..7ac2d88 100644 --- a/vertx/src/main/kotlin/com/huanshankeji/vertx/sqlclient/PreparedQueryBatchExecution.kt +++ b/vertx/src/main/kotlin/com/huanshankeji/vertx/sqlclient/PreparedQueryBatchExecution.kt @@ -13,7 +13,7 @@ import io.vertx.sqlclient.Tuple fun > PreparedQuery.sortDataAndExecuteBatch( dataList: List, selector: (DataT) -> SelectorResultT, toTuple: DataT.() -> Tuple ) = - executeBatch(dataList.sortedBy(selector = selector).map(toTuple)) + executeBatch(dataList.sortedBy(selector).map(toTuple)) @Untested From d3cee5e8f33cb96f82dc61bc62e6eb8337cdf296 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Sat, 18 Mar 2023 02:52:34 +0800 Subject: [PATCH 50/59] Add `BatchSqlResult.kt` to read multiple `SqlResult`s/`RowSet`s of query batch execution results --- .../vertx/sqlclient/BatchSqlResult.kt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 vertx/src/main/kotlin/com/huanshankeji/vertx/sqlclient/BatchSqlResult.kt diff --git a/vertx/src/main/kotlin/com/huanshankeji/vertx/sqlclient/BatchSqlResult.kt b/vertx/src/main/kotlin/com/huanshankeji/vertx/sqlclient/BatchSqlResult.kt new file mode 100644 index 0000000..a4c0d58 --- /dev/null +++ b/vertx/src/main/kotlin/com/huanshankeji/vertx/sqlclient/BatchSqlResult.kt @@ -0,0 +1,19 @@ +package com.huanshankeji.vertx.sqlclient + +import io.vertx.sqlclient.RowSet +import io.vertx.sqlclient.SqlResult + +fun > SqlResultT.batchSqlResultSequence(): Sequence = sequence { + var currentSqlResult: SqlResultT? = this@batchSqlResultSequence + + while (currentSqlResult !== null) { + yield(currentSqlResult) + currentSqlResult = currentSqlResult.next() as SqlResultT? + } +} + +fun SqlResult<*>.batchSqlResultRowCountSequence() = + batchSqlResultSequence().map { it.rowCount() } + +fun RowSet.batchSqlResultRowSequence() = + batchSqlResultSequence().map { asSequence() } From 0a05c2b44c63f449d19f81ddf94785c4ce80a4bd Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Sat, 18 Mar 2023 11:46:47 +0800 Subject: [PATCH 51/59] Simplify `batchSqlResultSequence` with `generateSequence` --- .../huanshankeji/vertx/sqlclient/BatchSqlResult.kt | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/vertx/src/main/kotlin/com/huanshankeji/vertx/sqlclient/BatchSqlResult.kt b/vertx/src/main/kotlin/com/huanshankeji/vertx/sqlclient/BatchSqlResult.kt index a4c0d58..dc95331 100644 --- a/vertx/src/main/kotlin/com/huanshankeji/vertx/sqlclient/BatchSqlResult.kt +++ b/vertx/src/main/kotlin/com/huanshankeji/vertx/sqlclient/BatchSqlResult.kt @@ -3,14 +3,11 @@ package com.huanshankeji.vertx.sqlclient import io.vertx.sqlclient.RowSet import io.vertx.sqlclient.SqlResult -fun > SqlResultT.batchSqlResultSequence(): Sequence = sequence { - var currentSqlResult: SqlResultT? = this@batchSqlResultSequence - - while (currentSqlResult !== null) { - yield(currentSqlResult) - currentSqlResult = currentSqlResult.next() as SqlResultT? +fun > SqlResultT.batchSqlResultSequence(): Sequence = + generateSequence(this) { + @Suppress("UNCHECKED_CAST") + it.next() as SqlResultT? } -} fun SqlResult<*>.batchSqlResultRowCountSequence() = batchSqlResultSequence().map { it.rowCount() } From fb194873881825d568ffcd0ebc4a1f88d2d9a59c Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Sat, 18 Mar 2023 21:36:27 +0800 Subject: [PATCH 52/59] Add `awaitExecuteBatchForRowSetSequence`, and move and rename the `SqlResult` `Sequence` functions --- .../sqlclient/BatchSqlResultSequences.kt} | 7 +++---- .../huanshankeji/vertx/kotlin/sqlclient/PreparedQuery.kt | 9 +++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) rename vertx/src/main/kotlin/com/huanshankeji/vertx/{sqlclient/BatchSqlResult.kt => kotlin/sqlclient/BatchSqlResultSequences.kt} (69%) create mode 100644 vertx/src/main/kotlin/com/huanshankeji/vertx/kotlin/sqlclient/PreparedQuery.kt diff --git a/vertx/src/main/kotlin/com/huanshankeji/vertx/sqlclient/BatchSqlResult.kt b/vertx/src/main/kotlin/com/huanshankeji/vertx/kotlin/sqlclient/BatchSqlResultSequences.kt similarity index 69% rename from vertx/src/main/kotlin/com/huanshankeji/vertx/sqlclient/BatchSqlResult.kt rename to vertx/src/main/kotlin/com/huanshankeji/vertx/kotlin/sqlclient/BatchSqlResultSequences.kt index dc95331..c38695b 100644 --- a/vertx/src/main/kotlin/com/huanshankeji/vertx/sqlclient/BatchSqlResult.kt +++ b/vertx/src/main/kotlin/com/huanshankeji/vertx/kotlin/sqlclient/BatchSqlResultSequences.kt @@ -1,7 +1,6 @@ -package com.huanshankeji.vertx.sqlclient +package com.huanshankeji.vertx.kotlin.sqlclient -import io.vertx.sqlclient.RowSet -import io.vertx.sqlclient.SqlResult +import io.vertx.sqlclient.* fun > SqlResultT.batchSqlResultSequence(): Sequence = generateSequence(this) { @@ -12,5 +11,5 @@ fun > SqlResultT.batchSqlResultSequence(): Sequence.batchSqlResultRowCountSequence() = batchSqlResultSequence().map { it.rowCount() } -fun RowSet.batchSqlResultRowSequence() = +fun RowSet.batchSqlResultRowSequenceSequence() = batchSqlResultSequence().map { asSequence() } diff --git a/vertx/src/main/kotlin/com/huanshankeji/vertx/kotlin/sqlclient/PreparedQuery.kt b/vertx/src/main/kotlin/com/huanshankeji/vertx/kotlin/sqlclient/PreparedQuery.kt new file mode 100644 index 0000000..9bb15fc --- /dev/null +++ b/vertx/src/main/kotlin/com/huanshankeji/vertx/kotlin/sqlclient/PreparedQuery.kt @@ -0,0 +1,9 @@ +package com.huanshankeji.vertx.kotlin.sqlclient + +import io.vertx.kotlin.coroutines.await +import io.vertx.sqlclient.PreparedQuery +import io.vertx.sqlclient.RowSet +import io.vertx.sqlclient.Tuple + +suspend fun PreparedQuery>.awaitExecuteBatchForRowSetSequence(batch: List) = + executeBatch(batch).await().batchSqlResultSequence() From 7b82af02366eb5cd2677e736bf3f9e06b6759533 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Sun, 19 Mar 2023 01:49:33 +0800 Subject: [PATCH 53/59] Rename `awaitExecuteBatchForRowSetSequence` to `executeBatchAwaitForRowSetSequence` to follow the Vert.x convention --- .../com/huanshankeji/vertx/kotlin/sqlclient/PreparedQuery.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vertx/src/main/kotlin/com/huanshankeji/vertx/kotlin/sqlclient/PreparedQuery.kt b/vertx/src/main/kotlin/com/huanshankeji/vertx/kotlin/sqlclient/PreparedQuery.kt index 9bb15fc..5380c82 100644 --- a/vertx/src/main/kotlin/com/huanshankeji/vertx/kotlin/sqlclient/PreparedQuery.kt +++ b/vertx/src/main/kotlin/com/huanshankeji/vertx/kotlin/sqlclient/PreparedQuery.kt @@ -5,5 +5,5 @@ import io.vertx.sqlclient.PreparedQuery import io.vertx.sqlclient.RowSet import io.vertx.sqlclient.Tuple -suspend fun PreparedQuery>.awaitExecuteBatchForRowSetSequence(batch: List) = +suspend fun PreparedQuery>.executeBatchAwaitForRowSetSequence(batch: List) = executeBatch(batch).await().batchSqlResultSequence() From b2c3878da8439d82db2c0153cd05a11b212eae9b Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Sun, 19 Mar 2023 01:56:18 +0800 Subject: [PATCH 54/59] Refactor `executeBatchAwaitForRowSetSequence` into `executeBatchAwaitForSqlResultSequence` --- .../com/huanshankeji/vertx/kotlin/sqlclient/PreparedQuery.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vertx/src/main/kotlin/com/huanshankeji/vertx/kotlin/sqlclient/PreparedQuery.kt b/vertx/src/main/kotlin/com/huanshankeji/vertx/kotlin/sqlclient/PreparedQuery.kt index 5380c82..8494f72 100644 --- a/vertx/src/main/kotlin/com/huanshankeji/vertx/kotlin/sqlclient/PreparedQuery.kt +++ b/vertx/src/main/kotlin/com/huanshankeji/vertx/kotlin/sqlclient/PreparedQuery.kt @@ -2,8 +2,8 @@ package com.huanshankeji.vertx.kotlin.sqlclient import io.vertx.kotlin.coroutines.await import io.vertx.sqlclient.PreparedQuery -import io.vertx.sqlclient.RowSet +import io.vertx.sqlclient.SqlResult import io.vertx.sqlclient.Tuple -suspend fun PreparedQuery>.executeBatchAwaitForRowSetSequence(batch: List) = +suspend fun > PreparedQuery.executeBatchAwaitForSqlResultSequence(batch: List) = executeBatch(batch).await().batchSqlResultSequence() From d5c4a68c502f15d0cf537beb7e40b1f85629707f Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Fri, 28 Apr 2023 11:57:53 +0800 Subject: [PATCH 55/59] Update code related to `ProtoBufSumTypeSerializer` --- .../kotlinx/serialization/protobuf/SumType.kt | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/serialization/src/commonMain/kotlin/com/huanshankeji/kotlinx/serialization/protobuf/SumType.kt b/serialization/src/commonMain/kotlin/com/huanshankeji/kotlinx/serialization/protobuf/SumType.kt index 42a3ce3..c25e455 100644 --- a/serialization/src/commonMain/kotlin/com/huanshankeji/kotlinx/serialization/protobuf/SumType.kt +++ b/serialization/src/commonMain/kotlin/com/huanshankeji/kotlinx/serialization/protobuf/SumType.kt @@ -9,7 +9,7 @@ import kotlinx.serialization.protobuf.ProtoNumber @ExperimentalSerializationApi @Serializable -class SumTypeSupertypeSurrogate( +private class SumTypeSupertypeSurrogate( @ProtoNumber(1) val subtypeNumber: Int, @ProtoNumber(2) @@ -19,17 +19,22 @@ class SumTypeSupertypeSurrogate( get() = backingSubtypeSerializedData!! } +/** + * A ProtoBuf [KSerializer] for sum types, aka, open/abstract/sealed classes and interfaces. + * + * It's achieved by converting the object to a wrapper surrogate object [SumTypeSupertypeSurrogate], + * in which the type is stored as a classifying [Int] number [SumTypeSupertypeSurrogate.subtypeNumber]. + */ @ExperimentalSerializationApi interface ProtoBufSumTypeSerializer : KSerializer { - val surrogateSerializer get() = SumTypeSupertypeSurrogate.serializer() + private val surrogateSerializer get() = SumTypeSupertypeSurrogate.serializer() override val descriptor: SerialDescriptor get() = surrogateSerializer.descriptor - fun Supertype.toSurrogate(): SumTypeSupertypeSurrogate { + private fun Supertype.toSurrogate(): SumTypeSupertypeSurrogate { val (subtypeNumber, subtypeSerializer) = getSubtypeNumberAndSubtypeSerializationStrategy(this) @Suppress("UNCHECKED_CAST") return SumTypeSupertypeSurrogate( - // use `encodeToByteArrayNothingWorkaround` if something goes wrong subtypeNumber, ProtoBuf.encodeToByteArray( subtypeSerializer as SerializationStrategy, this ) @@ -38,8 +43,7 @@ interface ProtoBufSumTypeSerializer : KSerializer { fun getSubtypeNumberAndSubtypeSerializationStrategy(value: Supertype): Pair> - fun SumTypeSupertypeSurrogate.toOriginal(): Supertype = - // use `decodeFromByteArrayNothingWorkaround` if something goes wrong + private fun SumTypeSupertypeSurrogate.toOriginal(): Supertype = @Suppress("UNCHECKED_CAST") ProtoBuf.decodeFromByteArray( getSubtypeDeserializationStrategy(subtypeNumber) as DeserializationStrategy, From d66ec9e98f22978a2c42b208cdf056f79f2f9072 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Wed, 10 May 2023 21:19:21 +0800 Subject: [PATCH 56/59] Update the message of `Untested` --- core/src/commonMain/kotlin/com/huanshankeji/Untested.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/commonMain/kotlin/com/huanshankeji/Untested.kt b/core/src/commonMain/kotlin/com/huanshankeji/Untested.kt index 4874f85..a4fe834 100644 --- a/core/src/commonMain/kotlin/com/huanshankeji/Untested.kt +++ b/core/src/commonMain/kotlin/com/huanshankeji/Untested.kt @@ -2,7 +2,7 @@ package com.huanshankeji import kotlin.annotation.AnnotationTarget.* -@RequiresOptIn("This API is untested.", RequiresOptIn.Level.WARNING) +@RequiresOptIn("This API hasn't been tested yet.", RequiresOptIn.Level.WARNING) @Retention(AnnotationRetention.BINARY) // The ones commented out are what I think may be used in very few use cases. @Target( From 053eab230fc97e04784078e5a6dc0452e91a7c17 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Tue, 16 May 2023 02:45:14 +0800 Subject: [PATCH 57/59] Mark code in ClassPropertyMapping.kt as `@Untested` --- exposed/build.gradle.kts | 4 +++ .../classproperty/ClassPropertyMapping.kt | 26 ++++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/exposed/build.gradle.kts b/exposed/build.gradle.kts index f471d4b..1d4fe2a 100644 --- a/exposed/build.gradle.kts +++ b/exposed/build.gradle.kts @@ -1,7 +1,11 @@ +import com.huanshankeji.cpnProject + plugins { id("jvm-conventions") } dependencies { implementation(commonDependencies.exposed.core()) + + implementation(cpnProject(project, ":core")) } diff --git a/exposed/src/main/kotlin/com/huanshankeji/exposed/datamapping/classproperty/ClassPropertyMapping.kt b/exposed/src/main/kotlin/com/huanshankeji/exposed/datamapping/classproperty/ClassPropertyMapping.kt index c933bad..90dd8d8 100644 --- a/exposed/src/main/kotlin/com/huanshankeji/exposed/datamapping/classproperty/ClassPropertyMapping.kt +++ b/exposed/src/main/kotlin/com/huanshankeji/exposed/datamapping/classproperty/ClassPropertyMapping.kt @@ -1,14 +1,21 @@ package com.huanshankeji.exposed.datamapping.classproperty +import com.huanshankeji.Untested import com.huanshankeji.exposed.datamapping.DataMapper import com.huanshankeji.exposed.datamapping.NullableDataMapper -import com.huanshankeji.exposed.datamapping.classproperty.OnDuplicateColumnPropertyNames.* +import com.huanshankeji.exposed.datamapping.classproperty.OnDuplicateColumnPropertyNames.CHOOSE_FIRST +import com.huanshankeji.exposed.datamapping.classproperty.OnDuplicateColumnPropertyNames.THROW import com.huanshankeji.exposed.datamapping.classproperty.PropertyColumnMapping.* import org.jetbrains.exposed.sql.* import org.jetbrains.exposed.sql.statements.UpdateBuilder import org.slf4j.LoggerFactory -import kotlin.reflect.* -import kotlin.reflect.full.* +import kotlin.reflect.KClass +import kotlin.reflect.KProperty1 +import kotlin.reflect.KType +import kotlin.reflect.full.isSubclassOf +import kotlin.reflect.full.memberProperties +import kotlin.reflect.full.primaryConstructor +import kotlin.reflect.typeOf import kotlin.sequences.Sequence // Our own class mapping implementation using reflection which should be adapted using annotation processors and code generation in the future. @@ -25,6 +32,7 @@ TODO: consider decoupling/removing `property` and `Data` from this class and ren However, after the refactor, `ColumnMapping` will still be coupled with `ClassPropertyColumnMappings` which is coupled with `PropertyColumnMapping`, so I am not sure whether this is necessary. */ +@Untested sealed class PropertyColumnMapping(val property: KProperty1) { class ExposedSqlPrimitive( property: KProperty1, @@ -217,6 +225,7 @@ class PropertyColumnMappingConfig

( typealias PropertyColumnMappingConfigMap = Map, PropertyColumnMappingConfig<*>> +@Untested fun getDefaultClassPropertyColumnMappings( clazz: KClass, columnByPropertyNameMap: Map>, @@ -341,6 +350,7 @@ fun KClass.sealedLeafSubclasses(): List> = if (isSealed) sealedSubclasses.flatMap { it.sealedLeafSubclasses() } else listOf(this) +@Untested fun getDefaultClassPropertyColumnMappings( clazz: KClass, tables: List

, onDuplicateColumnPropertyNames: OnDuplicateColumnPropertyNames = CHOOSE_FIRST, @@ -356,6 +366,7 @@ fun getDefaultClassPropertyColumnMappings( // TODO: decouple query mapper and update mapper. /** Supports classes with nested composite class properties and multiple tables */ +@Untested class ReflectionBasedClassPropertyDataMapper( val clazz: KClass, val classPropertyColumnMappings: ClassPropertyColumnMappings, @@ -369,6 +380,8 @@ class ReflectionBasedClassPropertyDataMapper( } } + +@Untested fun constructDataWithResultRow( clazz: KClass, classPropertyColumnMappings: ClassPropertyColumnMappings, resultRow: ResultRow ): Data = @@ -414,6 +427,7 @@ fun constructDataWithResultRow( typeParameterHelper(it as PropertyColumnMapping, it.property.returnType.classifier as KClass) }.toTypedArray()) +@Untested fun setUpdateBuilder( classPropertyColumnMappings: ClassPropertyColumnMappings, data: Data, updateBuilder: UpdateBuilder<*> ) { @@ -482,6 +496,7 @@ fun setUpdateBuilder( } } +@Untested fun PropertyColumnMapping<*, *>.forEachColumn(block: (Column<*>) -> Unit) = when (this) { is ExposedSqlPrimitive -> block(column) @@ -503,11 +518,13 @@ fun PropertyColumnMapping<*, *>.forEachColumn(block: (Column<*>) -> Unit) = is Skip -> {} } +@Untested fun ClassPropertyColumnMappings<*>.forEachColumn(block: (Column<*>) -> Unit) { for (propertyColumnMapping in this) propertyColumnMapping.forEachColumn(block) } +@Untested fun setUpdateBuilderColumnsToNullsWithMappings( classPropertyColumnMappings: ClassPropertyColumnMappings<*>, updateBuilder: UpdateBuilder<*> ) = @@ -522,9 +539,11 @@ fun setUpdateBuilderColumnsToNulls(columns: List>, updateBuilder: Upda updateBuilder[column as Column] = null } +@Untested fun ClassPropertyColumnMappings<*>.getColumnSet(): Set> = buildSet { forEachColumn { add(it) } } +@Untested inline fun reflectionBasedClassPropertyDataMapper( tables: List
, onDuplicateColumnPropertyNames: OnDuplicateColumnPropertyNames = CHOOSE_FIRST, @@ -539,6 +558,7 @@ inline fun reflectionBasedClassPropertyDataMapper( ) } +@Untested inline fun reflectionBasedClassPropertyDataMapper( table: Table, propertyColumnMappingConfigMapOverride: PropertyColumnMappingConfigMap = emptyMap(), From e778ed51ddc434846dd91ef24604b348645b3ff0 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Tue, 16 May 2023 02:49:41 +0800 Subject: [PATCH 58/59] Change `projectVersion` back to the main branch one --- buildSrc/src/main/kotlin/VersionsAndDependencies.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/src/main/kotlin/VersionsAndDependencies.kt b/buildSrc/src/main/kotlin/VersionsAndDependencies.kt index 10dc532..49b2c3a 100644 --- a/buildSrc/src/main/kotlin/VersionsAndDependencies.kt +++ b/buildSrc/src/main/kotlin/VersionsAndDependencies.kt @@ -2,7 +2,7 @@ import com.huanshankeji.CommonDependencies import com.huanshankeji.CommonGradleClasspathDependencies import com.huanshankeji.CommonVersions -val projectVersion = "0.3.0-generic-exposed-class-property-mapping-SNAPSHOT" +val projectVersion = "0.3.0-SNAPSHOT" val commonVersions = CommonVersions() val commonDependencies = CommonDependencies(commonVersions) From ae8241d992613600725727a6119c49b30a7367e8 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Tue, 16 May 2023 02:51:32 +0800 Subject: [PATCH 59/59] Add a sentence in the message of `@Untested` --- core/src/commonMain/kotlin/com/huanshankeji/Untested.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/commonMain/kotlin/com/huanshankeji/Untested.kt b/core/src/commonMain/kotlin/com/huanshankeji/Untested.kt index a4fe834..6c4a37c 100644 --- a/core/src/commonMain/kotlin/com/huanshankeji/Untested.kt +++ b/core/src/commonMain/kotlin/com/huanshankeji/Untested.kt @@ -2,7 +2,7 @@ package com.huanshankeji import kotlin.annotation.AnnotationTarget.* -@RequiresOptIn("This API hasn't been tested yet.", RequiresOptIn.Level.WARNING) +@RequiresOptIn("This API hasn't been tested yet. Use at your own risk.", RequiresOptIn.Level.WARNING) @Retention(AnnotationRetention.BINARY) // The ones commented out are what I think may be used in very few use cases. @Target(