From d0f5bd838632618193a61ea7dffb91881bd9585d Mon Sep 17 00:00:00 2001 From: Andrew Golovashevich Date: Fri, 31 Jan 2025 22:51:00 +0300 Subject: [PATCH] [history/serdha] Renaming '*Creator' -> '*Constructor' --- .../serdha0/api/module/CreateModuleScope.kt | 46 ++++------------ .../serdha0/api/table/CreateTableScope.kt | 46 ---------------- .../serdha0/api/table/TableConstructor.kt | 52 +++++++++++++++++++ 3 files changed, 62 insertions(+), 82 deletions(-) delete mode 100644 src/commonMain/kotlin/ru/landgrafhomyak/serdha0/api/table/CreateTableScope.kt create mode 100644 src/commonMain/kotlin/ru/landgrafhomyak/serdha0/api/table/TableConstructor.kt diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/serdha0/api/module/CreateModuleScope.kt b/src/commonMain/kotlin/ru/landgrafhomyak/serdha0/api/module/CreateModuleScope.kt index 6c67991..2f06a28 100644 --- a/src/commonMain/kotlin/ru/landgrafhomyak/serdha0/api/module/CreateModuleScope.kt +++ b/src/commonMain/kotlin/ru/landgrafhomyak/serdha0/api/module/CreateModuleScope.kt @@ -1,10 +1,10 @@ package ru.landgrafhomyak.db.serdha0.api.module import ru.landgrafhomyak.db.serdha0.api.table.Table -import ru.landgrafhomyak.db.serdha0.api.queries.QueryCreator +import ru.landgrafhomyak.db.serdha0.api.queries.QueryConstructor import ru.landgrafhomyak.db.serdha0.api.runtime.SynchronizedDatabase import ru.landgrafhomyak.db.serdha0.api.runtime.Transaction -import ru.landgrafhomyak.db.serdha0.api.table.CreateTableScope +import ru.landgrafhomyak.db.serdha0.api.table.TableConstructor /** * Scope methods for creating new [module template][ModuleTemplate]. @@ -13,32 +13,6 @@ import ru.landgrafhomyak.db.serdha0.api.table.CreateTableScope * @see ModuleTemplate.ModuleCreator.createSchema */ public interface CreateModuleScope { - /** - * Functional interface for creating table. - * - * Can be implemented like a companion object that just calls [TableUserExtension]'s constructor with the same or similar signature. - * - * @param TableUserExtension User's type for containing table-related descriptors. - * - * @see CreateModuleScope.createTable - * @see CreateModuleScope.createSessionScopeTemporaryTable - * @see CreateModuleScope.createTransactionScopeTemporaryTable - * @see UpgradeModuleScope.TableUpgrade - */ - public interface TableCreator { - /** - * Scope method that uses [creator] to initialize table schema. - * - * @param creator Object with descriptor providers and factories. - * @return User's object with descriptors for future access. - * - * @see CreateModuleScope.createTable - * @see CreateModuleScope.createSessionScopeTemporaryTable - * @see CreateModuleScope.createTransactionScopeTemporaryTable - * @see UpgradeModuleScope.TableUpgrade - */ - public fun createTable(creator: CreateTableScope): TableUserExtension - } /** * Creates table in [specified namespace][namespace] with [specified name][name] and stores it in the database. @@ -52,7 +26,7 @@ public interface CreateModuleScope { * @param initializer Table-related descriptors initializer. * @return Table descriptor. */ - public fun createTable(namespace: Namespace, name: String, initializer: TableCreator): Table + public fun createTable(namespace: Namespace, name: String, initializer: TableConstructor): Table /** * Creates a temporary table that exits only until connection to the database not [closed][SynchronizedDatabase._close]. @@ -65,7 +39,7 @@ public interface CreateModuleScope { * @param initializer Table-related descriptors initializer. * @return Table descriptor. */ - public fun createSessionScopeTemporaryTable(namespace: Namespace, name: String, initializer: TableCreator): Table + public fun createSessionScopeTemporaryTable(namespace: Namespace, 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]. @@ -78,17 +52,17 @@ public interface CreateModuleScope { * @param initializer Table-related descriptors initializer. * @return Table descriptor. */ - public fun createTransactionScopeTemporaryTable(namespace: Namespace, name: String, initializer: TableCreator): Table + public fun createTransactionScopeTemporaryTable(namespace: Namespace, name: String, initializer: TableConstructor): Table - public val queries: QueryCreator.Scope + public val queries: QueryConstructor.Scope - public val temporarySubqueries: QueryCreator.Scope + public val temporarySubqueries: QueryConstructor.Scope - public val moduleConfiguringTemporaryQueries: QueryCreator.Scope + public val moduleConfiguringTemporaryQueries: QueryConstructor.Scope - public fun createQuery(creator: QueryCreator): qUE + public fun createQuery(creator: QueryConstructor): qUE - public fun createModuleConfiguringTemporaryQuery(creator: QueryCreator): qUE + public fun createModuleConfiguringTemporaryQuery(creator: QueryConstructor): qUE /** * Replaces [specified namespace][rootNs] with schema provided by [template]. diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/serdha0/api/table/CreateTableScope.kt b/src/commonMain/kotlin/ru/landgrafhomyak/serdha0/api/table/CreateTableScope.kt deleted file mode 100644 index b72c5eb..0000000 --- a/src/commonMain/kotlin/ru/landgrafhomyak/serdha0/api/table/CreateTableScope.kt +++ /dev/null @@ -1,46 +0,0 @@ -package ru.landgrafhomyak.db.serdha0.api.table - -import ru.landgrafhomyak.db.serdha0.api.misc.Column -import ru.landgrafhomyak.db.serdha0.api.misc.DatabaseType - -public interface CreateTableScope { - public val types: DatabaseType.Provider - - public fun > column(name: String, type: DT): Column - - public fun index(name: String, vararg columns: Column<*, *, tUE>): Index - - public fun uniqueIndex(name: String, distinctNulls: Boolean, vararg columns: Column<*, *, tUE>): UniqueIndex - public fun checkConstraint(name: String, creator: CheckConstraint.Creator, recheckExistingRows: Boolean = false): CheckConstraint - public fun > defaultValue(c: Column, creator: DefaultConstraint.Creator): DefaultConstraint - - @Suppress("PropertyName") - public val rowId_column: Column, DatabaseType>, tUE> - - @Suppress("PropertyName") - public val rowId_uniqueConstraint: UniqueIndex - - public fun selfRowReference( - columnName: String, - onDelete: ForeignRowReference.OnDelete, - ): ForeignRowReference, DatabaseType.ROW_ID> - - public fun > selfRowReference( - columnName: String, - type: DT, - onDelete: ForeignRowReference.OnDelete, - ): ForeignRowReference - - public fun foreignRowReference( - columnName: String, - toTable: Table, - onDelete: ForeignRowReference.OnDelete, - ): ForeignRowReference, DatabaseType.ROW_ID> - - public fun > foreignRowReference( - columnName: String, - type: DT, - toTable: Table, - onDelete: ForeignRowReference.OnDelete, - ): ForeignRowReference -} \ No newline at end of file diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/serdha0/api/table/TableConstructor.kt b/src/commonMain/kotlin/ru/landgrafhomyak/serdha0/api/table/TableConstructor.kt new file mode 100644 index 0000000..6c64bbc --- /dev/null +++ b/src/commonMain/kotlin/ru/landgrafhomyak/serdha0/api/table/TableConstructor.kt @@ -0,0 +1,52 @@ +package ru.landgrafhomyak.db.serdha0.api.table + +import ru.landgrafhomyak.db.serdha0.api.misc.Column +import ru.landgrafhomyak.db.serdha0.api.misc.DatabaseType + + +public interface TableConstructor { + public fun createTable(context: Scope): TableUserExtension + + + public interface Scope { + public val types: DatabaseType.Provider + + public fun > column(name: String, type: DT): Column + + public fun index(name: String, vararg columns: Column<*, *, tUE>): Index + + public fun uniqueIndex(name: String, distinctNulls: Boolean, vararg columns: Column<*, *, tUE>): UniqueIndex + public fun checkConstraint(name: String, creator: CheckConstraint.Creator, recheckExistingRows: Boolean = false): CheckConstraint + public fun > defaultValue(c: Column, creator: DefaultConstraint.Creator): DefaultConstraint + + @Suppress("PropertyName") + public val rowId_column: Column, DatabaseType>, tUE> + + @Suppress("PropertyName") + public val rowId_uniqueConstraint: UniqueIndex + + public fun selfRowReference( + columnName: String, + onDelete: ForeignRowReference.OnDelete, + ): ForeignRowReference, DatabaseType.ROW_ID> + + public fun > selfRowReference( + columnName: String, + type: DT, + onDelete: ForeignRowReference.OnDelete, + ): ForeignRowReference + + public fun foreignRowReference( + columnName: String, + toTable: Table, + onDelete: ForeignRowReference.OnDelete, + ): ForeignRowReference, DatabaseType.ROW_ID> + + public fun > foreignRowReference( + columnName: String, + type: DT, + toTable: Table, + onDelete: ForeignRowReference.OnDelete, + ): ForeignRowReference + } +} \ No newline at end of file