Strict properties mangling rules for JVM targets

This commit is contained in:
Andrew Golovashevich 2025-02-23 14:00:58 +03:00
parent 757a8442f2
commit d8804c0efc
29 changed files with 318 additions and 278 deletions

View File

@ -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<RT, DT : DatabaseType<RT>, TableUserExtension : Any> {
/**
* Name of column for debugging, errors and raw schema access.
*/
public interface Column<RT, DT : DatabaseType<RT>, 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<TableUserExtension, *>
@Suppress("INAPPLICABLE_JVM_NAME", "PropertyName")
@get:JvmName("_getOwner")
public val _owner: _Selectable<tUE>
}

View File

@ -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<RT, wRT, wDT : DatabaseType<wRT>>(
@ -41,27 +36,20 @@ public interface DatabaseType<@Suppress("unused") RT> {
public interface BOOLEAN : DatabaseType<Boolean>
/**
* Descriptor of a raw binary data type for static type-checking.
* @see DatabaseType.Provider.BINARY_DATA
*/
@OptIn(ExperimentalUnsignedTypes::class)
public interface BINARY_DATA : DatabaseType<UByteArray> {
/**
* 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 <TableUserExtension : Any> ROW_ID(table: Table<TableUserExtension, *>): DatabaseType.ROW_ID<TableUserExtension>
public fun <tUE : Any> ROW_ID(table: Table<tUE, *>): DatabaseType.ROW_ID<tUE>
@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 <RT : Any, DT : DatabaseType<RT>> nullableOf(notNull: DT): Nullable<RT, DT>
}
}

View File

@ -2,9 +2,10 @@ package ru.landgrafhomyak.db.serdha0.api.misc
public interface FiltersScope<oqUE : Any> {
public fun <RT : Any, DT : DatabaseType<RT>> filterNotNull(nullable: IntermediateColumn<RT?, DatabaseType.Nullable<RT, DT>, oqUE>): IntermediateColumn<RT, DT, oqUE>
public fun <RT : Any, DT : DatabaseType<RT>> filterIsNull(nullable: IntermediateColumn<RT?, DatabaseType.Nullable<RT, DT>, oqUE>)
public enum class ComparisonType {
public enum class ComparisonOperator {
EQUALS,
NOT_EQUALS,
LESS,
@ -13,8 +14,11 @@ public interface FiltersScope<oqUE : Any> {
GREATER_OR_EQUALS,
}
public fun <RT, DT : DatabaseType<RT>> compareWithParam(column: IntermediateColumn<RT, DT, oqUE>, operator: ComparisonType, param: QueryParam<RT, DT, oqUE>)
public fun <RT, DT : DatabaseType<RT>> compareWithConstant(column: IntermediateColumn<RT, DT, oqUE>, operator: ComparisonType, constant: RT)
public fun <RT, DT : DatabaseType<RT>> compareWithParam(column: IntermediateColumn<RT, DT, oqUE>, operator: ComparisonOperator, param: QueryParam<RT, DT, oqUE>)
public fun <RT, DT : DatabaseType<RT>> compareWithConstant(column: IntermediateColumn<RT, DT, oqUE>, operator: ComparisonOperator, constant: RT)
public fun ifTrue(column: IntermediateColumn<Boolean, DatabaseType.BOOLEAN, oqUE>)
public fun ifFalse(column: IntermediateColumn<Boolean, DatabaseType.BOOLEAN, oqUE>)
}

View File

@ -1,5 +1,3 @@
package ru.landgrafhomyak.db.serdha0.api.misc
public interface IntermediateColumn<RT, DT : DatabaseType<RT>, OwnerBuilderUserExtension : Any> {
}
public interface IntermediateColumn<RT, DT : DatabaseType<RT>, OwnerBuilderUserExtension : Any>

View File

@ -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<mUE : Any> {
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("uExt")
public val uExt: mUE
public interface InputColumn<RT, DT : DatabaseType<RT>, mUE : Any> : Column<RT, DT, mUE>
@ -12,18 +15,24 @@ public interface Mapper<mUE : Any> {
public fun interface InputLinker<mUE : Any, qUE : Any> {
public fun link(linker: Scope<mUE, qUE>)
public interface Scope<_mUE : Any, qUE : Any> {
public val mUE: _mUE
public operator fun <RT, DT : DatabaseType<RT>> set(p: InputColumn<RT, DT, _mUE>, e: IntermediateColumn<RT, DT, qUE>)
public interface Scope<mUE : Any, qUE : Any> {
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("uExt")
public val uExt: mUE
public operator fun <RT, DT : DatabaseType<RT>> set(p: InputColumn<RT, DT, mUE>, e: IntermediateColumn<RT, DT, qUE>)
}
}
public fun interface OutputLinker<mUE : Any, qUE : Any, oUE : Any> {
public fun link(linker: Scope<mUE, qUE>): oUE
public interface Scope<_mUE : Any, qUE : Any> {
public val mUE: _mUE
public operator fun <RT, DT : DatabaseType<RT>> get(p: OutputColumn<RT, DT, _mUE>): IntermediateColumn<RT, DT, qUE>
public interface Scope<mUE : Any, qUE : Any> {
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("uExt")
public val uExt: mUE
public operator fun <RT, DT : DatabaseType<RT>> get(p: OutputColumn<RT, DT, mUE>): IntermediateColumn<RT, DT, qUE>
}
}
@ -31,8 +40,12 @@ public interface Mapper<mUE : Any> {
public fun createMapper(context: Scope<mUE>): Action<mUE>
public interface Scope<mUE : Any> {
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("types")
public val types: DatabaseType.Provider
public fun <RT, DT : DatabaseType<RT>> input(name: String, type: DT): InputColumn<RT, DT, mUE>
public fun <RT, DT : DatabaseType<RT>> output(name: String, type: DT): OutputColumn<RT, DT, mUE>
}
}

View File

@ -1,7 +1,13 @@
package ru.landgrafhomyak.db.serdha0.api.misc
public interface QueryParam<RT, DT : DatabaseType<RT>, OwnerQueryUserExtension : Any> {
import kotlin.jvm.JvmName
public interface QueryParam<RT, DT : DatabaseType<RT>, 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
}

View File

@ -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<rUE : Any> {
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("uExt")
public val uExt: rUE
public interface BidirectionalColumn<RT, DT : DatabaseType<RT>, rUE : Any> : Column<RT, DT, rUE>, QueryParam<RT, DT, rUE>
@ -14,7 +18,10 @@ public interface Reducer<rUE : Any> {
public fun link(linker: Scope<_rUE, qUE>): oUE
public interface Scope<rUE : Any, qUE : Any> {
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("uExt")
public val uExt: rUE
public fun <RT, DT : DatabaseType<RT>> link(red: BidirectionalColumn<RT, DT, rUE>, src: IntermediateColumn<RT, DT, qUE>): IntermediateColumn<RT, DT, qUE>
public fun <RT, DT : DatabaseType<RT>> linkAndInitialize(red: BidirectionalColumn<RT, DT, rUE>, src: IntermediateColumn<RT, DT, qUE>, initial: RT): IntermediateColumn<RT, DT, qUE>
public fun <RT, DT : DatabaseType<RT>> linkAndInitialize(red: BidirectionalColumn<RT, DT, rUE>, src: IntermediateColumn<RT, DT, qUE>, initial: QueryParam<RT, DT, qUE>): IntermediateColumn<RT, DT, qUE>
@ -28,7 +35,10 @@ public interface Reducer<rUE : Any> {
public fun createReducer(context: Scope<rUE>): Action<rUE>
public interface Scope<rUE : Any> {
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("types")
public val types: DatabaseType.Provider
public fun <RT, DT : DatabaseType<RT>> outputColumn(name: String, type: DT): OutputColumn<RT, DT, rUE>
public fun <RT, DT : DatabaseType<RT>> outputColumn(name: String, type: DT, defaultInitialValue: RT): OutputColumn<RT, DT, rUE>
public fun <RT, DT : DatabaseType<RT>> bidirectionalColumn(name: String, type: DT): BidirectionalColumn<RT, DT, rUE>

View File

@ -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<ttUE : Any, @Suppress("unused") R> {
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("getTargetTable")
public val targetTable: Table<ttUE, *>
public interface RowExportsConstructor<rUE : Any, ttUE : Any> {
public fun createRowExports(context: Scope<rUE, ttUE>): rUE
public interface Scope<rUE : Any, ttUE : Any> {
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("tt")
public val tt: Table<ttUE, *>
public fun <RT, DT : DatabaseType<RT>> selectFromTargetTable(column: Column<RT, DT, ttUE>): Column<RT, DT, rUE>
@ -30,6 +35,8 @@ public interface RowExpression<ttUE : Any, @Suppress("unused") R> {
}
public interface Constructor<ttUE : Any, rUE : Any, R> {
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("rowExports")
public val rowExports: RowExportsConstructor<rUE, ttUE>
public fun createRowExpression(internalQueries: _Query.Constructor._SelectsScope, runtimeQueries: _Query.Constructor._SelectsScope): Action<rUE, R>

View File

@ -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<out UE : Any> {
/**
* 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
}

View File

@ -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 <tUE : Any> createTable(namespace: Namespace = this.rootNs, name: String, initializer: TableConstructor<tUE>): Table<tUE, Nothing>
/**
* 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 <tUE : Any> createSessionScopeTemporaryTable(namespace: Namespace = this.rootNs, name: String, initializer: TableConstructor<tUE>): Table<tUE, Nothing>
/**
* 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 <tUE : Any> createTransactionScopeTemporaryTable(namespace: Namespace = this.rootNs, name: String, initializer: TableConstructor<tUE>): Table<tUE, Nothing>
public fun <tUE : Any> createModuleConfiguringScopeTemporaryTable(namespace: Namespace = this.rootNs, name: String, initializer: TableConstructor<tUE>): Table<tUE, Nothing>
@ -61,13 +25,5 @@ public interface CreateModuleScope {
public fun <R : Any> createModuleConfiguringScopeTemporaryQuery(creator: _Query.Constructor<R>): 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 <mUE : Any> substituteModule(rootNs: Namespace, template: ModuleTemplate<mUE>): Module<mUE>
}

View File

@ -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<mUE : Any> {
/**
* 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 <R : Any> createQuery(c: _Query.Constructor<R>): R
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("executor")
public val executor: Executor
}

View File

@ -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<mUE : Any> {
@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<omUE : Any, nmUE : Any> {
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("versionKey")
public val versionKey: String
public fun upgradeSchema(context: UpgradeModuleScope<omUE>): 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
}

View File

@ -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<String>
@Suppress("INAPPLICABLE_JVM_NAME", "PropertyName")
@get:JvmName("_getPath")
public val _path: List<String>
}

View File

@ -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<omUE : Any> : 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<tnUE : Any, toUE : Any> {
/**
* 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<toUE, *>, upgrade: TableUpgrade<tnUE, toUE>): 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 <tUE : Any> keepTable(
table: Table<tUE, *>,
): Table<tUE, *>
/**
* 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 <tUE : Any> renameTable(
table: Table<tUE, *>,
newNamespace: Namespace? = null,
newName: String? = null
): Table<tUE, *>
/**
* 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 <tnUE : Any, toUE : Any> upgradeTable(
oldTable: Table<toUE, *>,
upgrade: TableUpgrade<tnUE, toUE>
): Table<tnUE, toUE>
/**
* 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 <tnUE : Any, toUE : Any> upgradeAndRenameTable(
oldTable: Table<tnUE, toUE>,
newNamespace: Namespace? = null,
@ -103,49 +38,11 @@ public interface UpgradeModuleScope<omUE : Any> : CreateModuleScope {
upgrade: TableUpgrade<tnUE, toUE>
): Table<tnUE, toUE>
/**
* 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 <tUE : Any> createModuleUpgradeScopeTemporaryTable(namespace: Namespace, name: String, initializer: TableConstructor<tUE>): Table<tUE, Nothing>
/**
* 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 <smUE : Any> upgradeModule(oldModule: Module<*>, rootNs: Namespace, template: ModuleTemplate<smUE>): Module<smUE>
}

View File

@ -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<out qUE : Any> : _Query<qUE> {
override fun createQuery(internalQueries: _Query.Constructor.Scope, outQueries: _Query.Constructor.Scope): SingleRow<qUE> =
outQueries.deleteSingleRow(this)
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("targetTable")
public val targetTable: Table<ttUE, *>
public fun createDeleteSingleRowWithReturning(context: Scope<qUE, ttUE>): qUE
public interface Scope<qUE : Any, ttUE : Any> {
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("tt")
public val tt: Table<ttUE, *>
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("types")
public val types: DatabaseType.Provider
public fun <RT, DT : DatabaseType<RT>> queryParam(name: String, type: DT): QueryParam<RT, DT, qUE>
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("rowToRemove")
public val rowToRemove: QueryParam<RowId<ttUE>, DatabaseType.ROW_ID<ttUE>, qUE>
public fun <RT, DT : DatabaseType<RT>> returnRemovedValue(name: String, column: Column<RT, DT, ttUE>): Column<RT, DT, qUE>
@ -41,19 +50,37 @@ public interface DeleteQuery<out qUE : Any> : _Query<qUE> {
override fun createQuery(internalQueries: _Query.Constructor.Scope, outQueries: _Query.Constructor.Scope): FromSubquery<qUE> =
outQueries.deleteFromSubquery(this)
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("rowToRemove")
public val targetTable: Table<ttUE, *>
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("selector")
public val selector: _Selectable<sUE>
public fun createDeleteFromSubqueryWithReturning(context: Scope<qUE, ttUE, sUE>): qUE
public interface Scope<qUE : Any, ttUE : Any, sUE : Any> {
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("tt")
public val tt: Table<ttUE, *>
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("src")
public val src: _Selectable<sUE>
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("types")
public val types: DatabaseType.Provider
public fun <RT, DT : DatabaseType<RT>> queryParam(name: String, type: DT): QueryParam<RT, DT, qUE>
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("selectorParams")
public val selectorParams: InputRow.WithRedirect<sUE, qUE>
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("_getSelectorColumn")
@set:JvmName("selectorColumn")
public var selectorColumn: Column<RowId<ttUE>, DatabaseType.ROW_ID<ttUE>, sUE>
public fun <RT, DT : DatabaseType<RT>> returnFromSubquery(name: String, column: Column<RT, DT, sUE>): Column<RT, DT, qUE>
@ -72,13 +99,19 @@ public interface DeleteQuery<out qUE : Any> : _Query<qUE> {
override fun createQuery(internalQueries: _Query.Constructor.Scope, outQueries: _Query.Constructor.Scope): MultipleRows<qUE> =
outQueries.deleteMultipleRows(this)
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("targetTable")
public val targetTable: Table<ttUE, *>
public fun createMultipleRows(context: Scope<qUE, ttUE>): qUE
public interface Scope<qUE : Any, ttUE : Any> {
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("tt")
public val tt: Table<ttUE, *>
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("rowsToRemove")
public val rowsToRemove: QueryParam<RowId<ttUE>, DatabaseType.ROW_ID<ttUE>, qUE>
public fun ifNoRowSkip()

View File

@ -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<out qUE : Any> : _Query<qUE> {
@Suppress("ClassName")
public interface _CommonInsertCreatorScope<qUE : Any, ttUE : Any> {
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("types")
public val types: DatabaseType.Provider
public fun onConflictUpdate(u: UniqueIndex<ttUE>, c: (_UpsertClauseScope<qUE, ttUE>) -> Unit)
@ -32,11 +35,15 @@ public interface InsertQuery<out qUE : Any> : _Query<qUE> {
override fun createQuery(internalQueries: _Query.Constructor.Scope, outQueries: _Query.Constructor.Scope): SingleRow<qUE> =
outQueries.insertSingleRow(this)
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("targetTable")
public val targetTable: Table<ttUE, *>
public fun createInsertSingleRowWithReturning(context: Scope<qUE, ttUE>): qUE
public interface Scope<qUE : Any, ttUE : Any> : _CommonInsertCreatorScope<qUE, ttUE> {
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("tt")
public val tt: Table<ttUE, *>
public fun <RT, DT : DatabaseType<RT>> queryParam(name: String, type: DT): QueryParam<RT, DT, qUE>
@ -58,17 +65,28 @@ public interface InsertQuery<out qUE : Any> : _Query<qUE> {
override fun createQuery(internalQueries: _Query.Constructor.Scope, outQueries: _Query.Constructor.Scope): FromSubquery<qUE> =
outQueries.insertFromSubquery(this)
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("targetTable")
public val targetTable: Table<ttUE, *>
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("selector")
public val selector: _Selectable<sUE>
public fun createInsertSingleRowWithReturning(context: Scope<qUE, ttUE, sUE>): qUE
public interface Scope<qUE : Any, ttUE : Any, sUE : Any> : _CommonInsertCreatorScope<qUE, ttUE> {
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("tt")
public val tt: Table<ttUE, *>
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("src")
public val src: _Selectable<sUE>
public fun <RT, DT : DatabaseType<RT>> queryParam(name: String, type: DT): QueryParam<RT, DT, qUE>
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("sourceQueryParams")
public val sourceQueryParams: InputRow.WithRedirect<sUE, qUE>
public fun <RT, DT : DatabaseType<RT>> insertConstant(dst: Column<RT, DT, ttUE>, src: RT)
@ -89,10 +107,14 @@ public interface InsertQuery<out qUE : Any> : _Query<qUE> {
override fun createQuery(internalQueries: _Query.Constructor.Scope, outQueries: _Query.Constructor.Scope): MultipleRows<qUE> =
outQueries.insertMultipleRows(this)
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("targetTable")
public val targetTable: Table<ttUE, *>
public fun createInsertMultipleRows(context: Scope<qUE, ttUE>): qUE
public interface Scope<qUE : Any, ttUE : Any> : _CommonInsertCreatorScope<qUE, ttUE> {
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("tt")
public val tt: Table<ttUE, *>
public fun <RT, DT : DatabaseType<RT>> inputColumn(name: String, type: DT): QueryParam<RT, DT, qUE>

View File

@ -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<out qUE : Any> : _Query<qUE> {
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<out qUE : Any> : _Query<qUE> {
@Suppress("ClassName")
public interface _CommonSelectCreatorScope<qUE : Any> {
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("types")
public val types: DatabaseType.Provider
public fun <RT, DT : DatabaseType<RT>> queryParam(name: String, type: DT): QueryParam<RT, DT, qUE>
public fun <RT, DT : DatabaseType<RT>> paramAsColumn(param: QueryParam<RT, DT, qUE>): IntermediateColumn<RT, DT, qUE>
@ -53,10 +59,19 @@ public interface SelectQuery<out qUE : Any> : _Query<qUE> {
output: Mapper.OutputLinker<mUE, qUE, oUE>
): oUE
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("filters")
public val filters: FiltersScope<qUE>
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 <RT, DT : DatabaseType<RT>> returnParam(name: String, param: QueryParam<RT, DT, qUE>): Column<RT, DT, qUE>
@ -68,12 +83,19 @@ public interface SelectQuery<out qUE : Any> : _Query<qUE> {
override fun createQuery(internalQueries: _Query.Constructor.Scope, outQueries: _Query.Constructor.Scope): Simple<qUE> =
outQueries.select(this)
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("source")
public val source: _Selectable<tUE>
public fun createSelect(context: Scope<qUE, tUE>): qUE
public interface Scope<qUE : Any, tUE : Any> : _CommonSelectCreatorScope<qUE> {
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("src")
public val src: _Selectable<tUE>
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("subqueryParams")
public val subqueryParams: InputRow.WithRedirect<tUE, qUE>
public fun <RT, DT : DatabaseType<RT>> selectColumnFromSubquery(param: Column<RT, DT, tUE>): IntermediateColumn<RT, DT, qUE>
@ -86,19 +108,43 @@ public interface SelectQuery<out qUE : Any> : _Query<qUE> {
override fun createQuery(internalQueries: _Query.Constructor.Scope, outQueries: _Query.Constructor.Scope): WithJoin<qUE> =
outQueries.selectWithJoin(this)
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("left")
public val left: _Selectable<lsqUE>
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("right")
public val right: _Selectable<rsqUE>
@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, lsqUE, rsqUE>): qUE
public interface Scope<qUE : Any, lsqUE : Any, rsqUE : Any> : _CommonSelectCreatorScope<qUE> {
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("lsq")
public val lsq: _Selectable<lsqUE>
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("rsq")
public val rsq: _Selectable<rsqUE>
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("leftSubqueryParams")
public val leftSubqueryParams: InputRow.WithRedirect<lsqUE, qUE>
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("rightSubqueryParams")
public val rightSubqueryParams: InputRow.WithRedirect<rsqUE, qUE>
public fun <RT, DT : DatabaseType<RT>> selectColumnFromLeft(column: Column<RT, DT, lsqUE>): IntermediateColumn<RT, DT, qUE>
@ -113,12 +159,19 @@ public interface SelectQuery<out qUE : Any> : _Query<qUE> {
override fun createQuery(internalQueries: _Query.Constructor.Scope, outQueries: _Query.Constructor.Scope): Reducing<qUE> =
outQueries.selectReducing(this)
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("source")
public val source: _Selectable<tUE>
public fun createSelectWithReduce(context: Scope<qUE, tUE>): qUE
public interface Scope<qUE : Any, tUE : Any> : _CommonSelectCreatorScope<qUE> {
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("src")
public val src: _Selectable<tUE>
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("sourceParams")
public val sourceParams: InputRow.WithRedirect<tUE, qUE>
public fun <RT, DT : DatabaseType<RT>> selectColumnFromSubquery(param: Column<RT, DT, tUE>): IntermediateColumn<RT, DT, qUE>
@ -139,12 +192,19 @@ public interface SelectQuery<out qUE : Any> : _Query<qUE> {
override fun createQuery(internalQueries: _Query.Constructor.Scope, outQueries: _Query.Constructor.Scope): Folding<qUE> =
outQueries.selectFolding(this)
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("source")
public val source: _Selectable<tUE>
public fun createSelectWithFold(context: Scope<qUE, tUE>): qUE
public interface Scope<qUE : Any, tUE : Any> : _CommonSelectCreatorScope<qUE> {
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("src")
public val src: _Selectable<tUE>
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("sourceParams")
public val sourceParams: InputRow.WithRedirect<tUE, qUE>
public fun <RT, DT : DatabaseType<RT>> selectColumnFromSubquery(param: Column<RT, DT, tUE>): IntermediateColumn<RT, DT, qUE>
@ -166,16 +226,31 @@ public interface SelectQuery<out qUE : Any> : _Query<qUE> {
override fun createQuery(internalQueries: _Query.Constructor.Scope, outQueries: _Query.Constructor.Scope): Union<qUE> =
outQueries.selectUnion(this)
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("first")
public val first: _Selectable<fqUE>
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("last")
public val last: _Selectable<lqUE>
public fun createSelectWithJoin(context: Scope<qUE, fqUE, lqUE>): qUE
public interface Scope<qUE : Any, fqUE : Any, lqUE : Any> : _CommonSelectCreatorScope<qUE> {
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("fq")
public val fq: _Selectable<fqUE>
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("lq")
public val lq: _Selectable<lqUE>
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("firstSubqueryParams")
public val firstSubqueryParams: InputRow.WithRedirect<fqUE, qUE>
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("lastSubqueryParams")
public val lastSubqueryParams: InputRow.WithRedirect<lqUE, qUE>
public fun <RT, DT : DatabaseType<RT>> uniteColumns(first: Column<RT, DT, fqUE>, last: Column<RT, DT, lqUE>): IntermediateColumn<RT, DT, qUE>

View File

@ -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<out qUE : Any> : _Query<qUE> {
override fun createQuery(internalQueries: _Query.Constructor.Scope, outQueries: _Query.Constructor.Scope): SingleRow<qUE> =
outQueries.updateSingleRow(this)
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("targetTable")
public val targetTable: Table<ttUE, *>
public fun createUpdateSingleWithReturning(context: Scope<qUE, ttUE>): qUE
public interface Scope<qUE : Any, ttUE : Any> {
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("tt")
public val tt: Table<ttUE, *>
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("types")
public val types: DatabaseType.Provider
public fun <RT, DT : DatabaseType<RT>> queryParam(name: String, type: DT): QueryParam<RT, DT, qUE>
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("rowToUpdate")
public val rowToUpdate: QueryParam<RowId<ttUE>, DatabaseType.ROW_ID<ttUE>, qUE>
public fun <RT, DT : DatabaseType<RT>> updateColumnWithOldValue(dst: Column<RT, DT, ttUE>, src: Column<RT, DT, ttUE>)
@ -44,19 +53,37 @@ public interface UpdateQuery<out qUE : Any> : _Query<qUE> {
override fun createQuery(internalQueries: _Query.Constructor.Scope, outQueries: _Query.Constructor.Scope): FromSubquery<qUE> =
outQueries.updateFromSubquery(this)
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("targetTable")
public val targetTable: Table<ttUE, *>
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("selector")
public val selector: _Selectable<sUE>
public fun createUpdateFromSubqueryWithReturning(context: Scope<qUE, ttUE, sUE>): qUE
public interface Scope<qUE : Any, ttUE : Any, sUE : Any> {
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("tt")
public val tt: Table<ttUE, *>
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("src")
public val src: _Selectable<sUE>
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("types")
public val types: DatabaseType.Provider
public fun <RT, DT : DatabaseType<RT>> queryParam(name: String, type: DT): QueryParam<RT, DT, qUE>
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("selectorParams")
public val selectorParams: InputRow.WithRedirect<sUE, qUE>
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("_getSelectorColumn")
@set:JvmName("selectorColumn")
public var selectorColumn: Column<RowId<ttUE>, DatabaseType.ROW_ID<ttUE>, sUE>
public fun <RT, DT : DatabaseType<RT>> updateColumnWithSubquery(dst: Column<RT, DT, ttUE>, src: Column<RT, DT, sUE>)
@ -80,15 +107,23 @@ public interface UpdateQuery<out qUE : Any> : _Query<qUE> {
override fun createQuery(internalQueries: _Query.Constructor.Scope, outQueries: _Query.Constructor.Scope): MultipleRows<qUE> =
outQueries.updateMultipleRows(this)
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("targetTable")
public val targetTable: Table<ttUE, *>
public fun createUpdateMultipleRows(context: Scope<qUE, ttUE>): qUE
public interface Scope<qUE : Any, ttUE : Any> {
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("tt")
public val tt: Table<ttUE, *>
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("types")
public val types: DatabaseType.Provider
public fun <RT, DT : DatabaseType<RT>> inputColumn(name: String, type: DT): QueryParam<RT, DT, qUE>
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("rowToUpdate")
public val rowToUpdate: QueryParam<RowId<ttUE>, DatabaseType.ROW_ID<ttUE>, qUE>
public fun <RT, DT : DatabaseType<RT>> updateColumnWithOldValue(dst: Column<RT, DT, ttUE>, src: Column<RT, DT, ttUE>)

View File

@ -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<out qUE : Any> {
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("uExt")
public val uExt: qUE
public interface Table2Void<out qUE : Any> : _Query<qUE>
@ -16,6 +19,8 @@ public interface _Query<out qUE : Any> {
public fun createQuery(internalQueries: Scope, outQueries: Scope): R
public interface _SelectsScope {
@Suppress("INAPPLICABLE_JVM_NAME")
@JvmName("_composite")
public operator fun <R> invoke(constructor: Constructor<R>): R
public fun <qUE : Any, sqUE : Any> select(constructor: SelectQuery.Simple.Constructor<qUE, sqUE>): SelectQuery.Simple<qUE>

View File

@ -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
}

View File

@ -27,12 +27,6 @@ public interface Executor {
@LowLevelApi
public suspend fun <QueryUserExtension : Any> _executeAutoTransactedQuery(compiledQuery: _Query.Params2Void<QueryUserExtension>): InputRow._Scope<QueryUserExtension, Unit>
public interface AtomicScript<C, A, R> {
public suspend fun executeTransaction(transaction: Transaction, context: C, args: A): R
}
public suspend fun <C, A, R> transaction(script: AtomicScript<C, A, R>, context: C, args: A): R
public fun <TableUserException : Any, V> mapOfRowIds(
table: Table<TableUserException, *>,
builder: (MutableMap<OutputRow<TableUserException>, V>) -> Unit

View File

@ -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<qUE : Any> {
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("uExt")
public val uExt: qUE
public operator fun <RuntimeType> set(c: QueryParam<RuntimeType, *, qUE>, value: RuntimeType)

View File

@ -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<qUE : Any> {
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("uExt")
public val uExt: qUE
public operator fun <RuntimeType> get(c: Column<RuntimeType, *, qUE>): RuntimeType

View File

@ -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<ttUE : Any> : RowExpression<ttUE, Boolean> {
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("getName")
public val name: String
}

View File

@ -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<ctUE : Any, ttUE : Any, RT, DT : DatabaseType<RT>> : Column<RT, DT, ctUE> {
/**
* Table that contains references. For debugging.
*/
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("fromTable")
public val fromTable: Table<ctUE, *>
/**
* Table referenced by this foreign key. For debugging.
*/
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("toTable")
public val toTable: Table<ttUE, *>
/**
* 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
}
}

View File

@ -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<OwnerTableUserExtension : Any> {
/**
* 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<OwnerTableUserExtension, *>
/**
* Columns that are indexed by this index. For debugging.
*/
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("columns")
@get:JvmName("getColumns")
public val columns: List<Column<*, *, OwnerTableUserExtension>>
}

View File

@ -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<out UE : Any, pUE : Any> : _Selectable<UE> {
@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<String>
}

View File

@ -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<tUE : Any> {
public interface Scope<tUE : Any> {
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("types")
public val types: DatabaseType.Provider
public fun <RT, DT : DatabaseType<RT>> column(name: String, type: DT): Column<RT, DT, tUE>
@ -21,6 +25,8 @@ public interface TableConstructor<tUE : Any> {
public fun <RT : Any, DT : DatabaseType<RT>> defaultValue(c: Column<RT, DT, tUE>, value: RT): ColumnDefaultValue<tUE, RT>
public fun <RT : Any, DT : DatabaseType<RT>> defaultValue(c: Column<RT, DT, tUE>, creator: RowExpression.Constructor<tUE, *, RT>): ColumnDefaultValue<tUE, RT>
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("rowIdColumn")
public val rowIdColumn: Column<RowId<tUE>, DatabaseType.ROW_ID<tUE>, tUE>
public fun selfRowReference(

View File

@ -1,5 +1,9 @@
package ru.landgrafhomyak.db.serdha0.api.table
import kotlin.jvm.JvmName
public interface UniqueIndex<OwnerTableUserExtension : Any> : Index<OwnerTableUserExtension> {
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("areNullsDistinct")
public val areNullsDistinct: Boolean
}