[history/serdha] Changing ForeignKey to ForeignRowReference

This commit is contained in:
Andrew Golovashevich 2025-01-02 02:09:00 +03:00
parent c2c5ab9a28
commit c447770d71

View File

@ -1,7 +1,6 @@
package ru.landgrafhomyak.serdha.api.v0.ddl
import ru.landgrafhomyak.serdha.api.v0.Expression
import ru.landgrafhomyak.serdha.api.v0.LowLevelApi
public interface TableCreator<TableUserExtension : Any> {
public val expressionBuilder: Expression.Builder<TableUserExtension>
@ -22,64 +21,15 @@ public interface TableCreator<TableUserExtension : Any> {
@Suppress("PropertyName")
public val rowId_uniqueConstraint: UniqueIndex<TableUserExtension>
@Suppress("FunctionName")
@LowLevelApi
public fun <TargetTableUserWrapper : Any> _foreignKey(
fromColumns: Array<Column<*, *, TableUserExtension>>,
toTable: Table<TargetTableUserWrapper, *>,
toColumns: Array<Column<*, *, TargetTableUserWrapper>>,
onUpdate: ForeignKey.OnUpdateAction,
onDelete: ForeignKey.OnDeleteAction,
): ForeignKey<TableUserExtension, TargetTableUserWrapper>
public fun <TargetTableUserWrapper : Any> selfRowReference(
onDelete: ForeignRowReference.OnDeleteAction,
toColumn: Column<RowId<TargetTableUserWrapper>, ColumnType.ROW_ID<TargetTableUserWrapper>, TargetTableUserWrapper>,
): ForeignRowReference<TableUserExtension, TableUserExtension>
@OptIn(LowLevelApi::class)
public fun <TargetTableUserWrapper : Any, ColumnType1 : ColumnType<*>> foreignKey(
fromColumn: Column<*, ColumnType1, TableUserExtension>,
public fun <TargetTableUserWrapper : Any> foreignRowReference(
fromColumn: Column<RowId<TargetTableUserWrapper>, ColumnType.ROW_ID<TargetTableUserWrapper>, TableUserExtension>,
toTable: Table<TargetTableUserWrapper, *>,
toColumn: Column<*, ColumnType1, TargetTableUserWrapper>,
onUpdate: ForeignKey.OnUpdateAction,
onDelete: ForeignKey.OnDeleteAction,
): ForeignKey<TableUserExtension, TargetTableUserWrapper> = this._foreignKey(
fromColumns = arrayOf(fromColumn),
toTable = toTable,
toColumns = arrayOf(toColumn),
onUpdate = onUpdate,
onDelete = onDelete
)
@OptIn(LowLevelApi::class)
public fun <TargetTableUserWrapper : Any, ColumnType1 : ColumnType<*>, ColumnType2 : ColumnType<*>> foreignKey(
fromColumn1: Column<*, ColumnType1, TableUserExtension>,
fromColumn2: Column<*, ColumnType2, TableUserExtension>,
toTable: Table<TargetTableUserWrapper, *>,
toColumn1: Column<*, ColumnType1, TargetTableUserWrapper>,
toColumn2: Column<*, ColumnType2, TargetTableUserWrapper>,
onUpdate: ForeignKey.OnUpdateAction,
onDelete: ForeignKey.OnDeleteAction,
): ForeignKey<TableUserExtension, TargetTableUserWrapper> = this._foreignKey(
fromColumns = arrayOf(fromColumn1, fromColumn2),
toTable = toTable,
toColumns = arrayOf(toColumn1, toColumn2),
onUpdate = onUpdate,
onDelete = onDelete
)
@OptIn(LowLevelApi::class)
public fun <TargetTableUserWrapper : Any, ColumnType1 : ColumnType<*>, ColumnType2 : ColumnType<*>, ColumnType3 : ColumnType<*>> foreignKey(
fromColumn1: Column<*, ColumnType1, TableUserExtension>,
fromColumn2: Column<*, ColumnType2, TableUserExtension>,
fromColumn3: Column<*, ColumnType3, TableUserExtension>,
toTable: Table<TargetTableUserWrapper, *>,
toColumn1: Column<*, ColumnType1, TargetTableUserWrapper>,
toColumn2: Column<*, ColumnType2, TargetTableUserWrapper>,
toColumn3: Column<*, ColumnType3, TargetTableUserWrapper>,
onUpdate: ForeignKey.OnUpdateAction,
onDelete: ForeignKey.OnDeleteAction,
): ForeignKey<TableUserExtension, TargetTableUserWrapper> = this._foreignKey(
fromColumns = arrayOf(fromColumn1, fromColumn2, fromColumn3),
toTable = toTable,
toColumns = arrayOf(toColumn1, toColumn2, toColumn3),
onUpdate = onUpdate,
onDelete = onDelete
)
toColumn: Column<RowId<TargetTableUserWrapper>, ColumnType.ROW_ID<TargetTableUserWrapper>, TargetTableUserWrapper>,
onDelete: ForeignRowReference.OnDeleteAction,
): ForeignRowReference<TableUserExtension, TargetTableUserWrapper>
}