From d8804c0efc75199bd23a34e600a8e1b6692fb1c6 Mon Sep 17 00:00:00 2001 From: Andrew Golovashevich Date: Sun, 23 Feb 2025 14:00:58 +0300 Subject: [PATCH] Strict properties mangling rules for JVM targets --- .../db/serdha0/api/misc/Column.kt | 26 +--- .../db/serdha0/api/misc/DatabaseType.kt | 29 ++--- .../db/serdha0/api/misc/FiltersScope.kt | 10 +- .../db/serdha0/api/misc/IntermediateColumn.kt | 4 +- .../db/serdha0/api/misc/Mapper.kt | 25 +++- .../db/serdha0/api/misc/QueryParam.kt | 10 +- .../db/serdha0/api/misc/Reducer.kt | 10 ++ .../db/serdha0/api/misc/RowExpression.kt | 7 ++ .../db/serdha0/api/misc/_Selectable.kt | 22 ++++ .../serdha0/api/module/CreateModuleScope.kt | 52 +------- .../db/serdha0/api/module/Module.kt | 16 +-- .../db/serdha0/api/module/ModuleTemplate.kt | 7 ++ .../db/serdha0/api/module/Namespace.kt | 8 +- .../serdha0/api/module/UpgradeModuleScope.kt | 111 +----------------- .../db/serdha0/api/queries/DeleteQuery.kt | 33 ++++++ .../db/serdha0/api/queries/InsertQuery.kt | 22 ++++ .../db/serdha0/api/queries/SelectQuery.kt | 75 ++++++++++++ .../db/serdha0/api/queries/UpdateQuery.kt | 35 ++++++ .../db/serdha0/api/queries/_Query.kt | 5 + .../serdha0/api/runtime/DatabaseConnection.kt | 4 +- .../db/serdha0/api/runtime/Executor.kt | 6 - .../db/serdha0/api/runtime/InputRow.kt | 3 + .../db/serdha0/api/runtime/OutputRow.kt | 3 + .../db/serdha0/api/table/CheckConstraint.kt | 3 + .../serdha0/api/table/ForeignRowReference.kt | 26 ---- .../db/serdha0/api/table/Index.kt | 20 +--- .../db/serdha0/api/table/Table.kt | 14 ++- .../db/serdha0/api/table/TableConstructor.kt | 6 + .../db/serdha0/api/table/UniqueIndex.kt | 4 + 29 files changed, 318 insertions(+), 278 deletions(-) diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/misc/Column.kt b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/misc/Column.kt index 3fff0ae..3d99287 100644 --- a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/misc/Column.kt +++ b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/misc/Column.kt @@ -1,35 +1,17 @@ package ru.landgrafhomyak.db.serdha0.api.misc import kotlin.jvm.JvmName -import ru.landgrafhomyak.db.serdha0.api.table.Table -/** - * Descriptor of data column (of table or query). Used for schema manipulations and [access in queries builder][SelectedTable.selectColumn]. - * - * @param RT Type in programming language to which database type is converted. - * @param DT Descriptor of column type on database side. - * @param TableUserExtension Type of [owner's table][Column.table] user expression for static reporting errors when this descriptor passed to wrong table. - */ -public interface Column, TableUserExtension : Any> { - /** - * Name of column for debugging, errors and raw schema access. - */ +public interface Column, tUE : Any> { @Suppress("INAPPLICABLE_JVM_NAME") @get:JvmName("name") public val name: String - - /** - * Descriptor of column type on database side. - */ @Suppress("INAPPLICABLE_JVM_NAME") @get:JvmName("type") public val type: DT - /** - * Table, that contains this column. For debugging. - */ - @Suppress("INAPPLICABLE_JVM_NAME") - @get:JvmName("table") - public val table: Table + @Suppress("INAPPLICABLE_JVM_NAME", "PropertyName") + @get:JvmName("_getOwner") + public val _owner: _Selectable } \ No newline at end of file diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/misc/DatabaseType.kt b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/misc/DatabaseType.kt index 6c69f69..ddc9869 100644 --- a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/misc/DatabaseType.kt +++ b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/misc/DatabaseType.kt @@ -5,15 +5,10 @@ import kotlin.jvm.JvmName import ru.landgrafhomyak.db.serdha0.api.table.RowId import ru.landgrafhomyak.db.serdha0.api.table.Table -/** - * Descriptor of a database type. - * - * @param RT Type in programming language to which database type is converted. - */ @Suppress("ClassName", "RemoveRedundantQualifierName") public interface DatabaseType<@Suppress("unused") RT> { @Suppress("INAPPLICABLE_JVM_NAME") - @get:JvmName("name") + @get:JvmName("getName") public val name: String public abstract class _VirtualType>( @@ -41,27 +36,20 @@ public interface DatabaseType<@Suppress("unused") RT> { public interface BOOLEAN : DatabaseType - /** - * Descriptor of a raw binary data type for static type-checking. - * @see DatabaseType.Provider.BINARY_DATA - */ @OptIn(ExperimentalUnsignedTypes::class) public interface BINARY_DATA : DatabaseType { - /** - * Maximum count of bytes that can be stored by values of this type ot `null` if there is no limit. - */ + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("getMaxSizeOrNull") public val maxSizeOrNull: UInt? - /** - * `true` if value can't hold less than [maxSizeOrNull][DatabaseType.BINARY_DATA.maxSizeOrNull] bytes. - */ + + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("isFixedSize") public val isFixedSize: Boolean } public interface Provider { - @Suppress("INAPPLICABLE_JVM_NAME", "FunctionName") - @JvmName("ROW_ID") - public fun ROW_ID(table: Table): DatabaseType.ROW_ID + public fun ROW_ID(table: Table): DatabaseType.ROW_ID @Suppress("INAPPLICABLE_JVM_NAME", "PropertyName") @get:JvmName("BOOLEAN") @@ -71,11 +59,8 @@ public interface DatabaseType<@Suppress("unused") RT> { @get:JvmName("BINARY_DATA") public val BINARY_DATA: BINARY_DATA - @Suppress("INAPPLICABLE_JVM_NAME") - @JvmName("BINARY_DATA") public fun BINARY_DATA(size: UInt, isFixedSize: Boolean): BINARY_DATA public fun > nullableOf(notNull: DT): Nullable - } } diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/misc/FiltersScope.kt b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/misc/FiltersScope.kt index 5bacd2d..e431027 100644 --- a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/misc/FiltersScope.kt +++ b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/misc/FiltersScope.kt @@ -2,9 +2,10 @@ package ru.landgrafhomyak.db.serdha0.api.misc public interface FiltersScope { public fun > filterNotNull(nullable: IntermediateColumn, oqUE>): IntermediateColumn + public fun > filterIsNull(nullable: IntermediateColumn, oqUE>) - public enum class ComparisonType { + public enum class ComparisonOperator { EQUALS, NOT_EQUALS, LESS, @@ -13,8 +14,11 @@ public interface FiltersScope { GREATER_OR_EQUALS, } - public fun > compareWithParam(column: IntermediateColumn, operator: ComparisonType, param: QueryParam) - public fun > compareWithConstant(column: IntermediateColumn, operator: ComparisonType, constant: RT) + public fun > compareWithParam(column: IntermediateColumn, operator: ComparisonOperator, param: QueryParam) + + public fun > compareWithConstant(column: IntermediateColumn, operator: ComparisonOperator, constant: RT) + public fun ifTrue(column: IntermediateColumn) + public fun ifFalse(column: IntermediateColumn) } \ No newline at end of file diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/misc/IntermediateColumn.kt b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/misc/IntermediateColumn.kt index ad568d7..f17e80a 100644 --- a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/misc/IntermediateColumn.kt +++ b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/misc/IntermediateColumn.kt @@ -1,5 +1,3 @@ package ru.landgrafhomyak.db.serdha0.api.misc -public interface IntermediateColumn, OwnerBuilderUserExtension : Any> { - -} \ No newline at end of file +public interface IntermediateColumn, OwnerBuilderUserExtension : Any> \ No newline at end of file diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/misc/Mapper.kt b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/misc/Mapper.kt index 271d230..8fc9421 100644 --- a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/misc/Mapper.kt +++ b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/misc/Mapper.kt @@ -1,9 +1,12 @@ package ru.landgrafhomyak.db.serdha0.api.misc +import kotlin.jvm.JvmName import ru.landgrafhomyak.db.serdha0.api.runtime.InputRow import ru.landgrafhomyak.db.serdha0.api.runtime.OutputRow public interface Mapper { + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("uExt") public val uExt: mUE public interface InputColumn, mUE : Any> : Column @@ -12,18 +15,24 @@ public interface Mapper { public fun interface InputLinker { public fun link(linker: Scope) - public interface Scope<_mUE : Any, qUE : Any> { - public val mUE: _mUE - public operator fun > set(p: InputColumn, e: IntermediateColumn) + public interface Scope { + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("uExt") + public val uExt: mUE + + public operator fun > set(p: InputColumn, e: IntermediateColumn) } } public fun interface OutputLinker { public fun link(linker: Scope): oUE - public interface Scope<_mUE : Any, qUE : Any> { - public val mUE: _mUE - public operator fun > get(p: OutputColumn): IntermediateColumn + public interface Scope { + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("uExt") + public val uExt: mUE + + public operator fun > get(p: OutputColumn): IntermediateColumn } } @@ -31,8 +40,12 @@ public interface Mapper { public fun createMapper(context: Scope): Action public interface Scope { + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("types") public val types: DatabaseType.Provider + public fun > input(name: String, type: DT): InputColumn + public fun > output(name: String, type: DT): OutputColumn } } diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/misc/QueryParam.kt b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/misc/QueryParam.kt index d1c59c3..87b05d3 100644 --- a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/misc/QueryParam.kt +++ b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/misc/QueryParam.kt @@ -1,7 +1,13 @@ package ru.landgrafhomyak.db.serdha0.api.misc -public interface QueryParam, OwnerQueryUserExtension : Any> { +import kotlin.jvm.JvmName + +public interface QueryParam, oqUE : Any> { + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("getName") public val name: String - public val userWrapper: OwnerQueryUserExtension + + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("getType") public val type: DT } \ No newline at end of file diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/misc/Reducer.kt b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/misc/Reducer.kt index f957ab5..51672d8 100644 --- a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/misc/Reducer.kt +++ b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/misc/Reducer.kt @@ -1,9 +1,13 @@ package ru.landgrafhomyak.db.serdha0.api.misc +import kotlin.jvm.JvmName import ru.landgrafhomyak.db.serdha0.api.runtime.InputRow import ru.landgrafhomyak.db.serdha0.api.runtime.OutputRow public interface Reducer { + + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("uExt") public val uExt: rUE public interface BidirectionalColumn, rUE : Any> : Column, QueryParam @@ -14,7 +18,10 @@ public interface Reducer { public fun link(linker: Scope<_rUE, qUE>): oUE public interface Scope { + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("uExt") public val uExt: rUE + public fun > link(red: BidirectionalColumn, src: IntermediateColumn): IntermediateColumn public fun > linkAndInitialize(red: BidirectionalColumn, src: IntermediateColumn, initial: RT): IntermediateColumn public fun > linkAndInitialize(red: BidirectionalColumn, src: IntermediateColumn, initial: QueryParam): IntermediateColumn @@ -28,7 +35,10 @@ public interface Reducer { public fun createReducer(context: Scope): Action public interface Scope { + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("types") public val types: DatabaseType.Provider + public fun > outputColumn(name: String, type: DT): OutputColumn public fun > outputColumn(name: String, type: DT, defaultInitialValue: RT): OutputColumn public fun > bidirectionalColumn(name: String, type: DT): BidirectionalColumn diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/misc/RowExpression.kt b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/misc/RowExpression.kt index f869f3a..b2d1044 100644 --- a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/misc/RowExpression.kt +++ b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/misc/RowExpression.kt @@ -1,5 +1,6 @@ package ru.landgrafhomyak.db.serdha0.api.misc +import kotlin.jvm.JvmName import ru.landgrafhomyak.db.serdha0.api.queries._Query import ru.landgrafhomyak.db.serdha0.api.runtime.OutputRow import ru.landgrafhomyak.db.serdha0.api.runtime.Transaction @@ -7,12 +8,16 @@ import ru.landgrafhomyak.db.serdha0.api.table.RowId import ru.landgrafhomyak.db.serdha0.api.table.Table public interface RowExpression { + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("getTargetTable") public val targetTable: Table public interface RowExportsConstructor { public fun createRowExports(context: Scope): rUE public interface Scope { + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("tt") public val tt: Table public fun > selectFromTargetTable(column: Column): Column @@ -30,6 +35,8 @@ public interface RowExpression { } public interface Constructor { + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("rowExports") public val rowExports: RowExportsConstructor public fun createRowExpression(internalQueries: _Query.Constructor._SelectsScope, runtimeQueries: _Query.Constructor._SelectsScope): Action diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/misc/_Selectable.kt b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/misc/_Selectable.kt index 5d39a34..1d76120 100644 --- a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/misc/_Selectable.kt +++ b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/misc/_Selectable.kt @@ -1,6 +1,28 @@ package ru.landgrafhomyak.db.serdha0.api.misc +import kotlin.jvm.JvmName +import ru.landgrafhomyak.db.serdha0.api.queries.SelectQuery +import ru.landgrafhomyak.db.serdha0.api.queries.InsertQuery +import ru.landgrafhomyak.db.serdha0.api.queries.UpdateQuery +import ru.landgrafhomyak.db.serdha0.api.queries.DeleteQuery + + +/** + * Utility interface to mark queries (and table) that can be used as the source for other queries. + * + * @param UE Type of extension provided by user ([about user extensions](https://git.landgrafhomyak.ru/SERDHA/serdha-0-api.kt/wiki/User-extensions)). + * + * @see SelectQuery + * @see InsertQuery.FromSubquery.Constructor.selector + * @see UpdateQuery.FromSubquery.Constructor.selector + * @see DeleteQuery.FromSubquery.Constructor.selector + */ @Suppress("ClassName") public interface _Selectable { + /** + * Getter of an extension provided by user ([about user extensions](https://git.landgrafhomyak.ru/SERDHA/serdha-0-api.kt/wiki/User-extensions)). + */ + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("uExt") public val uExt: UE } \ No newline at end of file diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/module/CreateModuleScope.kt b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/module/CreateModuleScope.kt index b7967f8..fca93ed 100644 --- a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/module/CreateModuleScope.kt +++ b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/module/CreateModuleScope.kt @@ -1,58 +1,22 @@ package ru.landgrafhomyak.db.serdha0.api.module +import kotlin.jvm.JvmName import ru.landgrafhomyak.db.serdha0.api.table.Table import ru.landgrafhomyak.db.serdha0.api.queries._Query import ru.landgrafhomyak.db.serdha0.api.runtime.Executor import ru.landgrafhomyak.db.serdha0.api.runtime.Transaction import ru.landgrafhomyak.db.serdha0.api.table.TableConstructor -/** - * Scope methods for creating new [module template][ModuleTemplate]. - * - * @see ModuleTemplate.CreateModuleTemplatesScope.createTemplate - * @see ModuleTemplate.ModuleConstructor.createSchema - */ + public interface CreateModuleScope { + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("rootNs") public val rootNs: Namespace - /** - * Creates table in [specified namespace][namespace] with [specified name][name] and stores it in the database. - * If table was created by previous synchronizations, asserts that table at the specified path in the database is same as table provided by [initializer]. - * - * On [module upgrading][ModuleTemplate.CreateModuleTemplatesScope.upgradeTemplate] this table must be [kept][UpgradeModuleScope.upgradeTable] (or [renamed][UpgradeModuleScope.renameTable]) or [deleted][UpgradeModuleScope.deleteTable]. - * - * @param tUE User's type for containing table-related descriptors. - * @param namespace Way to group tables if there is a lot. - * @param name Name of table for debugging. - * @param initializer Table-related descriptors initializer. - * @return Table descriptor. - */ public fun createTable(namespace: Namespace = this.rootNs, name: String, initializer: TableConstructor): Table - /** - * Creates a temporary table that exits only until connection to the database not [closed][Executor._close]. - * - * On [module upgrading][ModuleTemplate.CreateModuleTemplatesScope.upgradeTemplate] must be recreated if needed. - * - * @param tUE User's type for containing table-related descriptors. - * @param namespace Way to group tables if there is a lot. - * @param name Name of table for debugging. - * @param initializer Table-related descriptors initializer. - * @return Table descriptor. - */ public fun createSessionScopeTemporaryTable(namespace: Namespace = this.rootNs, name: String, initializer: TableConstructor): Table - /** - * Creates a temporary table that exits only inside [transaction][Transaction] and auto-deleted (or cleared, depends on driver implementation) when it [finished][Transaction._assertTransactionFinishedAndReleaseResources]. - * - * On [module upgrading][ModuleTemplate.CreateModuleTemplatesScope.upgradeTemplate] must be recreated if needed. - * - * @param tUE User's type for containing table-related descriptors. - * @param namespace Way to group tables if there is a lot. - * @param name Name of table for debugging. - * @param initializer Table-related descriptors initializer. - * @return Table descriptor. - */ public fun createTransactionScopeTemporaryTable(namespace: Namespace = this.rootNs, name: String, initializer: TableConstructor): Table public fun createModuleConfiguringScopeTemporaryTable(namespace: Namespace = this.rootNs, name: String, initializer: TableConstructor): Table @@ -61,13 +25,5 @@ public interface CreateModuleScope { public fun createModuleConfiguringScopeTemporaryQuery(creator: _Query.Constructor): R - /** - * Replaces [specified namespace][rootNs] with schema provided by [template]. - * [This namespace][rootNs] will be root namespace for module and shouldn't contain any other definitions. - * - * @param rootNs Namespace where the new module will be located. - * @param template Schema template. - * @return Module descriptor. - */ public fun substituteModule(rootNs: Namespace, template: ModuleTemplate): Module } \ No newline at end of file diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/module/Module.kt b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/module/Module.kt index e54be78..127f0c0 100644 --- a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/module/Module.kt +++ b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/module/Module.kt @@ -4,25 +4,19 @@ import kotlin.jvm.JvmName import ru.landgrafhomyak.db.serdha0.api.queries._Query import ru.landgrafhomyak.db.serdha0.api.runtime.Executor -/** - * Descriptor of synchronized module. Used for schema manipulations. - */ + public interface Module { - /** - * Reference user's extension with descriptors related to this module for use in runtime. - */ @Suppress("INAPPLICABLE_JVM_NAME") - @get:JvmName("userExtension") + @get:JvmName("uExt") public val uExt: mUE - /** - * Version key internally used for automatically [upgrading modules][ModuleTemplate.CreateModuleTemplatesScope.upgradeTemplate]. For debugging. - */ @Suppress("INAPPLICABLE_JVM_NAME") - @get:JvmName("versionKey") + @get:JvmName("getVersionKey") public val versionKey: String public fun createQuery(c: _Query.Constructor): R + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("executor") public val executor: Executor } \ No newline at end of file diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/module/ModuleTemplate.kt b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/module/ModuleTemplate.kt index 837ac40..3f8a6a8 100644 --- a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/module/ModuleTemplate.kt +++ b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/module/ModuleTemplate.kt @@ -1,5 +1,6 @@ package ru.landgrafhomyak.db.serdha0.api.module +import kotlin.jvm.JvmName import ru.landgrafhomyak.db.serdha0.api.runtime.Transaction public interface ModuleTemplate<@Suppress("unused") mUE : Any> { @@ -25,6 +26,8 @@ public interface ModuleTemplate<@Suppress("unused") mUE : Any> { } public interface ModuleConstructor { + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("versionKey") public val versionKey: String public fun createSchema(context: CreateModuleScope): mUE @@ -33,6 +36,8 @@ public interface ModuleTemplate<@Suppress("unused") mUE : Any> { } public interface ModuleUpgrade { + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("versionKey") public val versionKey: String public fun upgradeSchema(context: UpgradeModuleScope): nmUE @@ -40,5 +45,7 @@ public interface ModuleTemplate<@Suppress("unused") mUE : Any> { public suspend fun upgradeData(ext: nmUE, transaction: Transaction) {} } + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("getVersionKey") public val versionKey: String } \ No newline at end of file diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/module/Namespace.kt b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/module/Namespace.kt index 40f935f..c94e851 100644 --- a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/module/Namespace.kt +++ b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/module/Namespace.kt @@ -1,10 +1,16 @@ package ru.landgrafhomyak.db.serdha0.api.module +import kotlin.jvm.JvmName + public interface Namespace { @Suppress("SpellCheckingInspection") public fun subnamespace(name: String): Namespace + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("getName") public val name: String - public val path: List + @Suppress("INAPPLICABLE_JVM_NAME", "PropertyName") + @get:JvmName("_getPath") + public val _path: List } \ No newline at end of file diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/module/UpgradeModuleScope.kt b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/module/UpgradeModuleScope.kt index 936e6cb..37b91e5 100644 --- a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/module/UpgradeModuleScope.kt +++ b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/module/UpgradeModuleScope.kt @@ -1,101 +1,36 @@ package ru.landgrafhomyak.db.serdha0.api.module +import kotlin.jvm.JvmName import ru.landgrafhomyak.db.serdha0.api.table.Table import ru.landgrafhomyak.db.serdha0.api.table.TableConstructor -/** - * Scope methods for upgrading [module template][ModuleTemplate]. - * - * @see ModuleTemplate.CreateModuleTemplatesScope.upgradeTemplate - * @see ModuleTemplate.ModuleUpgrade.upgradeSchema - */ + public interface UpgradeModuleScope : CreateModuleScope { + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("oldModule") public val oldModule: omUE - /** - * Functional interface for updating table. - * - * Can be implemented like a companion object that just calls [tnUE]'s constructor with the same or similar signature. - * - * @param tnUE User's type with table's descriptors from the previous table version. - * @param toUE User's type with descriptors of upgraded table. - * - * @see UpgradeModuleScope.upgradeTable - * @see UpgradeModuleScope.renameTable - * @see UpgradeModuleScope.upgradeAndRenameTable - * @see UpgradeModuleScope.CreateTable - */ public interface TableUpgrade { - /** - * Scope method that uses [upgrader] to update table schema. - * - * @param oldTable Descriptor to the previous version of table from which can be got user's extension with old descriptors. - * @param upgrader Object with descriptor providers and factories. - * @return User's object with upgraded descriptors for future access. - * - * @see UpgradeModuleScope.upgradeTable - * @see UpgradeModuleScope.renameTable - * @see UpgradeModuleScope.upgradeAndRenameTable - * @see UpgradeModuleScope.CreateTable - */ public fun upgradeTable(oldTable: Table, upgrade: TableUpgrade): tnUE } - /** - * Marks that table wouldn't be changed in this module version. - * - * @param tUE User's type with descriptors of related to table. - * @param oldTable Descriptor of table created in a previous template version. - * @return New table descriptor. - */ public fun keepTable( table: Table, ): Table - /** - * Renames or moves table without changing its schema. - * - * @param tUE User's type with descriptors of related to table. - * @param table Descriptor to table which should be renamed. - * @param newNamespace New namespace of the table. May be `null` if not changed. - * @param newName New namespace of the table. May be `null` if not changed. - * @return New table descriptor. - * @throws IllegalArgumentException If both [newName] and [newNamespace] are same as old or `null`. - */ public fun renameTable( table: Table, newNamespace: Namespace? = null, newName: String? = null ): Table - /** - * Upgrade table's descriptors without changing its [name][Table.name] or [namespace][Table.namespacesFromModuleRoot]. - * - * @param tnUE User's type with descriptors of upgraded table. - * @param toUE User's type with table's descriptors from the previous table version. - * @param oldTable Descriptor to the previous version of table from which can be got user's extension with old descriptors. - * @param upgrade Object with descriptor providers and factories. - * @return New table descriptor. - */ public fun upgradeTable( oldTable: Table, upgrade: TableUpgrade ): Table - /** - * Both upgrade table's schema and renames or moves table. - * - * @param tnUE User's type with descriptors of upgraded table. - * @param toUE User's type with table's descriptors from the previous table version. - * @param oldTable Descriptor of table which should be renamed and upgraded. - * @param newNamespace New namespace of the table. May be `null` if not changed. - * @param newName New namespace of the table. May be `null` if not changed. - * @param upgrade Object with descriptor providers and factories. - * @return New table descriptor. - * @throws IllegalArgumentException If both [newName] and [newNamespace] are same as old or `null`. - */ public fun upgradeAndRenameTable( oldTable: Table, newNamespace: Namespace? = null, @@ -103,49 +38,11 @@ public interface UpgradeModuleScope : CreateModuleScope { upgrade: TableUpgrade ): Table - /** - * Deletes table and all data in it. - * - * @param table Descriptor of table which should be deleted. - * - * @see UpgradeModuleScope.deleteTableAfterModuleUpgraded - */ public fun deleteTable(table: Table<*, *>) - /** - * Keeps table while module upgrading and deletes it after [ModuleTemplate.ModuleUpgrade.upgradeData]. - * [Table's][table] name become free and can be used for another table. - * - * @param table Descriptor of table which should be deleted. - * - * @see UpgradeModuleScope.deleteTable - */ public fun deleteTableAfterModuleUpgraded(table: Table<*, *>) - - /** - * Creates a temporary table that exits only while module upgrading and auto-deleted after [ModuleTemplate.ModuleUpgrade.upgradeData]. - * - * @param tUE User's type for containing table-related descriptors. - * @param namespace Way to group tables if there is a lot. - * @param name Name of table for debugging. - * @param initializer Table-related descriptors initializer. - * @return Table descriptor. - * - * @see UpgradeModuleScope.deleteTableAfterModuleUpgraded - * @see CreateModuleScope.createTable - * @see CreateModuleScope.createSessionScopeTemporaryTable - * @see CreateModuleScope.createTransactionScopeTemporaryTable - */ public fun createModuleUpgradeScopeTemporaryTable(namespace: Namespace, name: String, initializer: TableConstructor): Table - - /** - * Upgrades [module][oldModule] located at [rootNs] with new schema template. - * - * @param rootNs Namespace where the [old module][oldModule] is located and where upgraded module will be. - * @param template Schema template. - * @return Module descriptor. - */ public fun upgradeModule(oldModule: Module<*>, rootNs: Namespace, template: ModuleTemplate): Module } \ No newline at end of file diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/queries/DeleteQuery.kt b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/queries/DeleteQuery.kt index 67a25cd..5ad04e3 100644 --- a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/queries/DeleteQuery.kt +++ b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/queries/DeleteQuery.kt @@ -1,5 +1,6 @@ package ru.landgrafhomyak.db.serdha0.api.queries +import kotlin.jvm.JvmName import ru.landgrafhomyak.db.serdha0.api.misc.Column import ru.landgrafhomyak.db.serdha0.api.misc.DatabaseType import ru.landgrafhomyak.db.serdha0.api.misc.QueryParam @@ -14,16 +15,24 @@ public interface DeleteQuery : _Query { override fun createQuery(internalQueries: _Query.Constructor.Scope, outQueries: _Query.Constructor.Scope): SingleRow = outQueries.deleteSingleRow(this) + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("targetTable") public val targetTable: Table public fun createDeleteSingleRowWithReturning(context: Scope): qUE public interface Scope { + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("tt") public val tt: Table + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("types") public val types: DatabaseType.Provider public fun > queryParam(name: String, type: DT): QueryParam + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("rowToRemove") public val rowToRemove: QueryParam, DatabaseType.ROW_ID, qUE> public fun > returnRemovedValue(name: String, column: Column): Column @@ -41,19 +50,37 @@ public interface DeleteQuery : _Query { override fun createQuery(internalQueries: _Query.Constructor.Scope, outQueries: _Query.Constructor.Scope): FromSubquery = outQueries.deleteFromSubquery(this) + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("rowToRemove") public val targetTable: Table + + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("selector") public val selector: _Selectable public fun createDeleteFromSubqueryWithReturning(context: Scope): qUE public interface Scope { + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("tt") public val tt: Table + + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("src") public val src: _Selectable + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("types") public val types: DatabaseType.Provider public fun > queryParam(name: String, type: DT): QueryParam + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("selectorParams") public val selectorParams: InputRow.WithRedirect + + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("_getSelectorColumn") + @set:JvmName("selectorColumn") public var selectorColumn: Column, DatabaseType.ROW_ID, sUE> public fun > returnFromSubquery(name: String, column: Column): Column @@ -72,13 +99,19 @@ public interface DeleteQuery : _Query { override fun createQuery(internalQueries: _Query.Constructor.Scope, outQueries: _Query.Constructor.Scope): MultipleRows = outQueries.deleteMultipleRows(this) + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("targetTable") public val targetTable: Table public fun createMultipleRows(context: Scope): qUE public interface Scope { + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("tt") public val tt: Table + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("rowsToRemove") public val rowsToRemove: QueryParam, DatabaseType.ROW_ID, qUE> public fun ifNoRowSkip() diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/queries/InsertQuery.kt b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/queries/InsertQuery.kt index f515cf2..9f46869 100644 --- a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/queries/InsertQuery.kt +++ b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/queries/InsertQuery.kt @@ -1,5 +1,6 @@ package ru.landgrafhomyak.db.serdha0.api.queries +import kotlin.jvm.JvmName import ru.landgrafhomyak.db.serdha0.api.misc.Column import ru.landgrafhomyak.db.serdha0.api.table.Table import ru.landgrafhomyak.db.serdha0.api.misc.DatabaseType @@ -19,6 +20,8 @@ public interface InsertQuery : _Query { @Suppress("ClassName") public interface _CommonInsertCreatorScope { + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("types") public val types: DatabaseType.Provider public fun onConflictUpdate(u: UniqueIndex, c: (_UpsertClauseScope) -> Unit) @@ -32,11 +35,15 @@ public interface InsertQuery : _Query { override fun createQuery(internalQueries: _Query.Constructor.Scope, outQueries: _Query.Constructor.Scope): SingleRow = outQueries.insertSingleRow(this) + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("targetTable") public val targetTable: Table public fun createInsertSingleRowWithReturning(context: Scope): qUE public interface Scope : _CommonInsertCreatorScope { + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("tt") public val tt: Table public fun > queryParam(name: String, type: DT): QueryParam @@ -58,17 +65,28 @@ public interface InsertQuery : _Query { override fun createQuery(internalQueries: _Query.Constructor.Scope, outQueries: _Query.Constructor.Scope): FromSubquery = outQueries.insertFromSubquery(this) + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("targetTable") public val targetTable: Table + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("selector") public val selector: _Selectable public fun createInsertSingleRowWithReturning(context: Scope): qUE public interface Scope : _CommonInsertCreatorScope { + + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("tt") public val tt: Table + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("src") public val src: _Selectable public fun > queryParam(name: String, type: DT): QueryParam + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("sourceQueryParams") public val sourceQueryParams: InputRow.WithRedirect public fun > insertConstant(dst: Column, src: RT) @@ -89,10 +107,14 @@ public interface InsertQuery : _Query { override fun createQuery(internalQueries: _Query.Constructor.Scope, outQueries: _Query.Constructor.Scope): MultipleRows = outQueries.insertMultipleRows(this) + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("targetTable") public val targetTable: Table public fun createInsertMultipleRows(context: Scope): qUE public interface Scope : _CommonInsertCreatorScope { + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("tt") public val tt: Table public fun > inputColumn(name: String, type: DT): QueryParam diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/queries/SelectQuery.kt b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/queries/SelectQuery.kt index 16ebe1c..da6fea6 100644 --- a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/queries/SelectQuery.kt +++ b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/queries/SelectQuery.kt @@ -1,5 +1,7 @@ package ru.landgrafhomyak.db.serdha0.api.queries +import kotlin.jvm.JvmField +import kotlin.jvm.JvmName import ru.landgrafhomyak.db.serdha0.api.misc.Column import ru.landgrafhomyak.db.serdha0.api.misc.IntermediateColumn import ru.landgrafhomyak.db.serdha0.api.misc.DatabaseType @@ -17,7 +19,9 @@ public interface SelectQuery : _Query { public abstract class JoinType { public class LeftJoin( + @JvmField public val leftNull: Null, + @JvmField public val behaviour: Behaviour ) : JoinType() { @Suppress("ClassName") @@ -42,6 +46,8 @@ public interface SelectQuery : _Query { @Suppress("ClassName") public interface _CommonSelectCreatorScope { + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("types") public val types: DatabaseType.Provider public fun > queryParam(name: String, type: DT): QueryParam public fun > paramAsColumn(param: QueryParam): IntermediateColumn @@ -53,10 +59,19 @@ public interface SelectQuery : _Query { output: Mapper.OutputLinker ): oUE + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("filters") public val filters: FiltersScope public fun orderBy(order: Order, vararg column: IntermediateColumn<*, *, qUE>) + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("_getLimit") + @set:JvmName("limit") public var limit: UInt + + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("_getOffset") + @set:JvmName("offset") public var offset: ULong public fun > returnParam(name: String, param: QueryParam): Column @@ -68,12 +83,19 @@ public interface SelectQuery : _Query { override fun createQuery(internalQueries: _Query.Constructor.Scope, outQueries: _Query.Constructor.Scope): Simple = outQueries.select(this) + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("source") public val source: _Selectable public fun createSelect(context: Scope): qUE public interface Scope : _CommonSelectCreatorScope { + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("src") public val src: _Selectable + + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("subqueryParams") public val subqueryParams: InputRow.WithRedirect public fun > selectColumnFromSubquery(param: Column): IntermediateColumn @@ -86,19 +108,43 @@ public interface SelectQuery : _Query { override fun createQuery(internalQueries: _Query.Constructor.Scope, outQueries: _Query.Constructor.Scope): WithJoin = outQueries.selectWithJoin(this) + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("left") public val left: _Selectable + + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("right") public val right: _Selectable + + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("joinType") public val joinType: JoinType + + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("leftColumnToJoin") public val leftColumnToJoin: Column<*, *, lsqUE> + + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("rightColumnToJoin") public val rightColumnToJoin: Column<*, *, rsqUE> public fun createSelectWithJoin(context: Scope): qUE public interface Scope : _CommonSelectCreatorScope { + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("lsq") public val lsq: _Selectable + + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("rsq") public val rsq: _Selectable + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("leftSubqueryParams") public val leftSubqueryParams: InputRow.WithRedirect + + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("rightSubqueryParams") public val rightSubqueryParams: InputRow.WithRedirect public fun > selectColumnFromLeft(column: Column): IntermediateColumn @@ -113,12 +159,19 @@ public interface SelectQuery : _Query { override fun createQuery(internalQueries: _Query.Constructor.Scope, outQueries: _Query.Constructor.Scope): Reducing = outQueries.selectReducing(this) + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("source") public val source: _Selectable public fun createSelectWithReduce(context: Scope): qUE public interface Scope : _CommonSelectCreatorScope { + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("src") public val src: _Selectable + + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("sourceParams") public val sourceParams: InputRow.WithRedirect public fun > selectColumnFromSubquery(param: Column): IntermediateColumn @@ -139,12 +192,19 @@ public interface SelectQuery : _Query { override fun createQuery(internalQueries: _Query.Constructor.Scope, outQueries: _Query.Constructor.Scope): Folding = outQueries.selectFolding(this) + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("source") public val source: _Selectable public fun createSelectWithFold(context: Scope): qUE public interface Scope : _CommonSelectCreatorScope { + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("src") public val src: _Selectable + + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("sourceParams") public val sourceParams: InputRow.WithRedirect public fun > selectColumnFromSubquery(param: Column): IntermediateColumn @@ -166,16 +226,31 @@ public interface SelectQuery : _Query { override fun createQuery(internalQueries: _Query.Constructor.Scope, outQueries: _Query.Constructor.Scope): Union = outQueries.selectUnion(this) + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("first") public val first: _Selectable + + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("last") public val last: _Selectable public fun createSelectWithJoin(context: Scope): qUE public interface Scope : _CommonSelectCreatorScope { + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("fq") public val fq: _Selectable + + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("lq") public val lq: _Selectable + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("firstSubqueryParams") public val firstSubqueryParams: InputRow.WithRedirect + + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("lastSubqueryParams") public val lastSubqueryParams: InputRow.WithRedirect public fun > uniteColumns(first: Column, last: Column): IntermediateColumn diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/queries/UpdateQuery.kt b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/queries/UpdateQuery.kt index 6e30952..94ced29 100644 --- a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/queries/UpdateQuery.kt +++ b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/queries/UpdateQuery.kt @@ -1,5 +1,6 @@ package ru.landgrafhomyak.db.serdha0.api.queries +import kotlin.jvm.JvmName import ru.landgrafhomyak.db.serdha0.api.misc.Column import ru.landgrafhomyak.db.serdha0.api.table.Table import ru.landgrafhomyak.db.serdha0.api.misc.DatabaseType @@ -14,15 +15,23 @@ public interface UpdateQuery : _Query { override fun createQuery(internalQueries: _Query.Constructor.Scope, outQueries: _Query.Constructor.Scope): SingleRow = outQueries.updateSingleRow(this) + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("targetTable") public val targetTable: Table public fun createUpdateSingleWithReturning(context: Scope): qUE public interface Scope { + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("tt") public val tt: Table + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("types") public val types: DatabaseType.Provider public fun > queryParam(name: String, type: DT): QueryParam + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("rowToUpdate") public val rowToUpdate: QueryParam, DatabaseType.ROW_ID, qUE> public fun > updateColumnWithOldValue(dst: Column, src: Column) @@ -44,19 +53,37 @@ public interface UpdateQuery : _Query { override fun createQuery(internalQueries: _Query.Constructor.Scope, outQueries: _Query.Constructor.Scope): FromSubquery = outQueries.updateFromSubquery(this) + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("targetTable") public val targetTable: Table + + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("selector") public val selector: _Selectable public fun createUpdateFromSubqueryWithReturning(context: Scope): qUE public interface Scope { + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("tt") public val tt: Table + + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("src") public val src: _Selectable + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("types") public val types: DatabaseType.Provider public fun > queryParam(name: String, type: DT): QueryParam + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("selectorParams") public val selectorParams: InputRow.WithRedirect + + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("_getSelectorColumn") + @set:JvmName("selectorColumn") public var selectorColumn: Column, DatabaseType.ROW_ID, sUE> public fun > updateColumnWithSubquery(dst: Column, src: Column) @@ -80,15 +107,23 @@ public interface UpdateQuery : _Query { override fun createQuery(internalQueries: _Query.Constructor.Scope, outQueries: _Query.Constructor.Scope): MultipleRows = outQueries.updateMultipleRows(this) + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("targetTable") public val targetTable: Table public fun createUpdateMultipleRows(context: Scope): qUE public interface Scope { + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("tt") public val tt: Table + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("types") public val types: DatabaseType.Provider public fun > inputColumn(name: String, type: DT): QueryParam + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("rowToUpdate") public val rowToUpdate: QueryParam, DatabaseType.ROW_ID, qUE> public fun > updateColumnWithOldValue(dst: Column, src: Column) diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/queries/_Query.kt b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/queries/_Query.kt index 2264aa5..69bdb35 100644 --- a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/queries/_Query.kt +++ b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/queries/_Query.kt @@ -1,10 +1,13 @@ package ru.landgrafhomyak.db.serdha0.api.queries +import kotlin.jvm.JvmName import ru.landgrafhomyak.db.serdha0.api.misc._Selectable @Suppress("ClassName") public interface _Query { + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("uExt") public val uExt: qUE public interface Table2Void : _Query @@ -16,6 +19,8 @@ public interface _Query { public fun createQuery(internalQueries: Scope, outQueries: Scope): R public interface _SelectsScope { + @Suppress("INAPPLICABLE_JVM_NAME") + @JvmName("_composite") public operator fun invoke(constructor: Constructor): R public fun select(constructor: SelectQuery.Simple.Constructor): SelectQuery.Simple diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/runtime/DatabaseConnection.kt b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/runtime/DatabaseConnection.kt index e0ad970..24b995d 100644 --- a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/runtime/DatabaseConnection.kt +++ b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/runtime/DatabaseConnection.kt @@ -1,5 +1,6 @@ package ru.landgrafhomyak.db.serdha0.api.runtime +import kotlin.jvm.JvmName import ru.landgrafhomyak.db.serdha0.api.LowLevelApi import ru.landgrafhomyak.db.serdha0.api.module.Module import ru.landgrafhomyak.db.serdha0.api.module.ModuleTemplate @@ -18,7 +19,8 @@ public interface DatabaseConnection { @LowLevelApi public fun _finishSetup() - @Suppress("PropertyName") + @Suppress("PropertyName", "INAPPLICABLE_JVM_NAME") @LowLevelApi + @get:JvmName("_getExecutor") public val _executor: Executor } \ No newline at end of file diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/runtime/Executor.kt b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/runtime/Executor.kt index f6f7578..71ae93e 100644 --- a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/runtime/Executor.kt +++ b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/runtime/Executor.kt @@ -27,12 +27,6 @@ public interface Executor { @LowLevelApi public suspend fun _executeAutoTransactedQuery(compiledQuery: _Query.Params2Void): InputRow._Scope - public interface AtomicScript { - public suspend fun executeTransaction(transaction: Transaction, context: C, args: A): R - } - - public suspend fun transaction(script: AtomicScript, context: C, args: A): R - public fun mapOfRowIds( table: Table, builder: (MutableMap, V>) -> Unit diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/runtime/InputRow.kt b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/runtime/InputRow.kt index faee2ad..fa6b0bb 100644 --- a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/runtime/InputRow.kt +++ b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/runtime/InputRow.kt @@ -1,10 +1,13 @@ package ru.landgrafhomyak.db.serdha0.api.runtime +import kotlin.jvm.JvmName import ru.landgrafhomyak.db.serdha0.api.LowLevelApi import ru.landgrafhomyak.db.serdha0.api.misc.DatabaseType import ru.landgrafhomyak.db.serdha0.api.misc.QueryParam public interface InputRow { + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("uExt") public val uExt: qUE public operator fun set(c: QueryParam, value: RuntimeType) diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/runtime/OutputRow.kt b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/runtime/OutputRow.kt index 6dcfd04..812a816 100644 --- a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/runtime/OutputRow.kt +++ b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/runtime/OutputRow.kt @@ -1,9 +1,12 @@ package ru.landgrafhomyak.db.serdha0.api.runtime +import kotlin.jvm.JvmName import ru.landgrafhomyak.db.serdha0.api.LowLevelApi import ru.landgrafhomyak.db.serdha0.api.misc.Column public interface OutputRow { + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("uExt") public val uExt: qUE public operator fun get(c: Column): RuntimeType diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/table/CheckConstraint.kt b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/table/CheckConstraint.kt index 64a0e6a..c15adbd 100644 --- a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/table/CheckConstraint.kt +++ b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/table/CheckConstraint.kt @@ -1,7 +1,10 @@ package ru.landgrafhomyak.db.serdha0.api.table +import kotlin.jvm.JvmName import ru.landgrafhomyak.db.serdha0.api.misc.RowExpression public interface CheckConstraint : RowExpression { + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("getName") public val name: String } \ No newline at end of file diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/table/ForeignRowReference.kt b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/table/ForeignRowReference.kt index 972c1dc..8650234 100644 --- a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/table/ForeignRowReference.kt +++ b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/table/ForeignRowReference.kt @@ -4,47 +4,21 @@ import kotlin.jvm.JvmName import ru.landgrafhomyak.db.serdha0.api.misc.Column import ru.landgrafhomyak.db.serdha0.api.misc.DatabaseType -/** - * Descriptor of a reference to row in another table (== foreign key to `INTEGER PRIMARY KEY AUTOINCREMENT`). Used for schema manipulations. - * - * @param ctUE Type of [owner table's][ForeignRowReference.fromTable] user expression for static reporting errors when this descriptor passed to wrong table. - * @param ttUE Type of [target table's][ForeignRowReference.toTable] user expression for static reporting errors when this descriptor passed to wrong table. - */ public interface ForeignRowReference> : Column { - /** - * Table that contains references. For debugging. - */ @Suppress("INAPPLICABLE_JVM_NAME") @get:JvmName("fromTable") public val fromTable: Table - /** - * Table referenced by this foreign key. For debugging. - */ @Suppress("INAPPLICABLE_JVM_NAME") @get:JvmName("toTable") public val toTable: Table - /** - * Enum of actions to do when referenced row in [ForeignRowReference.toTable] deleted. - */ public enum class OnDelete { - /** - * Forbids deleting row in [ForeignRowReference.toTable] if there is at least one reference from [ForeignRowReference.fromTable]. - */ RESTRICT, - /** - * Replaces all references to deleted row in [ForeignRowReference.fromColumn] with `null`. - * - * Type of [ForeignRowReference.fromColumn] must be [nullable][DatabaseType.Builder.nullableOf]. - */ SET_NULL, - /** - * Deletes all rows in [ForeignRowReference.fromTable] that are referencing deleted row in [ForeignRowReference.toTable]. - */ CASCADE } } \ No newline at end of file diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/table/Index.kt b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/table/Index.kt index c12a878..f9594ad 100644 --- a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/table/Index.kt +++ b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/table/Index.kt @@ -3,30 +3,16 @@ package ru.landgrafhomyak.db.serdha0.api.table import kotlin.jvm.JvmName import ru.landgrafhomyak.db.serdha0.api.misc.Column -/** - * Descriptor of index. Used for schema manipulations. - * - * @param OwnerTableUserExtension Type of [owner table's][CheckConstraint.table] user expression for static reporting errors when this descriptor passed to wrong table. - */ public interface Index { - /** - * Name of index for debugging, errors and raw schema access. - */ @Suppress("INAPPLICABLE_JVM_NAME") - @get:JvmName("name") + @get:JvmName("getName") public val name: String - /** - * Table that contains this index. For debugging. - */ @Suppress("INAPPLICABLE_JVM_NAME") - @get:JvmName("table") + @get:JvmName("getTable") public val table: Table - /** - * Columns that are indexed by this index. For debugging. - */ @Suppress("INAPPLICABLE_JVM_NAME") - @get:JvmName("columns") + @get:JvmName("getColumns") public val columns: List> } \ No newline at end of file diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/table/Table.kt b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/table/Table.kt index d375c50..faba70b 100644 --- a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/table/Table.kt +++ b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/table/Table.kt @@ -1,19 +1,27 @@ package ru.landgrafhomyak.db.serdha0.api.table +import kotlin.jvm.JvmName import ru.landgrafhomyak.db.serdha0.api.misc._Selectable import ru.landgrafhomyak.db.serdha0.api.module.Module public interface Table : _Selectable { + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("uExt") public override val uExt: UE + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("getName") public val name: String + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("getModule") public val module: Module<*> public enum class TemporaryType { TRANSACTION_SCOPE, - CONNECTION_SCOPE + CONNECTION_SCOPE, + MODULE_UPGRADE_SCOPE } + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("getTemporaryType") public val temporaryType: TemporaryType? - - public val namespacesFromModuleRoot: List } \ No newline at end of file diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/table/TableConstructor.kt b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/table/TableConstructor.kt index 3dfac6d..967499a 100644 --- a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/table/TableConstructor.kt +++ b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/table/TableConstructor.kt @@ -1,5 +1,6 @@ package ru.landgrafhomyak.db.serdha0.api.table +import kotlin.jvm.JvmName import ru.landgrafhomyak.db.serdha0.api.misc.Column import ru.landgrafhomyak.db.serdha0.api.misc.DatabaseType import ru.landgrafhomyak.db.serdha0.api.misc.RowExpression @@ -10,6 +11,9 @@ public interface TableConstructor { public interface Scope { + + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("types") public val types: DatabaseType.Provider public fun > column(name: String, type: DT): Column @@ -21,6 +25,8 @@ public interface TableConstructor { public fun > defaultValue(c: Column, value: RT): ColumnDefaultValue public fun > defaultValue(c: Column, creator: RowExpression.Constructor): ColumnDefaultValue + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("rowIdColumn") public val rowIdColumn: Column, DatabaseType.ROW_ID, tUE> public fun selfRowReference( diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/table/UniqueIndex.kt b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/table/UniqueIndex.kt index 2f58e41..8048708 100644 --- a/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/table/UniqueIndex.kt +++ b/src/commonMain/kotlin/ru/landgrafhomyak/db/serdha0/api/table/UniqueIndex.kt @@ -1,5 +1,9 @@ package ru.landgrafhomyak.db.serdha0.api.table +import kotlin.jvm.JvmName + public interface UniqueIndex : Index { + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("areNullsDistinct") public val areNullsDistinct: Boolean } \ No newline at end of file