Table constructor
This commit is contained in:
parent
fbb03c204e
commit
d56ccd5a83
@ -1,7 +1,5 @@
|
||||
package ru.landgrafhomyak.db.raw_sql_skeleton
|
||||
|
||||
import ru.landgrafhomyak.db.serdha0.api.module.Module
|
||||
|
||||
public class Table(public val name: String, public val namespacesFromModuleRoot: List<String>) {
|
||||
public val asSqlReference: String = "\"${this.name}\""
|
||||
public val asSqlString: String = "\'${this.name}\'"
|
||||
|
@ -0,0 +1,18 @@
|
||||
package ru.landgrafhomyak.db.raw_sql_skeleton
|
||||
|
||||
import ru.landgrafhomyak.db.serdha0.api.misc.Column
|
||||
import ru.landgrafhomyak.db.serdha0.api.table.Index
|
||||
import ru.landgrafhomyak.db.serdha0.api.table.UniqueIndex
|
||||
|
||||
public interface TableConstructor<TableUserExtension : Any> {
|
||||
public fun createTable(context: Scope<TableUserExtension>): TableUserExtension
|
||||
|
||||
public interface Scope<tUE : Any> {
|
||||
public fun column(name: String, type: String): Column<*, *, tUE>
|
||||
|
||||
public fun index(name: String): Index<tUE>
|
||||
|
||||
public fun uniqueIndex(name: String): UniqueIndex<tUE>
|
||||
public fun checkConstraint(name: String): CheckConstraint<tUE>
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@ package ru.landgrafhomyak.db.serdha0.api.module
|
||||
|
||||
import ru.landgrafhomyak.db.raw_sql_skeleton.Table
|
||||
import ru.landgrafhomyak.db.serdha0.api.queries._Query
|
||||
import ru.landgrafhomyak.db.serdha0.api.table.TableConstructor
|
||||
import ru.landgrafhomyak.db.raw_sql_skeleton.TableConstructor
|
||||
import ru.landgrafhomyak.serdha0.api.module.Namespace
|
||||
|
||||
/**
|
||||
|
@ -1,53 +0,0 @@
|
||||
package ru.landgrafhomyak.db.serdha0.api.table
|
||||
|
||||
import ru.landgrafhomyak.db.raw_sql_skeleton.Table
|
||||
import ru.landgrafhomyak.db.serdha0.api.misc.Column
|
||||
import ru.landgrafhomyak.db.serdha0.api.misc.DatabaseType
|
||||
|
||||
|
||||
public interface TableConstructor<TableUserExtension : Any> {
|
||||
public fun createTable(context: Scope<TableUserExtension>): TableUserExtension
|
||||
|
||||
|
||||
public interface Scope<tUE : Any> {
|
||||
public val types: DatabaseType.Provider
|
||||
|
||||
public fun <RT, DT : DatabaseType<RT>> column(name: String, type: DT): Column<RT, DT, tUE>
|
||||
|
||||
public fun index(name: String, vararg columns: Column<*, *, tUE>): Index<tUE>
|
||||
|
||||
public fun uniqueIndex(name: String, distinctNulls: Boolean, vararg columns: Column<*, *, tUE>): UniqueIndex<tUE>
|
||||
public fun <cUE : Any> checkConstraint(name: String, creator: CheckConstraint.Creator<cUE, tUE>, recheckExistingRows: Boolean = false): CheckConstraint<tUE>
|
||||
public fun <cUE : Any, RT : Any, DT : DatabaseType<RT>> defaultValue(c: Column<RT, DT, tUE>, creator: DefaultConstraint.Creator<cUE, RT, DT, tUE>): DefaultConstraint<tUE>
|
||||
|
||||
@Suppress("PropertyName")
|
||||
public val rowId_column: Column<RowId<tUE>, DatabaseType<RowId<tUE>>, tUE>
|
||||
|
||||
@Suppress("PropertyName")
|
||||
public val rowId_uniqueConstraint: UniqueIndex<tUE>
|
||||
|
||||
public fun selfRowReference(
|
||||
columnName: String,
|
||||
onDelete: ForeignRowReference.OnDelete,
|
||||
): ForeignRowReference<tUE, tUE, RowId<tUE>, DatabaseType.ROW_ID<tUE>>
|
||||
|
||||
public fun <RT, DT : DatabaseType<RT>> selfRowReference(
|
||||
columnName: String,
|
||||
type: DT,
|
||||
onDelete: ForeignRowReference.OnDelete,
|
||||
): ForeignRowReference<tUE, tUE, RT, DT>
|
||||
|
||||
public fun <ttUE : Any> foreignRowReference(
|
||||
columnName: String,
|
||||
toTable: Table<ttUE, *>,
|
||||
onDelete: ForeignRowReference.OnDelete,
|
||||
): ForeignRowReference<tUE, ttUE, RowId<ttUE>, DatabaseType.ROW_ID<ttUE>>
|
||||
|
||||
public fun <ttUE : Any, RT, DT : DatabaseType<RT>> foreignRowReference(
|
||||
columnName: String,
|
||||
type: DT,
|
||||
toTable: Table<ttUE, *>,
|
||||
onDelete: ForeignRowReference.OnDelete,
|
||||
): ForeignRowReference<tUE, ttUE, RT, DT>
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user