Compare commits

...

9 Commits

18 changed files with 1237 additions and 290 deletions

View File

@ -19,7 +19,7 @@ buildscript {
} }
group = "ru.landgrafhomyak.db.serdha" group = "ru.landgrafhomyak.db.serdha"
version = "0.0" version = "0.1"
repositories { repositories {
mavenCentral() mavenCentral()

View File

@ -11,7 +11,7 @@ import ru.landgrafhomyak.db.serdha0.api.queries.UpdateQuery
import ru.landgrafhomyak.db.serdha0.api.queries._Query import ru.landgrafhomyak.db.serdha0.api.queries._Query
import ru.landgrafhomyak.db.serdha0.api.table.Table import ru.landgrafhomyak.db.serdha0.api.table.Table
public class InlineSelectConstructor<qUE : Any, sqUE : Any>( public open class InlineSelectConstructor<qUE : Any, sqUE : Any>(
override val source: _Selectable<sqUE>, override val source: _Selectable<sqUE>,
private val constructor: (SelectQuery.Simple.Constructor.Scope<qUE, sqUE>) -> qUE private val constructor: (SelectQuery.Simple.Constructor.Scope<qUE, sqUE>) -> qUE
) : SelectQuery.Simple.Constructor<qUE, sqUE> { ) : SelectQuery.Simple.Constructor<qUE, sqUE> {
@ -23,7 +23,7 @@ public fun <qUE : Any, sqUE : Any> _Query.Constructor._SelectsScope.select(
source: _Selectable<sqUE>, constructor: (SelectQuery.Simple.Constructor.Scope<qUE, sqUE>) -> qUE source: _Selectable<sqUE>, constructor: (SelectQuery.Simple.Constructor.Scope<qUE, sqUE>) -> qUE
): SelectQuery.Simple<qUE> = this.select(InlineSelectConstructor(source, constructor)) ): SelectQuery.Simple<qUE> = this.select(InlineSelectConstructor(source, constructor))
public class InlineSelectReducingConstructor<qUE : Any, sqUE : Any>( public open class InlineSelectReducingConstructor<qUE : Any, sqUE : Any>(
override val source: _Selectable<sqUE>, override val source: _Selectable<sqUE>,
private val constructor: (SelectQuery.Reducing.Constructor.Scope<qUE, sqUE>) -> qUE private val constructor: (SelectQuery.Reducing.Constructor.Scope<qUE, sqUE>) -> qUE
) : SelectQuery.Reducing.Constructor<qUE, sqUE> { ) : SelectQuery.Reducing.Constructor<qUE, sqUE> {
@ -35,7 +35,7 @@ public fun <qUE : Any, sqUE : Any> _Query.Constructor._SelectsScope.selectReduci
source: _Selectable<sqUE>, constructor: (SelectQuery.Reducing.Constructor.Scope<qUE, sqUE>) -> qUE source: _Selectable<sqUE>, constructor: (SelectQuery.Reducing.Constructor.Scope<qUE, sqUE>) -> qUE
): SelectQuery.Reducing<qUE> = this.selectReducing(InlineSelectReducingConstructor(source, constructor)) ): SelectQuery.Reducing<qUE> = this.selectReducing(InlineSelectReducingConstructor(source, constructor))
public class InlineSelectFoldingConstructor<qUE : Any, sqUE : Any>( public open class InlineSelectFoldingConstructor<qUE : Any, sqUE : Any>(
override val source: _Selectable<sqUE>, override val source: _Selectable<sqUE>,
private val constructor: (SelectQuery.Folding.Constructor.Scope<qUE, sqUE>) -> qUE private val constructor: (SelectQuery.Folding.Constructor.Scope<qUE, sqUE>) -> qUE
) : SelectQuery.Folding.Constructor<qUE, sqUE> { ) : SelectQuery.Folding.Constructor<qUE, sqUE> {
@ -48,7 +48,7 @@ public fun <qUE : Any, sqUE : Any> _Query.Constructor._SelectsScope.selectFoldin
): SelectQuery.Folding<qUE> = this.selectFolding(InlineSelectFoldingConstructor(source, constructor)) ): SelectQuery.Folding<qUE> = this.selectFolding(InlineSelectFoldingConstructor(source, constructor))
public class InlineSelectUnionConstructor<qUE : Any, fsqUE : Any, lsqUE : Any>( public open class InlineSelectUnionConstructor<qUE : Any, fsqUE : Any, lsqUE : Any>(
override val first: _Selectable<fsqUE>, override val last: _Selectable<lsqUE>, override val first: _Selectable<fsqUE>, override val last: _Selectable<lsqUE>,
private val constructor: (SelectQuery.Union.Constructor.Scope<qUE, fsqUE, lsqUE>) -> qUE private val constructor: (SelectQuery.Union.Constructor.Scope<qUE, fsqUE, lsqUE>) -> qUE
) : SelectQuery.Union.Constructor<qUE, fsqUE, lsqUE> { ) : SelectQuery.Union.Constructor<qUE, fsqUE, lsqUE> {
@ -60,7 +60,7 @@ public fun <qUE : Any, fsqUE : Any, lsqUE : Any> _Query.Constructor._SelectsScop
first: _Selectable<fsqUE>, last: _Selectable<lsqUE>, constructor: (SelectQuery.Union.Constructor.Scope<qUE, fsqUE, lsqUE>) -> qUE first: _Selectable<fsqUE>, last: _Selectable<lsqUE>, constructor: (SelectQuery.Union.Constructor.Scope<qUE, fsqUE, lsqUE>) -> qUE
): SelectQuery.Union<qUE> = this.selectUnion(InlineSelectUnionConstructor(first, last, constructor)) ): SelectQuery.Union<qUE> = this.selectUnion(InlineSelectUnionConstructor(first, last, constructor))
public class InlineInsertSingleRowConstructor<qUE : Any, ttUE : Any>( public open class InlineInsertSingleRowConstructor<qUE : Any, ttUE : Any>(
override val targetTable: Table<ttUE, *>, override val targetTable: Table<ttUE, *>,
private val constructor: (InsertQuery.SingleRow.Constructor.Scope<qUE, ttUE>) -> qUE private val constructor: (InsertQuery.SingleRow.Constructor.Scope<qUE, ttUE>) -> qUE
) : InsertQuery.SingleRow.Constructor<qUE, ttUE> { ) : InsertQuery.SingleRow.Constructor<qUE, ttUE> {
@ -73,7 +73,7 @@ public fun <qUE : Any, ttUE : Any> _Query.Constructor.Scope.insertSingleRow(
): InsertQuery.SingleRow<qUE> = this.insertSingleRow(InlineInsertSingleRowConstructor(targetTable, constructor)) ): InsertQuery.SingleRow<qUE> = this.insertSingleRow(InlineInsertSingleRowConstructor(targetTable, constructor))
public class InlineInsertFromSubqueryConstructor<qUE : Any, ttUE : Any, sqUE : Any>( public open class InlineInsertFromSubqueryConstructor<qUE : Any, ttUE : Any, sqUE : Any>(
override val targetTable: Table<ttUE, *>, override val targetTable: Table<ttUE, *>,
override val selector: _Selectable<sqUE>, override val selector: _Selectable<sqUE>,
private val constructor: (InsertQuery.FromSubquery.Constructor.Scope<qUE, ttUE, sqUE>) -> qUE private val constructor: (InsertQuery.FromSubquery.Constructor.Scope<qUE, ttUE, sqUE>) -> qUE
@ -86,6 +86,11 @@ public fun <qUE : Any, ttUE : Any, sqUE : Any> _Query.Constructor.Scope.insertFr
targetTable: Table<ttUE, *>, selector: _Selectable<sqUE>, constructor: (InsertQuery.FromSubquery.Constructor.Scope<qUE, ttUE, sqUE>) -> qUE targetTable: Table<ttUE, *>, selector: _Selectable<sqUE>, constructor: (InsertQuery.FromSubquery.Constructor.Scope<qUE, ttUE, sqUE>) -> qUE
): InsertQuery.FromSubquery<qUE> = this.insertFromSubquery(InlineInsertFromSubqueryConstructor(targetTable, selector, constructor)) ): InsertQuery.FromSubquery<qUE> = this.insertFromSubquery(InlineInsertFromSubqueryConstructor(targetTable, selector, constructor))
@Deprecated(
"Bad name",
ReplaceWith("InlineInsertMultipleRowsConstructor", "ru.landgrafhomyak.db.serdha0.user_commons.construction.InlineInsertMultipleRowsConstructor"),
DeprecationLevel.HIDDEN
)
public class InlineInsertMultipleRowConstructor<qUE : Any, ttUE : Any>( public class InlineInsertMultipleRowConstructor<qUE : Any, ttUE : Any>(
override val targetTable: Table<ttUE, *>, override val targetTable: Table<ttUE, *>,
private val constructor: (InsertQuery.MultipleRows.Constructor.Scope<qUE, ttUE>) -> qUE private val constructor: (InsertQuery.MultipleRows.Constructor.Scope<qUE, ttUE>) -> qUE
@ -94,11 +99,19 @@ public class InlineInsertMultipleRowConstructor<qUE : Any, ttUE : Any>(
this.constructor(context) this.constructor(context)
} }
public open class InlineInsertMultipleRowsConstructor<qUE : Any, ttUE : Any>(
override val targetTable: Table<ttUE, *>,
private val constructor: (InsertQuery.MultipleRows.Constructor.Scope<qUE, ttUE>) -> qUE
) : InsertQuery.MultipleRows.Constructor<qUE, ttUE> {
override fun createInsertMultipleRows(context: InsertQuery.MultipleRows.Constructor.Scope<qUE, ttUE>): qUE =
this.constructor(context)
}
public fun <qUE : Any, ttUE : Any> _Query.Constructor.Scope.insertMultipleRows( public fun <qUE : Any, ttUE : Any> _Query.Constructor.Scope.insertMultipleRows(
targetTable: Table<ttUE, *>, constructor: (InsertQuery.MultipleRows.Constructor.Scope<qUE, ttUE>) -> qUE targetTable: Table<ttUE, *>, constructor: (InsertQuery.MultipleRows.Constructor.Scope<qUE, ttUE>) -> qUE
): InsertQuery.MultipleRows<qUE> = this.insertMultipleRows(InlineInsertMultipleRowConstructor(targetTable, constructor)) ): InsertQuery.MultipleRows<qUE> = this.insertMultipleRows(InlineInsertMultipleRowsConstructor(targetTable, constructor))
public class InlineUpdateSingleRowConstructor<qUE : Any, ttUE : Any>( public open class InlineUpdateSingleRowConstructor<qUE : Any, ttUE : Any>(
override val targetTable: Table<ttUE, *>, override val targetTable: Table<ttUE, *>,
private val constructor: (UpdateQuery.SingleRow.Constructor.Scope<qUE, ttUE>) -> qUE private val constructor: (UpdateQuery.SingleRow.Constructor.Scope<qUE, ttUE>) -> qUE
) : UpdateQuery.SingleRow.Constructor<qUE, ttUE> { ) : UpdateQuery.SingleRow.Constructor<qUE, ttUE> {
@ -111,7 +124,7 @@ public fun <qUE : Any, ttUE : Any> _Query.Constructor.Scope.updateSingleRow(
): UpdateQuery.SingleRow<qUE> = this.updateSingleRow(InlineUpdateSingleRowConstructor(targetTable, constructor)) ): UpdateQuery.SingleRow<qUE> = this.updateSingleRow(InlineUpdateSingleRowConstructor(targetTable, constructor))
public class InlineUpdateFromSubqueryConstructor<qUE : Any, ttUE : Any, sqUE : Any>( public open class InlineUpdateFromSubqueryConstructor<qUE : Any, ttUE : Any, sqUE : Any>(
override val targetTable: Table<ttUE, *>, override val targetTable: Table<ttUE, *>,
override val selector: _Selectable<sqUE>, override val selector: _Selectable<sqUE>,
private val constructor: (UpdateQuery.FromSubquery.Constructor.Scope<qUE, ttUE, sqUE>) -> qUE private val constructor: (UpdateQuery.FromSubquery.Constructor.Scope<qUE, ttUE, sqUE>) -> qUE
@ -124,6 +137,12 @@ public fun <qUE : Any, ttUE : Any, sqUE : Any> _Query.Constructor.Scope.updateFr
targetTable: Table<ttUE, *>, selector: _Selectable<sqUE>, constructor: (UpdateQuery.FromSubquery.Constructor.Scope<qUE, ttUE, sqUE>) -> qUE targetTable: Table<ttUE, *>, selector: _Selectable<sqUE>, constructor: (UpdateQuery.FromSubquery.Constructor.Scope<qUE, ttUE, sqUE>) -> qUE
): UpdateQuery.FromSubquery<qUE> = this.updateFromSubquery(InlineUpdateFromSubqueryConstructor(targetTable, selector, constructor)) ): UpdateQuery.FromSubquery<qUE> = this.updateFromSubquery(InlineUpdateFromSubqueryConstructor(targetTable, selector, constructor))
@Deprecated(
"Bad name",
ReplaceWith("InlineUpdateMultipleRowsConstructor", "ru.landgrafhomyak.db.serdha0.user_commons.construction.InlineUpdateMultipleRowsConstructor"),
DeprecationLevel.HIDDEN
)
public class InlineUpdateMultipleRowConstructor<qUE : Any, ttUE : Any>( public class InlineUpdateMultipleRowConstructor<qUE : Any, ttUE : Any>(
override val targetTable: Table<ttUE, *>, override val targetTable: Table<ttUE, *>,
private val constructor: (UpdateQuery.MultipleRows.Constructor.Scope<qUE, ttUE>) -> qUE private val constructor: (UpdateQuery.MultipleRows.Constructor.Scope<qUE, ttUE>) -> qUE
@ -132,11 +151,19 @@ public class InlineUpdateMultipleRowConstructor<qUE : Any, ttUE : Any>(
this.constructor(context) this.constructor(context)
} }
public open class InlineUpdateMultipleRowsConstructor<qUE : Any, ttUE : Any>(
override val targetTable: Table<ttUE, *>,
private val constructor: (UpdateQuery.MultipleRows.Constructor.Scope<qUE, ttUE>) -> qUE
) : UpdateQuery.MultipleRows.Constructor<qUE, ttUE> {
override fun createUpdateMultipleRows(context: UpdateQuery.MultipleRows.Constructor.Scope<qUE, ttUE>): qUE =
this.constructor(context)
}
public fun <qUE : Any, ttUE : Any> _Query.Constructor.Scope.updateMultipleRows( public fun <qUE : Any, ttUE : Any> _Query.Constructor.Scope.updateMultipleRows(
targetTable: Table<ttUE, *>, constructor: (UpdateQuery.MultipleRows.Constructor.Scope<qUE, ttUE>) -> qUE targetTable: Table<ttUE, *>, constructor: (UpdateQuery.MultipleRows.Constructor.Scope<qUE, ttUE>) -> qUE
): UpdateQuery.MultipleRows<qUE> = this.updateMultipleRows(InlineUpdateMultipleRowConstructor(targetTable, constructor)) ): UpdateQuery.MultipleRows<qUE> = this.updateMultipleRows(InlineUpdateMultipleRowsConstructor(targetTable, constructor))
public class InlineDeleteSingleRowConstructor<qUE : Any, ttUE : Any>( public open class InlineDeleteSingleRowConstructor<qUE : Any, ttUE : Any>(
override val targetTable: Table<ttUE, *>, override val targetTable: Table<ttUE, *>,
private val constructor: (DeleteQuery.SingleRow.Constructor.Scope<qUE, ttUE>) -> qUE private val constructor: (DeleteQuery.SingleRow.Constructor.Scope<qUE, ttUE>) -> qUE
) : DeleteQuery.SingleRow.Constructor<qUE, ttUE> { ) : DeleteQuery.SingleRow.Constructor<qUE, ttUE> {
@ -149,7 +176,7 @@ public fun <qUE : Any, ttUE : Any> _Query.Constructor.Scope.deleteSingleRow(
): DeleteQuery.SingleRow<qUE> = this.deleteSingleRow(InlineDeleteSingleRowConstructor(targetTable, constructor)) ): DeleteQuery.SingleRow<qUE> = this.deleteSingleRow(InlineDeleteSingleRowConstructor(targetTable, constructor))
public class InlineDeleteFromSubqueryConstructor<qUE : Any, ttUE : Any, sqUE : Any>( public open class InlineDeleteFromSubqueryConstructor<qUE : Any, ttUE : Any, sqUE : Any>(
override val targetTable: Table<ttUE, *>, override val targetTable: Table<ttUE, *>,
override val selector: _Selectable<sqUE>, override val selector: _Selectable<sqUE>,
private val constructor: (DeleteQuery.FromSubquery.Constructor.Scope<qUE, ttUE, sqUE>) -> qUE private val constructor: (DeleteQuery.FromSubquery.Constructor.Scope<qUE, ttUE, sqUE>) -> qUE
@ -162,6 +189,11 @@ public fun <qUE : Any, ttUE : Any, sqUE : Any> _Query.Constructor.Scope.deleteFr
targetTable: Table<ttUE, *>, selector: _Selectable<sqUE>, constructor: (DeleteQuery.FromSubquery.Constructor.Scope<qUE, ttUE, sqUE>) -> qUE targetTable: Table<ttUE, *>, selector: _Selectable<sqUE>, constructor: (DeleteQuery.FromSubquery.Constructor.Scope<qUE, ttUE, sqUE>) -> qUE
): DeleteQuery.FromSubquery<qUE> = this.deleteFromSubquery(InlineDeleteFromSubqueryConstructor(targetTable, selector, constructor)) ): DeleteQuery.FromSubquery<qUE> = this.deleteFromSubquery(InlineDeleteFromSubqueryConstructor(targetTable, selector, constructor))
@Deprecated(
"Bad name",
ReplaceWith("InlineDeleteMultipleRowsConstructor", "ru.landgrafhomyak.db.serdha0.user_commons.construction.InlineDeleteMultipleRowsConstructor"),
DeprecationLevel.HIDDEN
)
public class InlineDeleteMultipleRowConstructor<qUE : Any, ttUE : Any>( public class InlineDeleteMultipleRowConstructor<qUE : Any, ttUE : Any>(
override val targetTable: Table<ttUE, *>, override val targetTable: Table<ttUE, *>,
private val constructor: (DeleteQuery.MultipleRows.Constructor.Scope<qUE, ttUE>) -> qUE private val constructor: (DeleteQuery.MultipleRows.Constructor.Scope<qUE, ttUE>) -> qUE
@ -170,7 +202,15 @@ public class InlineDeleteMultipleRowConstructor<qUE : Any, ttUE : Any>(
this.constructor(context) this.constructor(context)
} }
public open class InlineDeleteMultipleRowsConstructor<qUE : Any, ttUE : Any>(
override val targetTable: Table<ttUE, *>,
private val constructor: (DeleteQuery.MultipleRows.Constructor.Scope<qUE, ttUE>) -> qUE
) : DeleteQuery.MultipleRows.Constructor<qUE, ttUE> {
override fun createMultipleRows(context: DeleteQuery.MultipleRows.Constructor.Scope<qUE, ttUE>): qUE =
this.constructor(context)
}
public fun <qUE : Any, ttUE : Any> _Query.Constructor.Scope.deleteMultipleRows( public fun <qUE : Any, ttUE : Any> _Query.Constructor.Scope.deleteMultipleRows(
targetTable: Table<ttUE, *>, constructor: (DeleteQuery.MultipleRows.Constructor.Scope<qUE, ttUE>) -> qUE targetTable: Table<ttUE, *>, constructor: (DeleteQuery.MultipleRows.Constructor.Scope<qUE, ttUE>) -> qUE
): DeleteQuery.MultipleRows<qUE> = this.deleteMultipleRows(InlineDeleteMultipleRowConstructor(targetTable, constructor)) ): DeleteQuery.MultipleRows<qUE> = this.deleteMultipleRows(InlineDeleteMultipleRowsConstructor(targetTable, constructor))

View File

@ -1,4 +1,4 @@
@file:JvmName("_QueryParamKt") @file:JvmName("_QueryParamKt") // todo query_param_like
package ru.landgrafhomyak.db.serdha0.user_commons.construction package ru.landgrafhomyak.db.serdha0.user_commons.construction
@ -47,6 +47,11 @@ public fun <qUE : Any, ocUE : Any, RT, DT : DatabaseType<RT>> InsertQuery.Single
name: String, column: Column<RT, DT, ocUE> name: String, column: Column<RT, DT, ocUE>
): QueryParam<RT, DT, qUE> = this.queryParam(name, column.type) ): QueryParam<RT, DT, qUE> = this.queryParam(name, column.type)
@JvmName("queryParamLike\$target")
public fun <qUE : Any, ocUE : Any, RT, DT : DatabaseType<RT>> InsertQuery.FromSubquery.Constructor.Scope<qUE, ocUE, *>.queryParamLike(
name: String, column: Column<RT, DT, ocUE>
): QueryParam<RT, DT, qUE> = this.queryParam(name, column.type)
public fun <qUE : Any, ocUE : Any, RT, DT : DatabaseType<RT>> InsertQuery.FromSubquery.Constructor.Scope<qUE, *, ocUE>.queryParamLike( public fun <qUE : Any, ocUE : Any, RT, DT : DatabaseType<RT>> InsertQuery.FromSubquery.Constructor.Scope<qUE, *, ocUE>.queryParamLike(
name: String, column: Column<RT, DT, ocUE> name: String, column: Column<RT, DT, ocUE>
): QueryParam<RT, DT, qUE> = this.queryParam(name, column.type) ): QueryParam<RT, DT, qUE> = this.queryParam(name, column.type)
@ -59,6 +64,11 @@ public fun <qUE : Any, ocUE : Any, RT, DT : DatabaseType<RT>> UpdateQuery.Single
name: String, column: Column<RT, DT, ocUE> name: String, column: Column<RT, DT, ocUE>
): QueryParam<RT, DT, qUE> = this.queryParam(name, column.type) ): QueryParam<RT, DT, qUE> = this.queryParam(name, column.type)
@JvmName("queryParamLike\$target")
public fun <qUE : Any, ocUE : Any, RT, DT : DatabaseType<RT>> UpdateQuery.FromSubquery.Constructor.Scope<qUE, ocUE, *>.queryParamLike(
name: String, column: Column<RT, DT, ocUE>
): QueryParam<RT, DT, qUE> = this.queryParam(name, column.type)
public fun <qUE : Any, ocUE : Any, RT, DT : DatabaseType<RT>> UpdateQuery.FromSubquery.Constructor.Scope<qUE, *, ocUE>.queryParamLike( public fun <qUE : Any, ocUE : Any, RT, DT : DatabaseType<RT>> UpdateQuery.FromSubquery.Constructor.Scope<qUE, *, ocUE>.queryParamLike(
name: String, column: Column<RT, DT, ocUE> name: String, column: Column<RT, DT, ocUE>
): QueryParam<RT, DT, qUE> = this.queryParam(name, column.type) ): QueryParam<RT, DT, qUE> = this.queryParam(name, column.type)
@ -71,6 +81,10 @@ public fun <qUE : Any, ocUE : Any, RT, DT : DatabaseType<RT>> DeleteQuery.Single
name: String, column: Column<RT, DT, ocUE> name: String, column: Column<RT, DT, ocUE>
): QueryParam<RT, DT, qUE> = this.queryParam(name, column.type) ): QueryParam<RT, DT, qUE> = this.queryParam(name, column.type)
@JvmName("queryParamLike\$target")
public fun <qUE : Any, ocUE : Any, RT, DT : DatabaseType<RT>> DeleteQuery.FromSubquery.Constructor.Scope<qUE, ocUE, *>.queryParamLike(
name: String, column: Column<RT, DT, ocUE>
): QueryParam<RT, DT, qUE> = this.queryParam(name, column.type)
public fun <qUE : Any, ocUE : Any, RT, DT : DatabaseType<RT>> DeleteQuery.FromSubquery.Constructor.Scope<qUE, *, ocUE>.queryParamLike( public fun <qUE : Any, ocUE : Any, RT, DT : DatabaseType<RT>> DeleteQuery.FromSubquery.Constructor.Scope<qUE, *, ocUE>.queryParamLike(
name: String, column: Column<RT, DT, ocUE> name: String, column: Column<RT, DT, ocUE>
): QueryParam<RT, DT, qUE> = this.queryParam(name, column.type) ): QueryParam<RT, DT, qUE> = this.queryParam(name, column.type)

View File

@ -18,3 +18,7 @@ public fun <qUE : Any, ocUE : Any, RT, DT : DatabaseType<RT>> SelectQuery.WithJo
public fun <qUE : Any, ocUE : Any, RT, DT : DatabaseType<RT>> SelectQuery.WithJoin.Constructor.Scope<qUE, *, ocUE>.returnColumnFromRight( public fun <qUE : Any, ocUE : Any, RT, DT : DatabaseType<RT>> SelectQuery.WithJoin.Constructor.Scope<qUE, *, ocUE>.returnColumnFromRight(
name: String, column: Column<RT, DT, ocUE> name: String, column: Column<RT, DT, ocUE>
): Column<RT, DT, qUE> = this.returnColumn(name, this.selectColumnFromRight(column)) ): Column<RT, DT, qUE> = this.returnColumn(name, this.selectColumnFromRight(column))
public fun <qUE : Any, ocUE : Any, RT : Any, DT : DatabaseType<RT>> SelectQuery.WithJoin.Constructor.Scope<qUE, *, ocUE>.returnColumnFromRightAsNullable(
name: String, column: Column<RT, DT, ocUE>
): Column<RT?, DatabaseType.Nullable<RT, DT>, qUE> = this.returnColumn(name, this.selectColumnFromRightAsNullable(column))

View File

@ -0,0 +1,25 @@
@file:JvmName("_RowReferenceKt")
package ru.landgrafhomyak.db.serdha0.user_commons.construction
import kotlin.jvm.JvmName
import ru.landgrafhomyak.db.serdha0.api.misc.DatabaseType
import ru.landgrafhomyak.db.serdha0.api.table.ForeignRowReference
import ru.landgrafhomyak.db.serdha0.api.table.RowId
import ru.landgrafhomyak.db.serdha0.api.table.Table
import ru.landgrafhomyak.db.serdha0.api.table.TableConstructor
public fun <tUE : Any> TableConstructor.Scope<tUE>.nullableSelfRowReference(
columnName: String,
onDelete: ForeignRowReference.OnDelete,
): ForeignRowReference<tUE, tUE, RowId<tUE>?, DatabaseType.Nullable<RowId<tUE>, DatabaseType.ROW_ID<tUE>>> =
this.selfRowReference(columnName, this.types.nullableOf(this.rowIdColumn.type), onDelete)
public fun <tUE : Any, ttUE : Any> TableConstructor.Scope<tUE>.nullableForeignRowReference(
columnName: String,
toTable: Table<ttUE, *>,
onDelete: ForeignRowReference.OnDelete,
): ForeignRowReference<tUE, ttUE, RowId<ttUE>?, DatabaseType.Nullable<RowId<ttUE>, DatabaseType.ROW_ID<ttUE>>> =
this.foreignRowReference(columnName, this.types.nullableOf(this.types.ROW_ID(toTable)), toTable, onDelete)

View File

@ -0,0 +1,503 @@
@file:JvmName("_TableInlineConstructorsKt")
package ru.landgrafhomyak.db.serdha0.user_commons.construction
import kotlin.jvm.JvmName
import ru.landgrafhomyak.db.serdha0.api.module.CreateModuleScope
import ru.landgrafhomyak.db.serdha0.api.module.Module
import ru.landgrafhomyak.db.serdha0.api.module.Namespace
import ru.landgrafhomyak.db.serdha0.api.table.Table
import ru.landgrafhomyak.db.serdha0.api.table.TableConstructor
public open class InlineTableConstructor0<tUE : Any>(
private val constructor: (TableConstructor.Scope<tUE>) -> tUE
) : TableConstructor<tUE> {
override fun createTable(context: TableConstructor.Scope<tUE>): tUE {
return this.constructor(context)
}
}
public fun <tUE : Any> CreateModuleScope.createTable(
namespace: Namespace = this.rootNs, name: String, constructor: (TableConstructor.Scope<tUE>) -> tUE
): Table<tUE, Nothing> =
this.createTable(namespace, name, InlineTableConstructor0(constructor))
public fun <tUE : Any> CreateModuleScope.createSessionScopeTemporaryTable(
namespace: Namespace = this.rootNs, name: String, constructor: (TableConstructor.Scope<tUE>) -> tUE
): Table<tUE, Nothing> =
this.createSessionScopeTemporaryTable(namespace, name, InlineTableConstructor0(constructor))
public fun <tUE : Any> CreateModuleScope.createTransactionScopeTemporaryTable(
namespace: Namespace = this.rootNs, name: String, constructor: (TableConstructor.Scope<tUE>) -> tUE
): Table<tUE, Nothing> =
this.createTransactionScopeTemporaryTable(namespace, name, InlineTableConstructor0(constructor))
public fun <tUE : Any> CreateModuleScope.createModuleConfiguringScopeTemporaryTable(
namespace: Namespace = this.rootNs, name: String, constructor: (TableConstructor.Scope<tUE>) -> tUE
): Table<tUE, Nothing> =
this.createModuleConfiguringScopeTemporaryTable(namespace, name, InlineTableConstructor0(constructor))
public fun <tUE : Any> Module<*>.createSessionScopeTemporaryTable(
name: String, constructor: (TableConstructor.Scope<tUE>) -> tUE
): Table<tUE, Nothing> =
this.createSessionScopeTemporaryTable(name, InlineTableConstructor0(constructor))
public fun <tUE : Any> Module<*>.createTransactionScopeTemporaryTable(
name: String, constructor: (TableConstructor.Scope<tUE>) -> tUE
): Table<tUE, Nothing> =
this.createTransactionScopeTemporaryTable(name, InlineTableConstructor0(constructor))
public open class InlineTableConstructor1<tUE : Any, A1>(
private val constructor: (TableConstructor.Scope<tUE>, A1) -> tUE,
private val a1: A1
) : TableConstructor<tUE> {
override fun createTable(context: TableConstructor.Scope<tUE>): tUE {
return this.constructor(context, this.a1)
}
}
public fun <tUE : Any, A1> CreateModuleScope.createTable(
namespace: Namespace = this.rootNs, name: String, constructor: (TableConstructor.Scope<tUE>, A1) -> tUE,
a1: A1
): Table<tUE, Nothing> =
this.createTable(namespace, name, InlineTableConstructor1(constructor, a1))
public fun <tUE : Any, A1> CreateModuleScope.createSessionScopeTemporaryTable(
namespace: Namespace = this.rootNs, name: String, constructor: (TableConstructor.Scope<tUE>, A1) -> tUE,
a1: A1
): Table<tUE, Nothing> =
this.createSessionScopeTemporaryTable(namespace, name, InlineTableConstructor1(constructor, a1))
public fun <tUE : Any, A1> CreateModuleScope.createTransactionScopeTemporaryTable(
namespace: Namespace = this.rootNs, name: String, constructor: (TableConstructor.Scope<tUE>, A1) -> tUE,
a1: A1
): Table<tUE, Nothing> =
this.createTransactionScopeTemporaryTable(namespace, name, InlineTableConstructor1(constructor, a1))
public fun <tUE : Any, A1> CreateModuleScope.createModuleConfiguringScopeTemporaryTable(
namespace: Namespace = this.rootNs, name: String, constructor: (TableConstructor.Scope<tUE>, A1) -> tUE,
a1: A1
): Table<tUE, Nothing> =
this.createModuleConfiguringScopeTemporaryTable(namespace, name, InlineTableConstructor1(constructor, a1))
public fun <tUE : Any, A1> Module<*>.createSessionScopeTemporaryTable(
name: String, constructor: (TableConstructor.Scope<tUE>, A1) -> tUE,
a1: A1
): Table<tUE, Nothing> =
this.createSessionScopeTemporaryTable(name, InlineTableConstructor1(constructor, a1))
public fun <tUE : Any, A1> Module<*>.createTransactionScopeTemporaryTable(
name: String, constructor: (TableConstructor.Scope<tUE>, A1) -> tUE,
a1: A1
): Table<tUE, Nothing> =
this.createTransactionScopeTemporaryTable(name, InlineTableConstructor1(constructor, a1))
public open class InlineTableConstructor2<tUE : Any, A1, A2>(
private val constructor: (TableConstructor.Scope<tUE>, A1, A2) -> tUE,
private val a1: A1, private val a2: A2,
) : TableConstructor<tUE> {
override fun createTable(context: TableConstructor.Scope<tUE>): tUE {
return this.constructor(context, this.a1, this.a2)
}
}
public fun <tUE : Any, A1, A2> CreateModuleScope.createTable(
namespace: Namespace = this.rootNs, name: String, constructor: (TableConstructor.Scope<tUE>, A1, A2) -> tUE,
a1: A1, a2: A2
): Table<tUE, Nothing> =
this.createTable(namespace, name, InlineTableConstructor2(constructor, a1, a2))
public fun <tUE : Any, A1, A2> CreateModuleScope.createSessionScopeTemporaryTable(
namespace: Namespace = this.rootNs, name: String, constructor: (TableConstructor.Scope<tUE>, A1, A2) -> tUE,
a1: A1, a2: A2
): Table<tUE, Nothing> =
this.createSessionScopeTemporaryTable(namespace, name, InlineTableConstructor2(constructor, a1, a2))
public fun <tUE : Any, A1, A2> CreateModuleScope.createTransactionScopeTemporaryTable(
namespace: Namespace = this.rootNs, name: String, constructor: (TableConstructor.Scope<tUE>, A1, A2) -> tUE,
a1: A1, a2: A2
): Table<tUE, Nothing> =
this.createTransactionScopeTemporaryTable(namespace, name, InlineTableConstructor2(constructor, a1, a2))
public fun <tUE : Any, A1, A2> CreateModuleScope.createModuleConfiguringScopeTemporaryTable(
namespace: Namespace = this.rootNs, name: String, constructor: (TableConstructor.Scope<tUE>, A1, A2) -> tUE,
a1: A1, a2: A2
): Table<tUE, Nothing> =
this.createModuleConfiguringScopeTemporaryTable(namespace, name, InlineTableConstructor2(constructor, a1, a2))
public fun <tUE : Any, A1, A2> Module<*>.createSessionScopeTemporaryTable(
name: String, constructor: (TableConstructor.Scope<tUE>, A1, A2) -> tUE,
a1: A1, a2: A2
): Table<tUE, Nothing> =
this.createSessionScopeTemporaryTable(name, InlineTableConstructor2(constructor, a1, a2))
public fun <tUE : Any, A1, A2> Module<*>.createTransactionScopeTemporaryTable(
name: String, constructor: (TableConstructor.Scope<tUE>, A1, A2) -> tUE,
a1: A1, a2: A2
): Table<tUE, Nothing> =
this.createTransactionScopeTemporaryTable(name, InlineTableConstructor2(constructor, a1, a2))
public open class InlineTableConstructor3<tUE : Any, A1, A2, A3>(
private val constructor: (TableConstructor.Scope<tUE>, A1, A2, A3) -> tUE,
private val a1: A1, private val a2: A2, private val a3: A3,
) : TableConstructor<tUE> {
override fun createTable(context: TableConstructor.Scope<tUE>): tUE {
return this.constructor(context, this.a1, this.a2, this.a3)
}
}
public fun <tUE : Any, A1, A2, A3> CreateModuleScope.createTable(
namespace: Namespace = this.rootNs, name: String, constructor: (TableConstructor.Scope<tUE>, A1, A2, A3) -> tUE,
a1: A1, a2: A2, a3: A3
): Table<tUE, Nothing> =
this.createTable(namespace, name, InlineTableConstructor3(constructor, a1, a2, a3))
public fun <tUE : Any, A1, A2, A3> CreateModuleScope.createSessionScopeTemporaryTable(
namespace: Namespace = this.rootNs, name: String, constructor: (TableConstructor.Scope<tUE>, A1, A2, A3) -> tUE,
a1: A1, a2: A2, a3: A3
): Table<tUE, Nothing> =
this.createSessionScopeTemporaryTable(namespace, name, InlineTableConstructor3(constructor, a1, a2, a3))
public fun <tUE : Any, A1, A2, A3> CreateModuleScope.createTransactionScopeTemporaryTable(
namespace: Namespace = this.rootNs, name: String, constructor: (TableConstructor.Scope<tUE>, A1, A2, A3) -> tUE,
a1: A1, a2: A2, a3: A3
): Table<tUE, Nothing> =
this.createTransactionScopeTemporaryTable(namespace, name, InlineTableConstructor3(constructor, a1, a2, a3))
public fun <tUE : Any, A1, A2, A3> CreateModuleScope.createModuleConfiguringScopeTemporaryTable(
namespace: Namespace = this.rootNs, name: String, constructor: (TableConstructor.Scope<tUE>, A1, A2, A3) -> tUE,
a1: A1, a2: A2, a3: A3
): Table<tUE, Nothing> =
this.createModuleConfiguringScopeTemporaryTable(namespace, name, InlineTableConstructor3(constructor, a1, a2, a3))
public fun <tUE : Any, A1, A2, A3> Module<*>.createSessionScopeTemporaryTable(
name: String, constructor: (TableConstructor.Scope<tUE>, A1, A2, A3) -> tUE,
a1: A1, a2: A2, a3: A3
): Table<tUE, Nothing> =
this.createSessionScopeTemporaryTable(name, InlineTableConstructor3(constructor, a1, a2, a3))
public fun <tUE : Any, A1, A2, A3> Module<*>.createTransactionScopeTemporaryTable(
name: String, constructor: (TableConstructor.Scope<tUE>, A1, A2, A3) -> tUE,
a1: A1, a2: A2, a3: A3
): Table<tUE, Nothing> =
this.createTransactionScopeTemporaryTable(name, InlineTableConstructor3(constructor, a1, a2, a3))
public open class InlineTableConstructor4<tUE : Any, A1, A2, A3, A4>(
private val constructor: (TableConstructor.Scope<tUE>, A1, A2, A3, A4) -> tUE,
private val a1: A1, private val a2: A2, private val a3: A3, private val a4: A4
) : TableConstructor<tUE> {
override fun createTable(context: TableConstructor.Scope<tUE>): tUE {
return this.constructor(context, this.a1, this.a2, this.a3, this.a4)
}
}
public fun <tUE : Any, A1, A2, A3, A4> CreateModuleScope.createTable(
namespace: Namespace = this.rootNs, name: String, constructor: (TableConstructor.Scope<tUE>, A1, A2, A3, A4) -> tUE,
a1: A1, a2: A2, a3: A3, a4: A4
): Table<tUE, Nothing> =
this.createTable(namespace, name, InlineTableConstructor4(constructor, a1, a2, a3, a4))
public fun <tUE : Any, A1, A2, A3, A4> CreateModuleScope.createSessionScopeTemporaryTable(
namespace: Namespace = this.rootNs, name: String, constructor: (TableConstructor.Scope<tUE>, A1, A2, A3, A4) -> tUE,
a1: A1, a2: A2, a3: A3, a4: A4
): Table<tUE, Nothing> =
this.createSessionScopeTemporaryTable(namespace, name, InlineTableConstructor4(constructor, a1, a2, a3, a4))
public fun <tUE : Any, A1, A2, A3, A4> CreateModuleScope.createTransactionScopeTemporaryTable(
namespace: Namespace = this.rootNs, name: String, constructor: (TableConstructor.Scope<tUE>, A1, A2, A3, A4) -> tUE,
a1: A1, a2: A2, a3: A3, a4: A4
): Table<tUE, Nothing> =
this.createTransactionScopeTemporaryTable(namespace, name, InlineTableConstructor4(constructor, a1, a2, a3, a4))
public fun <tUE : Any, A1, A2, A3, A4> CreateModuleScope.createModuleConfiguringScopeTemporaryTable(
namespace: Namespace = this.rootNs, name: String, constructor: (TableConstructor.Scope<tUE>, A1, A2, A3, A4) -> tUE,
a1: A1, a2: A2, a3: A3, a4: A4
): Table<tUE, Nothing> =
this.createModuleConfiguringScopeTemporaryTable(namespace, name, InlineTableConstructor4(constructor, a1, a2, a3, a4))
public fun <tUE : Any, A1, A2, A3, A4> Module<*>.createSessionScopeTemporaryTable(
name: String, constructor: (TableConstructor.Scope<tUE>, A1, A2, A3, A4) -> tUE,
a1: A1, a2: A2, a3: A3, a4: A4
): Table<tUE, Nothing> =
this.createSessionScopeTemporaryTable(name, InlineTableConstructor4(constructor, a1, a2, a3, a4))
public fun <tUE : Any, A1, A2, A3, A4> Module<*>.createTransactionScopeTemporaryTable(
name: String, constructor: (TableConstructor.Scope<tUE>, A1, A2, A3, A4) -> tUE,
a1: A1, a2: A2, a3: A3, a4: A4
): Table<tUE, Nothing> =
this.createTransactionScopeTemporaryTable(name, InlineTableConstructor4(constructor, a1, a2, a3, a4))
public open class InlineTableConstructor5<tUE : Any, A1, A2, A3, A4, A5>(
private val constructor: (TableConstructor.Scope<tUE>, A1, A2, A3, A4, A5) -> tUE,
private val a1: A1, private val a2: A2, private val a3: A3, private val a4: A4, private val a5: A5
) : TableConstructor<tUE> {
override fun createTable(context: TableConstructor.Scope<tUE>): tUE {
return this.constructor(context, this.a1, this.a2, this.a3, this.a4, this.a5)
}
}
public fun <tUE : Any, A1, A2, A3, A4, A5> CreateModuleScope.createTable(
namespace: Namespace = this.rootNs, name: String, constructor: (TableConstructor.Scope<tUE>, A1, A2, A3, A4, A5) -> tUE,
a1: A1, a2: A2, a3: A3, a4: A4, a5: A5
): Table<tUE, Nothing> =
this.createTable(namespace, name, InlineTableConstructor5(constructor, a1, a2, a3, a4, a5))
public fun <tUE : Any, A1, A2, A3, A4, A5> CreateModuleScope.createSessionScopeTemporaryTable(
namespace: Namespace = this.rootNs, name: String, constructor: (TableConstructor.Scope<tUE>, A1, A2, A3, A4, A5) -> tUE,
a1: A1, a2: A2, a3: A3, a4: A4, a5: A5
): Table<tUE, Nothing> =
this.createSessionScopeTemporaryTable(namespace, name, InlineTableConstructor5(constructor, a1, a2, a3, a4, a5))
public fun <tUE : Any, A1, A2, A3, A4, A5> CreateModuleScope.createTransactionScopeTemporaryTable(
namespace: Namespace = this.rootNs, name: String, constructor: (TableConstructor.Scope<tUE>, A1, A2, A3, A4, A5) -> tUE,
a1: A1, a2: A2, a3: A3, a4: A4, a5: A5
): Table<tUE, Nothing> =
this.createTransactionScopeTemporaryTable(namespace, name, InlineTableConstructor5(constructor, a1, a2, a3, a4, a5))
public fun <tUE : Any, A1, A2, A3, A4, A5> CreateModuleScope.createModuleConfiguringScopeTemporaryTable(
namespace: Namespace = this.rootNs, name: String, constructor: (TableConstructor.Scope<tUE>, A1, A2, A3, A4, A5) -> tUE,
a1: A1, a2: A2, a3: A3, a4: A4, a5: A5
): Table<tUE, Nothing> =
this.createModuleConfiguringScopeTemporaryTable(namespace, name, InlineTableConstructor5(constructor, a1, a2, a3, a4, a5))
public fun <tUE : Any, A1, A2, A3, A4, A5> Module<*>.createSessionScopeTemporaryTable(
name: String, constructor: (TableConstructor.Scope<tUE>, A1, A2, A3, A4, A5) -> tUE,
a1: A1, a2: A2, a3: A3, a4: A4, a5: A5
): Table<tUE, Nothing> =
this.createSessionScopeTemporaryTable(name, InlineTableConstructor5(constructor, a1, a2, a3, a4, a5))
public fun <tUE : Any, A1, A2, A3, A4, A5> Module<*>.createTransactionScopeTemporaryTable(
name: String, constructor: (TableConstructor.Scope<tUE>, A1, A2, A3, A4, A5) -> tUE,
a1: A1, a2: A2, a3: A3, a4: A4, a5: A5
): Table<tUE, Nothing> =
this.createTransactionScopeTemporaryTable(name, InlineTableConstructor5(constructor, a1, a2, a3, a4, a5))
public open class InlineTableConstructor6<tUE : Any, A1, A2, A3, A4, A5, A6>(
private val constructor: (TableConstructor.Scope<tUE>, A1, A2, A3, A4, A5, A6) -> tUE,
private val a1: A1, private val a2: A2, private val a3: A3, private val a4: A4, private val a5: A5, private val a6: A6
) : TableConstructor<tUE> {
override fun createTable(context: TableConstructor.Scope<tUE>): tUE {
return this.constructor(context, this.a1, this.a2, this.a3, this.a4, this.a5, this.a6)
}
}
public fun <tUE : Any, A1, A2, A3, A4, A5, A6> CreateModuleScope.createTable(
namespace: Namespace = this.rootNs, name: String, constructor: (TableConstructor.Scope<tUE>, A1, A2, A3, A4, A5, A6) -> tUE,
a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6
): Table<tUE, Nothing> =
this.createTable(namespace, name, InlineTableConstructor6(constructor, a1, a2, a3, a4, a5, a6))
public fun <tUE : Any, A1, A2, A3, A4, A5, A6> CreateModuleScope.createSessionScopeTemporaryTable(
namespace: Namespace = this.rootNs, name: String, constructor: (TableConstructor.Scope<tUE>, A1, A2, A3, A4, A5, A6) -> tUE,
a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6
): Table<tUE, Nothing> =
this.createSessionScopeTemporaryTable(namespace, name, InlineTableConstructor6(constructor, a1, a2, a3, a4, a5, a6))
public fun <tUE : Any, A1, A2, A3, A4, A5, A6> CreateModuleScope.createTransactionScopeTemporaryTable(
namespace: Namespace = this.rootNs, name: String, constructor: (TableConstructor.Scope<tUE>, A1, A2, A3, A4, A5, A6) -> tUE,
a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6
): Table<tUE, Nothing> =
this.createTransactionScopeTemporaryTable(namespace, name, InlineTableConstructor6(constructor, a1, a2, a3, a4, a5, a6))
public fun <tUE : Any, A1, A2, A3, A4, A5, A6> CreateModuleScope.createModuleConfiguringScopeTemporaryTable(
namespace: Namespace = this.rootNs, name: String, constructor: (TableConstructor.Scope<tUE>, A1, A2, A3, A4, A5, A6) -> tUE,
a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6
): Table<tUE, Nothing> =
this.createModuleConfiguringScopeTemporaryTable(namespace, name, InlineTableConstructor6(constructor, a1, a2, a3, a4, a5, a6))
public fun <tUE : Any, A1, A2, A3, A4, A5, A6> Module<*>.createSessionScopeTemporaryTable(
name: String, constructor: (TableConstructor.Scope<tUE>, A1, A2, A3, A4, A5, A6) -> tUE,
a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6
): Table<tUE, Nothing> =
this.createSessionScopeTemporaryTable(name, InlineTableConstructor6(constructor, a1, a2, a3, a4, a5, a6))
public fun <tUE : Any, A1, A2, A3, A4, A5, A6> Module<*>.createTransactionScopeTemporaryTable(
name: String, constructor: (TableConstructor.Scope<tUE>, A1, A2, A3, A4, A5, A6) -> tUE,
a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6
): Table<tUE, Nothing> =
this.createTransactionScopeTemporaryTable(name, InlineTableConstructor6(constructor, a1, a2, a3, a4, a5, a6))
public open class InlineTableConstructor7<tUE : Any, A1, A2, A3, A4, A5, A6, A7>(
private val constructor: (TableConstructor.Scope<tUE>, A1, A2, A3, A4, A5, A6, A7) -> tUE,
private val a1: A1, private val a2: A2, private val a3: A3, private val a4: A4, private val a5: A5, private val a6: A6, private val a7: A7
) : TableConstructor<tUE> {
override fun createTable(context: TableConstructor.Scope<tUE>): tUE {
return this.constructor(context, this.a1, this.a2, this.a3, this.a4, this.a5, this.a6, this.a7)
}
}
public fun <tUE : Any, A1, A2, A3, A4, A5, A6, A7> CreateModuleScope.createTable(
namespace: Namespace = this.rootNs, name: String, constructor: (TableConstructor.Scope<tUE>, A1, A2, A3, A4, A5, A6, A7) -> tUE,
a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7
): Table<tUE, Nothing> =
this.createTable(namespace, name, InlineTableConstructor7(constructor, a1, a2, a3, a4, a5, a6, a7))
public fun <tUE : Any, A1, A2, A3, A4, A5, A6, A7> CreateModuleScope.createSessionScopeTemporaryTable(
namespace: Namespace = this.rootNs, name: String, constructor: (TableConstructor.Scope<tUE>, A1, A2, A3, A4, A5, A6, A7) -> tUE,
a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7
): Table<tUE, Nothing> =
this.createSessionScopeTemporaryTable(namespace, name, InlineTableConstructor7(constructor, a1, a2, a3, a4, a5, a6, a7))
public fun <tUE : Any, A1, A2, A3, A4, A5, A6, A7> CreateModuleScope.createTransactionScopeTemporaryTable(
namespace: Namespace = this.rootNs, name: String, constructor: (TableConstructor.Scope<tUE>, A1, A2, A3, A4, A5, A6, A7) -> tUE,
a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7
): Table<tUE, Nothing> =
this.createTransactionScopeTemporaryTable(namespace, name, InlineTableConstructor7(constructor, a1, a2, a3, a4, a5, a6, a7))
public fun <tUE : Any, A1, A2, A3, A4, A5, A6, A7> CreateModuleScope.createModuleConfiguringScopeTemporaryTable(
namespace: Namespace = this.rootNs, name: String, constructor: (TableConstructor.Scope<tUE>, A1, A2, A3, A4, A5, A6, A7) -> tUE,
a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7
): Table<tUE, Nothing> =
this.createModuleConfiguringScopeTemporaryTable(namespace, name, InlineTableConstructor7(constructor, a1, a2, a3, a4, a5, a6, a7))
public fun <tUE : Any, A1, A2, A3, A4, A5, A6, A7> Module<*>.createSessionScopeTemporaryTable(
name: String, constructor: (TableConstructor.Scope<tUE>, A1, A2, A3, A4, A5, A6, A7) -> tUE,
a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7
): Table<tUE, Nothing> =
this.createSessionScopeTemporaryTable(name, InlineTableConstructor7(constructor, a1, a2, a3, a4, a5, a6, a7))
public fun <tUE : Any, A1, A2, A3, A4, A5, A6, A7> Module<*>.createTransactionScopeTemporaryTable(
name: String, constructor: (TableConstructor.Scope<tUE>, A1, A2, A3, A4, A5, A6, A7) -> tUE,
a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7
): Table<tUE, Nothing> =
this.createTransactionScopeTemporaryTable(name, InlineTableConstructor7(constructor, a1, a2, a3, a4, a5, a6, a7))
public open class InlineTableConstructor8<tUE : Any, A1, A2, A3, A4, A5, A6, A7, A8>(
private val constructor: (TableConstructor.Scope<tUE>, A1, A2, A3, A4, A5, A6, A7, A8) -> tUE,
private val a1: A1, private val a2: A2, private val a3: A3, private val a4: A4, private val a5: A5, private val a6: A6, private val a7: A7, private val a8: A8
) : TableConstructor<tUE> {
override fun createTable(context: TableConstructor.Scope<tUE>): tUE {
return this.constructor(context, this.a1, this.a2, this.a3, this.a4, this.a5, this.a6, this.a7, this.a8)
}
}
public fun <tUE : Any, A1, A2, A3, A4, A5, A6, A7, A8> CreateModuleScope.createTable(
namespace: Namespace = this.rootNs, name: String, constructor: (TableConstructor.Scope<tUE>, A1, A2, A3, A4, A5, A6, A7, A8) -> tUE,
a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, a8: A8
): Table<tUE, Nothing> =
this.createTable(namespace, name, InlineTableConstructor8(constructor, a1, a2, a3, a4, a5, a6, a7, a8))
public fun <tUE : Any, A1, A2, A3, A4, A5, A6, A7, A8> CreateModuleScope.createSessionScopeTemporaryTable(
namespace: Namespace = this.rootNs, name: String, constructor: (TableConstructor.Scope<tUE>, A1, A2, A3, A4, A5, A6, A7, A8) -> tUE,
a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, a8: A8
): Table<tUE, Nothing> =
this.createSessionScopeTemporaryTable(namespace, name, InlineTableConstructor8(constructor, a1, a2, a3, a4, a5, a6, a7, a8))
public fun <tUE : Any, A1, A2, A3, A4, A5, A6, A7, A8> CreateModuleScope.createTransactionScopeTemporaryTable(
namespace: Namespace = this.rootNs, name: String, constructor: (TableConstructor.Scope<tUE>, A1, A2, A3, A4, A5, A6, A7, A8) -> tUE,
a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, a8: A8
): Table<tUE, Nothing> =
this.createTransactionScopeTemporaryTable(namespace, name, InlineTableConstructor8(constructor, a1, a2, a3, a4, a5, a6, a7, a8))
public fun <tUE : Any, A1, A2, A3, A4, A5, A6, A7, A8> CreateModuleScope.createModuleConfiguringScopeTemporaryTable(
namespace: Namespace = this.rootNs, name: String, constructor: (TableConstructor.Scope<tUE>, A1, A2, A3, A4, A5, A6, A7, A8) -> tUE,
a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, a8: A8
): Table<tUE, Nothing> =
this.createModuleConfiguringScopeTemporaryTable(namespace, name, InlineTableConstructor8(constructor, a1, a2, a3, a4, a5, a6, a7, a8))
public fun <tUE : Any, A1, A2, A3, A4, A5, A6, A7, A8> Module<*>.createSessionScopeTemporaryTable(
name: String, constructor: (TableConstructor.Scope<tUE>, A1, A2, A3, A4, A5, A6, A7, A8) -> tUE,
a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, a8: A8
): Table<tUE, Nothing> =
this.createSessionScopeTemporaryTable(name, InlineTableConstructor8(constructor, a1, a2, a3, a4, a5, a6, a7, a8))
public fun <tUE : Any, A1, A2, A3, A4, A5, A6, A7, A8> Module<*>.createTransactionScopeTemporaryTable(
name: String, constructor: (TableConstructor.Scope<tUE>, A1, A2, A3, A4, A5, A6, A7, A8) -> tUE,
a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, a8: A8
): Table<tUE, Nothing> =
this.createTransactionScopeTemporaryTable(name, InlineTableConstructor8(constructor, a1, a2, a3, a4, a5, a6, a7, a8))
public open class InlineTableConstructor9<tUE : Any, A1, A2, A3, A4, A5, A6, A7, A8, A9>(
private val constructor: (TableConstructor.Scope<tUE>, A1, A2, A3, A4, A5, A6, A7, A8, A9) -> tUE,
private val a1: A1, private val a2: A2, private val a3: A3, private val a4: A4, private val a5: A5, private val a6: A6, private val a7: A7, private val a8: A8, private val a9: A9
) : TableConstructor<tUE> {
override fun createTable(context: TableConstructor.Scope<tUE>): tUE {
return this.constructor(context, this.a1, this.a2, this.a3, this.a4, this.a5, this.a6, this.a7, this.a8, this.a9)
}
}
public fun <tUE : Any, A1, A2, A3, A4, A5, A6, A7, A8, A9> CreateModuleScope.createTable(
namespace: Namespace = this.rootNs, name: String, constructor: (TableConstructor.Scope<tUE>, A1, A2, A3, A4, A5, A6, A7, A8, A9) -> tUE,
a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, a8: A8, a9: A9
): Table<tUE, Nothing> =
this.createTable(namespace, name, InlineTableConstructor9(constructor, a1, a2, a3, a4, a5, a6, a7, a8, a9))
public fun <tUE : Any, A1, A2, A3, A4, A5, A6, A7, A8, A9> CreateModuleScope.createSessionScopeTemporaryTable(
namespace: Namespace = this.rootNs, name: String, constructor: (TableConstructor.Scope<tUE>, A1, A2, A3, A4, A5, A6, A7, A8, A9) -> tUE,
a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, a8: A8, a9: A9
): Table<tUE, Nothing> =
this.createSessionScopeTemporaryTable(namespace, name, InlineTableConstructor9(constructor, a1, a2, a3, a4, a5, a6, a7, a8, a9))
public fun <tUE : Any, A1, A2, A3, A4, A5, A6, A7, A8, A9> CreateModuleScope.createTransactionScopeTemporaryTable(
namespace: Namespace = this.rootNs, name: String, constructor: (TableConstructor.Scope<tUE>, A1, A2, A3, A4, A5, A6, A7, A8, A9) -> tUE,
a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, a8: A8, a9: A9
): Table<tUE, Nothing> =
this.createTransactionScopeTemporaryTable(namespace, name, InlineTableConstructor9(constructor, a1, a2, a3, a4, a5, a6, a7, a8, a9))
public fun <tUE : Any, A1, A2, A3, A4, A5, A6, A7, A8, A9> CreateModuleScope.createModuleConfiguringScopeTemporaryTable(
namespace: Namespace = this.rootNs, name: String, constructor: (TableConstructor.Scope<tUE>, A1, A2, A3, A4, A5, A6, A7, A8, A9) -> tUE,
a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, a8: A8, a9: A9
): Table<tUE, Nothing> =
this.createModuleConfiguringScopeTemporaryTable(namespace, name, InlineTableConstructor9(constructor, a1, a2, a3, a4, a5, a6, a7, a8, a9))
public fun <tUE : Any, A1, A2, A3, A4, A5, A6, A7, A8, A9> Module<*>.createSessionScopeTemporaryTable(
name: String, constructor: (TableConstructor.Scope<tUE>, A1, A2, A3, A4, A5, A6, A7, A8, A9) -> tUE,
a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, a8: A8, a9: A9
): Table<tUE, Nothing> =
this.createSessionScopeTemporaryTable(name, InlineTableConstructor9(constructor, a1, a2, a3, a4, a5, a6, a7, a8, a9))
public fun <tUE : Any, A1, A2, A3, A4, A5, A6, A7, A8, A9> Module<*>.createTransactionScopeTemporaryTable(
name: String, constructor: (TableConstructor.Scope<tUE>, A1, A2, A3, A4, A5, A6, A7, A8, A9) -> tUE,
a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, a8: A8, a9: A9
): Table<tUE, Nothing> =
this.createTransactionScopeTemporaryTable(name, InlineTableConstructor9(constructor, a1, a2, a3, a4, a5, a6, a7, a8, a9))
public open class InlineTableConstructor10<tUE : Any, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10>(
private val constructor: (TableConstructor.Scope<tUE>, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10) -> tUE,
private val a1: A1, private val a2: A2, private val a3: A3, private val a4: A4, private val a5: A5, private val a6: A6, private val a7: A7, private val a8: A8, private val a9: A9, private val a10: A10
) : TableConstructor<tUE> {
override fun createTable(context: TableConstructor.Scope<tUE>): tUE {
return this.constructor(context, this.a1, this.a2, this.a3, this.a4, this.a5, this.a6, this.a7, this.a8, this.a9, this.a10)
}
}
public fun <tUE : Any, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10> CreateModuleScope.createTable(
namespace: Namespace = this.rootNs, name: String, constructor: (TableConstructor.Scope<tUE>, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10) -> tUE,
a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, a8: A8, a9: A9, a10: A10
): Table<tUE, Nothing> =
this.createTable(namespace, name, InlineTableConstructor10(constructor, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10))
public fun <tUE : Any, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10> CreateModuleScope.createSessionScopeTemporaryTable(
namespace: Namespace = this.rootNs, name: String, constructor: (TableConstructor.Scope<tUE>, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10) -> tUE,
a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, a8: A8, a9: A9, a10: A10
): Table<tUE, Nothing> =
this.createSessionScopeTemporaryTable(namespace, name, InlineTableConstructor10(constructor, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10))
public fun <tUE : Any, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10> CreateModuleScope.createTransactionScopeTemporaryTable(
namespace: Namespace = this.rootNs, name: String, constructor: (TableConstructor.Scope<tUE>, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10) -> tUE,
a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, a8: A8, a9: A9, a10: A10
): Table<tUE, Nothing> =
this.createTransactionScopeTemporaryTable(namespace, name, InlineTableConstructor10(constructor, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10))
public fun <tUE : Any, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10> CreateModuleScope.createModuleConfiguringScopeTemporaryTable(
namespace: Namespace = this.rootNs, name: String, constructor: (TableConstructor.Scope<tUE>, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10) -> tUE,
a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, a8: A8, a9: A9, a10: A10
): Table<tUE, Nothing> =
this.createModuleConfiguringScopeTemporaryTable(namespace, name, InlineTableConstructor10(constructor, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10))
public fun <tUE : Any, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10> Module<*>.createSessionScopeTemporaryTable(
name: String, constructor: (TableConstructor.Scope<tUE>, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10) -> tUE,
a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, a8: A8, a9: A9, a10: A10
): Table<tUE, Nothing> =
this.createSessionScopeTemporaryTable(name, InlineTableConstructor10(constructor, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10))
public fun <tUE : Any, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10> Module<*>.createTransactionScopeTemporaryTable(
name: String, constructor: (TableConstructor.Scope<tUE>, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10) -> tUE,
a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, a8: A8, a9: A9, a10: A10
): Table<tUE, Nothing> =
this.createTransactionScopeTemporaryTable(name, InlineTableConstructor10(constructor, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10))

View File

@ -2,6 +2,6 @@ package ru.landgrafhomyak.db.serdha0.user_commons.executors
import ru.landgrafhomyak.db.serdha0.api.runtime.OutputRow import ru.landgrafhomyak.db.serdha0.api.runtime.OutputRow
public fun interface RowConsumer0<qUE : Any, R> { public interface RowConsumer0<qUE : Any, R> {
public fun transformRow(row: OutputRow<qUE>): R public fun transformRow(row: OutputRow<qUE>): R
} }

View File

@ -2,6 +2,6 @@ package ru.landgrafhomyak.db.serdha0.user_commons.executors
import ru.landgrafhomyak.db.serdha0.api.runtime.OutputRow import ru.landgrafhomyak.db.serdha0.api.runtime.OutputRow
public fun interface RowConsumer1<qUE : Any, R> { public interface RowConsumer1<qUE : Any, R> {
public fun transformRow(row: OutputRow<qUE>, index: Int): R public fun transformRow(row: OutputRow<qUE>, index: Int): R
} }

View File

@ -5,25 +5,100 @@ package ru.landgrafhomyak.db.serdha0.user_commons.executors
import kotlin.contracts.InvocationKind import kotlin.contracts.InvocationKind
import kotlin.contracts.contract import kotlin.contracts.contract
import kotlin.jvm.JvmName import kotlin.jvm.JvmName
import ru.landgrafhomyak.db.serdha0.api.LowLevelApi
import ru.landgrafhomyak.db.serdha0.api.runtime.InputRow
import ru.landgrafhomyak.db.serdha0.api.runtime.OutputRow
@Suppress("FunctionName") @Suppress("FunctionName")
@PublishedApi @PublishedApi
internal inline fun <R> _safeAutoClose(onAbort: () -> Unit = {}, action: () -> R): R { internal inline fun <R> _safeAutoClose(onAbort: () -> Unit = {}, onSuccess: () -> Unit = {}, action: () -> R): R {
contract { contract {
callsInPlace(action, InvocationKind.EXACTLY_ONCE) callsInPlace(action, InvocationKind.EXACTLY_ONCE)
callsInPlace(onAbort, InvocationKind.AT_MOST_ONCE) callsInPlace(onAbort, InvocationKind.AT_MOST_ONCE)
callsInPlace(onSuccess, InvocationKind.EXACTLY_ONCE)
} }
val ret: R val ret: R
var wasError = false
try { try {
ret = action() ret = action()
} catch (e1: Throwable) { } catch (e1: Throwable) {
wasError = true
try { try {
onAbort() onAbort()
} catch (e2: Throwable) { } catch (e2: Throwable) {
e1.addSuppressed(e2) e1.addSuppressed(e2)
} }
throw e1 throw e1
} finally {
if (!wasError)
onSuccess()
} }
return ret return ret
} }
@Suppress("ClassName")
public class _ReturnFromInputError : Error("Returning from outer function from input row initializer block is undefined behaviour")
@Suppress("FunctionName", "REDUNDANT_INLINE_SUSPEND_FUNCTION_TYPE")
@LowLevelApi
public suspend inline fun <I : InputRow._Scope<*, O>, O : OutputRow._Iterator<*, Unit>> _safeAutoClose_IO(
iRow: I,
inputAction: suspend (I) -> Unit,
outputAction: suspend (O) -> Unit,
) {
contract {
callsInPlace(inputAction, InvocationKind.EXACTLY_ONCE)
callsInPlace(outputAction, InvocationKind.EXACTLY_ONCE)
}
@Suppress("VARIABLE_WITH_REDUNDANT_INITIALIZER")
var crossReturned = true
_safeAutoClose(
onAbort = { iRow._abort() },
action = { inputAction(iRow); crossReturned = false },
onSuccess = {
if (crossReturned) throw _ReturnFromInputError()
val oRow = iRow._finish()
_safeAutoClose(
onAbort = { oRow._abort() },
action = { outputAction(oRow) },
onSuccess = { oRow._finish() }
)
}
)
}
@Suppress("FunctionName", "REDUNDANT_INLINE_SUSPEND_FUNCTION_TYPE")
@LowLevelApi
public suspend inline fun <I : InputRow._Scope<*, Unit>> _safeAutoClose_I(
iRow: I,
inputAction: suspend (I) -> Unit,
) {
contract {
callsInPlace(inputAction, InvocationKind.EXACTLY_ONCE)
}
_safeAutoClose(
onAbort = { iRow._abort() },
action = { inputAction(iRow) },
onSuccess = { iRow._finish() }
)
}
@Suppress("FunctionName", "REDUNDANT_INLINE_SUSPEND_FUNCTION_TYPE")
@LowLevelApi
public suspend inline fun <O : OutputRow._Iterator<*, Unit>> _safeAutoClose_O(
oRow: O,
outputAction: suspend (O) -> Unit,
) {
contract {
callsInPlace(outputAction, InvocationKind.EXACTLY_ONCE)
}
_safeAutoClose(
onAbort = { oRow._abort() },
action = { outputAction(oRow) },
onSuccess = { oRow._finish() }
)
}
public fun test() {
}

View File

@ -4,9 +4,12 @@
package ru.landgrafhomyak.db.serdha0.user_commons.executors package ru.landgrafhomyak.db.serdha0.user_commons.executors
import kotlin.contracts.InvocationKind
import kotlin.contracts.contract
import kotlin.jvm.JvmName import kotlin.jvm.JvmName
import ru.landgrafhomyak.db.serdha0.api.LowLevelApi import ru.landgrafhomyak.db.serdha0.api.LowLevelApi
import ru.landgrafhomyak.db.serdha0.api.queries._Query import ru.landgrafhomyak.db.serdha0.api.queries._Query
import ru.landgrafhomyak.db.serdha0.api.runtime.OutputRow
import ru.landgrafhomyak.db.serdha0.api.runtime.Transaction import ru.landgrafhomyak.db.serdha0.api.runtime.Transaction
public class ExpectedOneRowException : Error("Expected at least one row, but table is empty") public class ExpectedOneRowException : Error("Expected at least one row, but table is empty")
@ -15,154 +18,195 @@ public class TooManyRowsException : Error("Expected exactly one row, but got mor
public suspend inline fun <qUE : Any, R> Transaction.selectExactlyOneOrError( public suspend inline fun <qUE : Any, R> Transaction.selectExactlyOneOrError(
compiledQuery: _Query.Params2Table<qUE>, compiledQuery: _Query.Params2Table<qUE>,
params: RowProducer0<qUE>, params: RowProducer0<qUE>,
result: RowConsumer0<qUE, R> result: (OutputRow<qUE>) -> R
): R { ): R {
val iRow = this._executeQuery(compiledQuery) contract {
_safeAutoClose(onAbort = { iRow._abort() }) { callsInPlace(result, InvocationKind.EXACTLY_ONCE)
params.initializeRow(iRow)
} }
val oRow = iRow._finish() _safeAutoClose_IO(
val ret: R iRow = this._executeQuery(compiledQuery),
_safeAutoClose(onAbort = { oRow._abort() }) { inputAction = params::initializeRow,
outputAction = { oRow ->
if (!oRow._next()) if (!oRow._next())
throw ExpectedOneRowException() throw ExpectedOneRowException()
ret = result.transformRow(oRow) _safeAutoClose(onSuccess = { if (oRow._next()) throw TooManyRowsException() }) {
if (oRow._next()) return result(oRow)
throw TooManyRowsException()
} }
oRow._finish() }
return ret )
}
public suspend inline fun <qUE : Any, R> Transaction.selectExactlyOneOrError(
compiledQuery: _Query.Params2Table<qUE>,
params: RowProducer0<qUE>,
result: RowConsumer0<qUE, R>
): R = this.selectExactlyOneOrError(compiledQuery, params, result::transformRow)
public suspend inline fun <qUE : Any, R> Transaction.selectExactlyOneOrError(
compiledQuery: _Query.Void2Table<qUE>,
result: (OutputRow<qUE>) -> R
): R {
contract {
callsInPlace(result, InvocationKind.EXACTLY_ONCE)
}
_safeAutoClose_O(
oRow = this._executeQuery(compiledQuery),
outputAction = { oRow ->
if (!oRow._next())
throw ExpectedOneRowException()
_safeAutoClose(onSuccess = { if (oRow._next()) throw TooManyRowsException() }) {
return result(oRow)
}
}
)
} }
public suspend inline fun <qUE : Any, R> Transaction.selectExactlyOneOrError( public suspend inline fun <qUE : Any, R> Transaction.selectExactlyOneOrError(
compiledQuery: _Query.Void2Table<qUE>, compiledQuery: _Query.Void2Table<qUE>,
result: RowConsumer0<qUE, R> result: RowConsumer0<qUE, R>
): R { ): R = this.selectExactlyOneOrError(compiledQuery, result::transformRow)
val oRow = this._executeQuery(compiledQuery)
val ret: R public suspend inline fun <qUE : Any, R> Transaction.selectExactlyOneOrNull(
_safeAutoClose(onAbort = { oRow._abort() }) { compiledQuery: _Query.Params2Table<qUE>,
if (!oRow._next()) params: RowProducer0<qUE>,
throw ExpectedOneRowException() result: (OutputRow<qUE>) -> R
ret = result.transformRow(oRow) ): R? {
if (oRow._next()) contract {
throw TooManyRowsException() callsInPlace(result, InvocationKind.AT_MOST_ONCE)
} }
oRow._finish() _safeAutoClose_IO(
return ret iRow = this._executeQuery(compiledQuery),
inputAction = params::initializeRow,
outputAction = { oRow ->
if (!oRow._next())
return null
_safeAutoClose(onSuccess = { if (oRow._next()) throw TooManyRowsException() }) {
return result(oRow)
}
}
)
} }
public suspend inline fun <qUE : Any, R> Transaction.selectExactlyOneOrNull( public suspend inline fun <qUE : Any, R> Transaction.selectExactlyOneOrNull(
compiledQuery: _Query.Params2Table<qUE>, compiledQuery: _Query.Params2Table<qUE>,
params: RowProducer0<qUE>, params: RowProducer0<qUE>,
result: RowConsumer0<qUE, R> result: RowConsumer0<qUE, R>
): R? = this.selectExactlyOneOrNull(compiledQuery, params, result::transformRow)
public suspend inline fun <qUE : Any, R> Transaction.selectExactlyOneOrNull(
compiledQuery: _Query.Void2Table<qUE>,
result: (OutputRow<qUE>) -> R
): R? { ): R? {
val iRow = this._executeQuery(compiledQuery) contract {
_safeAutoClose(onAbort = { iRow._abort() }) { callsInPlace(result, InvocationKind.AT_MOST_ONCE)
params.initializeRow(iRow)
} }
val oRow = iRow._finish() _safeAutoClose_O(
val ret: R? oRow = this._executeQuery(compiledQuery),
_safeAutoClose(onAbort = { oRow._abort() }) { outputAction = { oRow ->
if (!oRow._next()) { if (!oRow._next())
ret = null return null
return@_safeAutoClose _safeAutoClose(onSuccess = { if (oRow._next()) throw TooManyRowsException() }) {
return result(oRow)
} }
ret = result.transformRow(oRow)
if (oRow._next())
throw TooManyRowsException()
} }
oRow._finish() )
return ret
} }
public suspend inline fun <qUE : Any, R> Transaction.selectExactlyOneOrNull( public suspend inline fun <qUE : Any, R> Transaction.selectExactlyOneOrNull(
compiledQuery: _Query.Void2Table<qUE>, compiledQuery: _Query.Void2Table<qUE>,
result: RowConsumer0<qUE, R> result: RowConsumer0<qUE, R>
): R? { ): R? = this.selectExactlyOneOrNull(compiledQuery, result::transformRow)
val oRow = this._executeQuery(compiledQuery)
val ret: R? public suspend inline fun <qUE : Any, R> Transaction.selectFirstOrError(
_safeAutoClose(onAbort = { oRow._abort() }) { compiledQuery: _Query.Params2Table<qUE>,
if (!oRow._next()) { params: RowProducer0<qUE>,
ret = null result: (OutputRow<qUE>) -> R
return@_safeAutoClose ): R {
contract {
callsInPlace(result, InvocationKind.EXACTLY_ONCE)
} }
ret = result.transformRow(oRow) _safeAutoClose_IO(
if (oRow._next()) iRow = this._executeQuery(compiledQuery),
throw TooManyRowsException() inputAction = params::initializeRow,
outputAction = { oRow ->
if (!oRow._next())
throw ExpectedOneRowException()
return result(oRow)
} }
oRow._finish() )
return ret
} }
public suspend inline fun <qUE : Any, R> Transaction.selectFirstOrError( public suspend inline fun <qUE : Any, R> Transaction.selectFirstOrError(
compiledQuery: _Query.Params2Table<qUE>, compiledQuery: _Query.Params2Table<qUE>,
params: RowProducer0<qUE>, params: RowProducer0<qUE>,
result: RowConsumer0<qUE, R> result: RowConsumer0<qUE, R>
): R = this.selectFirstOrError(compiledQuery, params, result::transformRow)
public suspend inline fun <qUE : Any, R> Transaction.selectFirstOrError(
compiledQuery: _Query.Void2Table<qUE>,
result: (OutputRow<qUE>) -> R
): R { ): R {
val iRow = this._executeQuery(compiledQuery) contract {
_safeAutoClose(onAbort = { iRow._abort() }) { callsInPlace(result, InvocationKind.EXACTLY_ONCE)
params.initializeRow(iRow)
} }
val oRow = iRow._finish() _safeAutoClose_O(
val ret: R oRow = this._executeQuery(compiledQuery),
_safeAutoClose(onAbort = { oRow._abort() }) { outputAction = { oRow ->
if (!oRow._next()) if (!oRow._next())
throw ExpectedOneRowException() throw ExpectedOneRowException()
ret = result.transformRow(oRow) return result(oRow)
} }
oRow._finish() )
return ret
} }
public suspend inline fun <qUE : Any, R> Transaction.selectFirstOrError( public suspend inline fun <qUE : Any, R> Transaction.selectFirstOrError(
compiledQuery: _Query.Void2Table<qUE>, compiledQuery: _Query.Void2Table<qUE>,
result: RowConsumer0<qUE, R> result: RowConsumer0<qUE, R>
): R { ): R = this.selectFirstOrError(compiledQuery, result::transformRow)
val oRow = this._executeQuery(compiledQuery)
val ret: R public suspend inline fun <qUE : Any, R> Transaction.selectFirstOrNull(
_safeAutoClose(onAbort = { oRow._abort() }) { compiledQuery: _Query.Params2Table<qUE>,
if (!oRow._next()) params: RowProducer0<qUE>,
throw ExpectedOneRowException() result: (OutputRow<qUE>) -> R
ret = result.transformRow(oRow) ): R? {
contract {
callsInPlace(result, InvocationKind.AT_MOST_ONCE)
} }
oRow._finish() _safeAutoClose_IO(
return ret iRow = this._executeQuery(compiledQuery),
inputAction = params::initializeRow,
outputAction = { oRow ->
if (!oRow._next())
return null
return result(oRow)
}
)
} }
public suspend inline fun <qUE : Any, R> Transaction.selectFirstOrNull( public suspend inline fun <qUE : Any, R> Transaction.selectFirstOrNull(
compiledQuery: _Query.Params2Table<qUE>, compiledQuery: _Query.Params2Table<qUE>,
params: RowProducer0<qUE>, params: RowProducer0<qUE>,
result: RowConsumer0<qUE, R> result: RowConsumer0<qUE, R>
): R? = this.selectFirstOrNull(compiledQuery, params, result::transformRow)
public suspend inline fun <qUE : Any, R> Transaction.selectFirstOrNull(
compiledQuery: _Query.Void2Table<qUE>,
result: (OutputRow<qUE>) -> R
): R? { ): R? {
val iRow = this._executeQuery(compiledQuery) contract {
_safeAutoClose(onAbort = { iRow._abort() }) { callsInPlace(result, InvocationKind.AT_MOST_ONCE)
params.initializeRow(iRow)
} }
val oRow = iRow._finish() _safeAutoClose_O(
val ret: R? oRow = this._executeQuery(compiledQuery),
_safeAutoClose(onAbort = { oRow._abort() }) { outputAction = { oRow ->
if (!oRow._next()) { if (!oRow._next())
ret = null return null
return@_safeAutoClose return result(oRow)
} }
ret = result.transformRow(oRow) )
}
oRow._finish()
return ret
} }
public suspend inline fun <qUE : Any, R> Transaction.selectFirstOrNull( public suspend inline fun <qUE : Any, R> Transaction.selectFirstOrNull(
compiledQuery: _Query.Void2Table<qUE>, compiledQuery: _Query.Void2Table<qUE>,
result: RowConsumer0<qUE, R> result: RowConsumer0<qUE, R>
): R? { ): R? = this.selectFirstOrNull(compiledQuery, result::transformRow)
val oRow = this._executeQuery(compiledQuery)
val ret: R?
_safeAutoClose(onAbort = { oRow._abort() }) {
if (!oRow._next()) {
ret = null
return@_safeAutoClose
}
ret = result.transformRow(oRow)
}
oRow._finish()
return ret
}

View File

@ -4,71 +4,128 @@
package ru.landgrafhomyak.db.serdha0.user_commons.executors package ru.landgrafhomyak.db.serdha0.user_commons.executors
import kotlin.contracts.InvocationKind
import kotlin.contracts.contract
import kotlin.jvm.JvmName import kotlin.jvm.JvmName
import ru.landgrafhomyak.db.serdha0.api.LowLevelApi import ru.landgrafhomyak.db.serdha0.api.LowLevelApi
import ru.landgrafhomyak.db.serdha0.api.queries._Query import ru.landgrafhomyak.db.serdha0.api.queries._Query
import ru.landgrafhomyak.db.serdha0.api.runtime.OutputRow
import ru.landgrafhomyak.db.serdha0.api.runtime.Transaction import ru.landgrafhomyak.db.serdha0.api.runtime.Transaction
public suspend inline fun <qUE : Any> Transaction.select( public suspend inline fun <qUE : Any> Transaction.select(
compiledQuery: _Query.Params2Table<qUE>, compiledQuery: _Query.Params2Table<qUE>,
params: RowProducer0<qUE>, params: RowProducer0<qUE>,
transform: RowConsumer0<qUE, Unit> transform: (OutputRow<qUE>) -> Unit
) { ) {
val iRow = this._executeQuery(compiledQuery) contract {
_safeAutoClose(onAbort = { iRow._abort() }) { callsInPlace(transform, InvocationKind.UNKNOWN)
params.initializeRow(iRow)
} }
val oRow = iRow._finish() _safeAutoClose_IO(
_safeAutoClose(onAbort = { oRow._abort() }) { iRow = this._executeQuery(compiledQuery),
inputAction = params::initializeRow,
outputAction = { oRow ->
while (oRow._next()) while (oRow._next())
transform.transformRow(oRow) transform(oRow)
} }
oRow._finish() )
}
public suspend inline fun <qUE : Any> Transaction.select(
compiledQuery: _Query.Params2Table<qUE>,
params: RowProducer0<qUE>,
transform: RowConsumer0<qUE, Unit>
): Unit = this.select(compiledQuery, params, transform::transformRow)
public suspend inline fun <qUE : Any> Transaction.select(
compiledQuery: _Query.Void2Table<qUE>,
transform: (OutputRow<qUE>) -> Unit
) {
contract {
callsInPlace(transform, InvocationKind.UNKNOWN)
}
_safeAutoClose_O(
oRow = this._executeQuery(compiledQuery),
outputAction = { oRow ->
while (oRow._next())
transform(oRow)
}
)
} }
public suspend inline fun <qUE : Any> Transaction.select( public suspend inline fun <qUE : Any> Transaction.select(
compiledQuery: _Query.Void2Table<qUE>, compiledQuery: _Query.Void2Table<qUE>,
transform: RowConsumer0<qUE, Unit> transform: RowConsumer0<qUE, Unit>
) { ): Unit = this.select(compiledQuery, transform::transformRow)
val oRow = this._executeQuery(compiledQuery)
_safeAutoClose(onAbort = { oRow._abort() }) { public suspend inline fun <qUE : Any, E> Transaction.mapRows(
while (oRow._next()) compiledQuery: _Query.Params2Table<qUE>,
transform.transformRow(oRow) params: RowProducer0<qUE>,
transform: (OutputRow<qUE>) -> E
): List<E> {
contract {
callsInPlace(transform, InvocationKind.UNKNOWN)
} }
oRow._finish() _safeAutoClose_IO(
iRow = this._executeQuery(compiledQuery),
inputAction = params::initializeRow,
outputAction = { oRow ->
val dst = ArrayList<E>()
while (oRow._next())
dst.add(transform(oRow))
return dst
}
)
} }
public suspend inline fun <qUE : Any, E> Transaction.mapRows( public suspend inline fun <qUE : Any, E> Transaction.mapRows(
compiledQuery: _Query.Params2Table<qUE>, compiledQuery: _Query.Params2Table<qUE>,
params: RowProducer0<qUE>, params: RowProducer0<qUE>,
transform: RowConsumer0<qUE, E> transform: RowConsumer0<qUE, E>
): List<E> = this.mapRows(compiledQuery, params, transform::transformRow)
public suspend inline fun <qUE : Any, E> Transaction.mapRows(
compiledQuery: _Query.Void2Table<qUE>,
transform: (OutputRow<qUE>) -> E
): List<E> { ): List<E> {
val iRow = this._executeQuery(compiledQuery) contract {
_safeAutoClose(onAbort = { iRow._abort() }) { callsInPlace(transform, InvocationKind.UNKNOWN)
params.initializeRow(iRow)
} }
val oRow = iRow._finish() _safeAutoClose_O(
val out = ArrayList<E>() oRow = this._executeQuery(compiledQuery),
_safeAutoClose(onAbort = { oRow._abort() }) { outputAction = { oRow ->
val dst = ArrayList<E>()
while (oRow._next()) while (oRow._next())
out.add(transform.transformRow(oRow)) dst.add(transform(oRow))
return dst
} }
oRow._finish() )
return out
} }
public suspend inline fun <qUE : Any, E> Transaction.mapRows( public suspend inline fun <qUE : Any, E> Transaction.mapRows(
compiledQuery: _Query.Void2Table<qUE>, compiledQuery: _Query.Void2Table<qUE>,
transform: RowConsumer0<qUE, E> transform: RowConsumer0<qUE, E>
): List<E> = this.mapRows(compiledQuery, transform::transformRow)
public suspend inline fun <qUE : Any, E> Transaction.mapRowsIndexed(
compiledQuery: _Query.Params2Table<qUE>,
params: RowProducer0<qUE>,
firstIndex: Int = 0,
transform: (OutputRow<qUE>, Int) -> E
): List<E> { ): List<E> {
val oRow = this._executeQuery(compiledQuery) contract {
val out = ArrayList<E>() callsInPlace(transform, InvocationKind.UNKNOWN)
_safeAutoClose(onAbort = { oRow._abort() }) {
while (oRow._next())
out.add(transform.transformRow(oRow))
} }
oRow._finish() _safeAutoClose_IO(
return out iRow = this._executeQuery(compiledQuery),
inputAction = params::initializeRow,
outputAction = { oRow ->
val dst = ArrayList<E>()
var i = firstIndex
while (oRow._next())
dst.add(transform(oRow, i++))
return dst
}
)
} }
public suspend inline fun <qUE : Any, E> Transaction.mapRowsIndexed( public suspend inline fun <qUE : Any, E> Transaction.mapRowsIndexed(
@ -76,36 +133,52 @@ public suspend inline fun <qUE : Any, E> Transaction.mapRowsIndexed(
params: RowProducer0<qUE>, params: RowProducer0<qUE>,
firstIndex: Int = 0, firstIndex: Int = 0,
transform: RowConsumer1<qUE, E> transform: RowConsumer1<qUE, E>
): List<E> = this.mapRowsIndexed(compiledQuery, params, firstIndex, transform::transformRow)
public suspend inline fun <qUE : Any, E> Transaction.mapRowsIndexed(
compiledQuery: _Query.Void2Table<qUE>,
firstIndex: Int = 0,
transform: (OutputRow<qUE>, Int) -> E
): List<E> { ): List<E> {
val iRow = this._executeQuery(compiledQuery) contract {
_safeAutoClose(onAbort = { iRow._abort() }) { callsInPlace(transform, InvocationKind.UNKNOWN)
params.initializeRow(iRow)
} }
val oRow = iRow._finish() _safeAutoClose_O(
val out = ArrayList<E>() oRow = this._executeQuery(compiledQuery),
_safeAutoClose(onAbort = { oRow._abort() }) { outputAction = { oRow ->
val dst = ArrayList<E>()
var i = firstIndex var i = firstIndex
while (oRow._next()) while (oRow._next())
out.add(transform.transformRow(oRow, i++)) dst.add(transform(oRow, i++))
return dst
} }
oRow._finish() )
return out
} }
public suspend inline fun <qUE : Any, E> Transaction.mapRowsIndexed( public suspend inline fun <qUE : Any, E> Transaction.mapRowsIndexed(
compiledQuery: _Query.Void2Table<qUE>, compiledQuery: _Query.Void2Table<qUE>,
firstIndex: Int = 0, firstIndex: Int = 0,
transform: RowConsumer1<qUE, E> transform: RowConsumer1<qUE, E>
): List<E> { ): List<E> = this.mapRowsIndexed(compiledQuery, firstIndex, transform::transformRow)
val oRow = this._executeQuery(compiledQuery)
val out = ArrayList<E>() public suspend inline fun <qUE : Any, E, C : MutableCollection<E>> Transaction.mapRowsTo(
_safeAutoClose(onAbort = { oRow._abort() }) { compiledQuery: _Query.Params2Table<qUE>,
var i = firstIndex params: RowProducer0<qUE>,
while (oRow._next()) dst: C,
out.add(transform.transformRow(oRow, i++)) transform: (OutputRow<qUE>) -> E
): C {
contract {
callsInPlace(transform, InvocationKind.UNKNOWN)
} }
oRow._finish() _safeAutoClose_IO(
return out iRow = this._executeQuery(compiledQuery),
inputAction = params::initializeRow,
outputAction = { oRow ->
while (oRow._next())
dst.add(transform(oRow))
return dst
}
)
} }
public suspend inline fun <qUE : Any, E, C : MutableCollection<E>> Transaction.mapRowsTo( public suspend inline fun <qUE : Any, E, C : MutableCollection<E>> Transaction.mapRowsTo(
@ -113,100 +186,134 @@ public suspend inline fun <qUE : Any, E, C : MutableCollection<E>> Transaction.m
params: RowProducer0<qUE>, params: RowProducer0<qUE>,
dst: C, dst: C,
transform: RowConsumer0<qUE, E> transform: RowConsumer0<qUE, E>
): C = this.mapRowsTo(compiledQuery, params, dst, transform::transformRow)
public suspend inline fun <qUE : Any, E, C : MutableCollection<E>> Transaction.mapRowsTo(
compiledQuery: _Query.Void2Table<qUE>,
dst: C,
transform: (OutputRow<qUE>) -> E
): C { ): C {
val iRow = this._executeQuery(compiledQuery) contract {
_safeAutoClose(onAbort = { iRow._abort() }) { callsInPlace(transform, InvocationKind.UNKNOWN)
params.initializeRow(iRow)
} }
val oRow = iRow._finish() _safeAutoClose_O(
_safeAutoClose(onAbort = { oRow._abort() }) { oRow = this._executeQuery(compiledQuery),
outputAction = { oRow ->
while (oRow._next()) while (oRow._next())
dst.add(transform.transformRow(oRow)) dst.add(transform(oRow))
}
oRow._finish()
return dst return dst
} }
)
}
public suspend inline fun <qUE : Any, E, C : MutableCollection<E>> Transaction.mapRowsTo( public suspend inline fun <qUE : Any, E, C : MutableCollection<E>> Transaction.mapRowsTo(
compiledQuery: _Query.Void2Table<qUE>, compiledQuery: _Query.Void2Table<qUE>,
dst: C, dst: C,
transform: RowConsumer0<qUE, E> transform: RowConsumer0<qUE, E>
): C = this.mapRowsTo(compiledQuery, dst, transform::transformRow)
public suspend inline fun <qUE : Any, E, C : MutableCollection<E>> Transaction.mapRowsIndexedTo(
compiledQuery: _Query.Params2Table<qUE>,
params: RowProducer0<qUE>,
dst: C, firstIndex: Int = 0,
transform: (OutputRow<qUE>, Int) -> E
): C { ): C {
val oRow = this._executeQuery(compiledQuery) contract {
_safeAutoClose(onAbort = { oRow._abort() }) { callsInPlace(transform, InvocationKind.UNKNOWN)
while (oRow._next())
dst.add(transform.transformRow(oRow))
} }
oRow._finish() _safeAutoClose_IO(
iRow = this._executeQuery(compiledQuery),
inputAction = params::initializeRow,
outputAction = { oRow ->
var i = firstIndex
while (oRow._next())
dst.add(transform(oRow, i++))
return dst return dst
} }
)
}
public suspend inline fun <qUE : Any, E, C : MutableCollection<E>> Transaction.mapRowsIndexedTo( public suspend inline fun <qUE : Any, E, C : MutableCollection<E>> Transaction.mapRowsIndexedTo(
compiledQuery: _Query.Params2Table<qUE>, compiledQuery: _Query.Params2Table<qUE>,
params: RowProducer0<qUE>, params: RowProducer0<qUE>,
dst: C, firstIndex: Int = 0, dst: C, firstIndex: Int = 0,
transform: RowConsumer1<qUE, E> transform: RowConsumer1<qUE, E>
): C = this.mapRowsIndexedTo(compiledQuery, params, dst, firstIndex, transform::transformRow)
public suspend inline fun <qUE : Any, E, C : MutableCollection<E>> Transaction.mapRowsIndexedTo(
compiledQuery: _Query.Void2Table<qUE>,
dst: C, firstIndex: Int = 0,
transform: (OutputRow<qUE>, Int) -> E
): C { ): C {
val iRow = this._executeQuery(compiledQuery) contract {
_safeAutoClose(onAbort = { iRow._abort() }) { callsInPlace(transform, InvocationKind.UNKNOWN)
params.initializeRow(iRow)
} }
val oRow = iRow._finish() _safeAutoClose_O(
_safeAutoClose(onAbort = { oRow._abort() }) { oRow = this._executeQuery(compiledQuery),
outputAction = { oRow ->
var i = firstIndex var i = firstIndex
while (oRow._next()) while (oRow._next())
dst.add(transform.transformRow(oRow, i++)) dst.add(transform(oRow, i++))
}
oRow._finish()
return dst return dst
} }
)
}
public suspend inline fun <qUE : Any, E, C : MutableCollection<E>> Transaction.mapRowsIndexedTo( public suspend inline fun <qUE : Any, E, C : MutableCollection<E>> Transaction.mapRowsIndexedTo(
compiledQuery: _Query.Void2Table<qUE>, compiledQuery: _Query.Void2Table<qUE>,
dst: C, firstIndex: Int = 0, dst: C, firstIndex: Int = 0,
transform: RowConsumer1<qUE, E> transform: RowConsumer1<qUE, E>
): C { ): C = this.mapRowsIndexedTo(compiledQuery, dst, firstIndex, transform::transformRow)
val oRow = this._executeQuery(compiledQuery)
_safeAutoClose(onAbort = { oRow._abort() }) { public suspend inline fun <qUE : Any, E> Transaction.mapRowsTo(
var i = firstIndex compiledQuery: _Query.Params2Table<qUE>,
while (oRow._next()) params: RowProducer0<qUE>,
dst.add(transform.transformRow(oRow, i++)) dst: Array<E>, dstOffset: Int = 0,
transform: (OutputRow<qUE>) -> E
): Array<E> {
contract {
callsInPlace(transform, InvocationKind.UNKNOWN)
} }
oRow._finish() _safeAutoClose_IO(
iRow = this._executeQuery(compiledQuery),
inputAction = params::initializeRow,
outputAction = { oRow ->
var i = dstOffset
while (oRow._next())
dst[i++] = transform(oRow)
return dst return dst
} }
)
}
public suspend inline fun <qUE : Any, E> Transaction.mapRowsTo( public suspend inline fun <qUE : Any, E> Transaction.mapRowsTo(
compiledQuery: _Query.Params2Table<qUE>, compiledQuery: _Query.Params2Table<qUE>,
params: RowProducer0<qUE>, params: RowProducer0<qUE>,
dst: Array<E>, dstOffset: Int = 0, dst: Array<E>, dstOffset: Int = 0,
transform: RowConsumer0<qUE, E> transform: RowConsumer0<qUE, E>
): Array<E> = this.mapRowsTo(compiledQuery, params, dst, dstOffset, transform::transformRow)
public suspend inline fun <qUE : Any, E> Transaction.mapRowsTo(
compiledQuery: _Query.Void2Table<qUE>,
dst: Array<E>, dstOffset: Int = 0,
transform: (OutputRow<qUE>) -> E
): Array<E> { ): Array<E> {
val iRow = this._executeQuery(compiledQuery) contract {
_safeAutoClose(onAbort = { iRow._abort() }) { callsInPlace(transform, InvocationKind.UNKNOWN)
params.initializeRow(iRow)
} }
val oRow = iRow._finish() _safeAutoClose_O(
_safeAutoClose(onAbort = { oRow._abort() }) { oRow = this._executeQuery(compiledQuery),
outputAction = { oRow ->
var i = dstOffset var i = dstOffset
while (oRow._next()) while (oRow._next())
dst[i++] = transform.transformRow(oRow) dst[i++] = transform(oRow)
}
oRow._finish()
return dst return dst
} }
)
}
public suspend inline fun <qUE : Any, E> Transaction.mapRowsTo( public suspend inline fun <qUE : Any, E> Transaction.mapRowsTo(
compiledQuery: _Query.Void2Table<qUE>, compiledQuery: _Query.Void2Table<qUE>,
dst: Array<E>, dstOffset: Int = 0, dst: Array<E>, dstOffset: Int = 0,
transform: RowConsumer0<qUE, E> transform: RowConsumer0<qUE, E>
): Array<E> { ): Array<E> = this.mapRowsTo(compiledQuery, dst, dstOffset, transform::transformRow)
val oRow = this._executeQuery(compiledQuery)
_safeAutoClose(onAbort = { oRow._abort() }) {
var i = dstOffset
while (oRow._next())
dst[i++] = transform.transformRow(oRow)
}
oRow._finish()
return dst
}

View File

@ -13,20 +13,19 @@ public suspend inline fun <qUE : Any> Transaction.executeWithParams(
compiledQuery: _Query.Params2Void<qUE>, compiledQuery: _Query.Params2Void<qUE>,
params: RowProducer0<qUE> params: RowProducer0<qUE>
) { ) {
val iRow = this._executeQuery(compiledQuery) _safeAutoClose_I(
_safeAutoClose(onAbort = { iRow._abort() }) { iRow = this._executeQuery(compiledQuery),
params.initializeRow(iRow) inputAction = params::initializeRow
} )
iRow._finish()
} }
public suspend inline fun <qUE : Any> Transaction.executeWithParams( public suspend inline fun <qUE : Any> Transaction.executeWithParams(
compiledQuery: _Query.Params2Table<qUE>, compiledQuery: _Query.Params2Table<qUE>,
params: RowProducer0<qUE> params: RowProducer0<qUE>
) { ) {
val iRow = this._executeQuery(compiledQuery) _safeAutoClose_IO(
_safeAutoClose(onAbort = { iRow._abort() }) { iRow = this._executeQuery(compiledQuery),
params.initializeRow(iRow) inputAction = params::initializeRow,
} outputAction = {}
iRow._finish()._finish() )
} }

View File

@ -4,7 +4,6 @@
package ru.landgrafhomyak.db.serdha0.user_commons.executors package ru.landgrafhomyak.db.serdha0.user_commons.executors
import kotlin.contracts.contract
import kotlin.jvm.JvmName import kotlin.jvm.JvmName
import ru.landgrafhomyak.db.serdha0.api.LowLevelApi import ru.landgrafhomyak.db.serdha0.api.LowLevelApi
import ru.landgrafhomyak.db.serdha0.api.queries._Query import ru.landgrafhomyak.db.serdha0.api.queries._Query
@ -15,14 +14,15 @@ public suspend inline fun <qUE : Any, E> Transaction.mapToRows(
collection: Iterable<E>, collection: Iterable<E>,
transform: RowProducer1<qUE, E> transform: RowProducer1<qUE, E>
) { ) {
val iRow = this._executeQuery(compiledQuery) _safeAutoClose_I(
_safeAutoClose(onAbort = { iRow._abort() }) { iRow = this._executeQuery(compiledQuery),
inputAction = { iRow ->
for (elem in collection) { for (elem in collection) {
iRow._next() iRow._next()
transform.transformToRow(iRow, elem) transform.transformToRow(iRow, elem)
} }
} }
iRow._finish() )
} }
public suspend inline fun <qUE : Any, E> Transaction.mapToRowsIndexed( public suspend inline fun <qUE : Any, E> Transaction.mapToRowsIndexed(
@ -31,16 +31,16 @@ public suspend inline fun <qUE : Any, E> Transaction.mapToRowsIndexed(
firstIndex: Int = 0, firstIndex: Int = 0,
transform: RowProducer2<qUE, E> transform: RowProducer2<qUE, E>
) { ) {
val iRow = this._executeQuery(compiledQuery) _safeAutoClose_I(
iRow = this._executeQuery(compiledQuery),
inputAction = { iRow ->
var index = firstIndex var index = firstIndex
_safeAutoClose(onAbort = { iRow._abort() }) {
for (elem in collection) { for (elem in collection) {
iRow._next() iRow._next()
transform.transformToRow(iRow, index, elem) transform.transformToRow(iRow, index++, elem)
index++
} }
} }
iRow._finish() )
} }
public suspend inline fun <qUE : Any, E> Transaction.mapToRows( public suspend inline fun <qUE : Any, E> Transaction.mapToRows(
@ -48,14 +48,15 @@ public suspend inline fun <qUE : Any, E> Transaction.mapToRows(
sequence: Sequence<E>, sequence: Sequence<E>,
transform: RowProducer1<qUE, E> transform: RowProducer1<qUE, E>
) { ) {
val iRow = this._executeQuery(compiledQuery) _safeAutoClose_I(
_safeAutoClose(onAbort = { iRow._abort() }) { iRow = this._executeQuery(compiledQuery),
inputAction = { iRow ->
for (elem in sequence) { for (elem in sequence) {
iRow._next() iRow._next()
transform.transformToRow(iRow, elem) transform.transformToRow(iRow, elem)
} }
} }
iRow._finish() )
} }
public suspend inline fun <qUE : Any, E> Transaction.mapToRowsIndexed( public suspend inline fun <qUE : Any, E> Transaction.mapToRowsIndexed(
@ -64,47 +65,48 @@ public suspend inline fun <qUE : Any, E> Transaction.mapToRowsIndexed(
firstIndex: Int = 0, firstIndex: Int = 0,
transform: RowProducer2<qUE, E> transform: RowProducer2<qUE, E>
) { ) {
val iRow = this._executeQuery(compiledQuery) _safeAutoClose_I(
iRow = this._executeQuery(compiledQuery),
inputAction = { iRow ->
var index = firstIndex var index = firstIndex
_safeAutoClose(onAbort = { iRow._abort() }) {
for (elem in sequence) { for (elem in sequence) {
iRow._next() iRow._next()
transform.transformToRow(iRow, index, elem) transform.transformToRow(iRow, index++, elem)
index++
} }
} }
iRow._finish() )
} }
public suspend inline fun <qUE : Any, E> Transaction.mapToRows( public suspend inline fun <qUE : Any, E> Transaction.mapToRows(
compiledQuery: _Query.Table2Void<qUE>, compiledQuery: _Query.Table2Void<qUE>,
sequence: Array<E>, array: Array<E>,
transform: RowProducer1<qUE, E> transform: RowProducer1<qUE, E>
) { ) {
val iRow = this._executeQuery(compiledQuery) _safeAutoClose_I(
_safeAutoClose(onAbort = { iRow._abort() }) { iRow = this._executeQuery(compiledQuery),
for (elem in sequence) { inputAction = { iRow ->
for (elem in array) {
iRow._next() iRow._next()
transform.transformToRow(iRow, elem) transform.transformToRow(iRow, elem)
} }
} }
iRow._finish() )
} }
public suspend inline fun <qUE : Any, E> Transaction.mapToRowsIndexed( public suspend inline fun <qUE : Any, E> Transaction.mapToRowsIndexed(
compiledQuery: _Query.Table2Void<qUE>, compiledQuery: _Query.Table2Void<qUE>,
sequence: Array<E>, array: Array<E>,
firstIndex: Int = 0, firstIndex: Int = 0,
transform: RowProducer2<qUE, E> transform: RowProducer2<qUE, E>
) { ) {
val iRow = this._executeQuery(compiledQuery) _safeAutoClose_I(
iRow = this._executeQuery(compiledQuery),
inputAction = { iRow ->
var index = firstIndex var index = firstIndex
_safeAutoClose(onAbort = { iRow._abort() }) { for (elem in array) {
for (elem in sequence) {
iRow._next() iRow._next()
transform.transformToRow(iRow, index, elem) transform.transformToRow(iRow, index++, elem)
index++
} }
} }
iRow._finish() )
} }

View File

@ -0,0 +1,37 @@
@file:OptIn(LowLevelApi::class)
@file:JvmName("_TransactionsKt")
package ru.landgrafhomyak.db.serdha0.user_commons.executors
import kotlin.jvm.JvmName
import ru.landgrafhomyak.db.serdha0.api.LowLevelApi
import ru.landgrafhomyak.db.serdha0.api.runtime.Executor
import ru.landgrafhomyak.db.serdha0.api.runtime.Transaction
public suspend inline fun <R> Executor.transaction(scope: (Transaction) -> R): R {
val transaction = this._startTransaction()
var e1: Throwable? = null
try {
return scope(transaction)
} catch (e: Throwable) {
e1 = e
throw e
} finally {
try {
transaction._assertTransactionFinishedAndReleaseResources()
} catch (e2: Throwable) {
if (e1 == null) {
throw e2
} else {
e1.addSuppressed(e2)
}
}
}
}
public suspend inline fun <R> Executor.autoCommittedTransaction(scope: (Transaction) -> R): R =
this.transaction { transaction ->
_safeAutoClose(onAbort = { transaction.rollback() }, onSuccess = { transaction.commit() }) {
return@transaction scope(transaction)
}
}

View File

@ -0,0 +1,20 @@
package ru.landgrafhomyak.db.serdha0.user_commons.reducers
import ru.landgrafhomyak.db.serdha0.api.misc.Reducer
import ru.landgrafhomyak.db.serdha0.api.runtime.InputRow
import ru.landgrafhomyak.db.serdha0.api.runtime.OutputRow
import ru.landgrafhomyak.db.serdha0.user_commons.types.U_INT_64
public class Count private constructor(context: Reducer.Constructor.Scope<Count>) : Reducer.Action<Count> {
@Suppress("PropertyName", "MemberVisibilityCanBePrivate")
public val C_Counter: Reducer.OutputColumn<ULong, U_INT_64, Count> = context.outputColumn("counter", context.types.U_INT_64, 0u)
override fun calculate(acc: OutputRow<Count>, row: OutputRow<Count>, newAcc: InputRow<Count>) {
newAcc[this.C_Counter] = acc[this.C_Counter] + 1u
}
public object Constructor : Reducer.Constructor<Count> {
override fun createReducer(context: Reducer.Constructor.Scope<Count>): Reducer.Action<Count> =
Count(context)
}
}

View File

@ -0,0 +1,21 @@
package ru.landgrafhomyak.db.serdha0.user_commons.reducers
import ru.landgrafhomyak.db.serdha0.api.misc.DatabaseType
import ru.landgrafhomyak.db.serdha0.api.misc.Reducer
import ru.landgrafhomyak.db.serdha0.api.runtime.InputRow
import ru.landgrafhomyak.db.serdha0.api.runtime.OutputRow
public class HasRows private constructor(context: Reducer.Constructor.Scope<HasRows>) : Reducer.Action<HasRows> {
@Suppress("PropertyName", "MemberVisibilityCanBePrivate")
public val C_HasRows: Reducer.OutputColumn<Boolean, DatabaseType.BOOLEAN, HasRows> =
context.outputColumn("flag", context.types.BOOLEAN, false)
override fun calculate(acc: OutputRow<HasRows>, row: OutputRow<HasRows>, newAcc: InputRow<HasRows>) {
newAcc[this.C_HasRows] = true
}
public object Constructor : Reducer.Constructor<HasRows> {
override fun createReducer(context: Reducer.Constructor.Scope<HasRows>): Reducer.Action<HasRows> =
HasRows(context)
}
}

View File

@ -0,0 +1,28 @@
package ru.landgrafhomyak.db.serdha0.user_commons.reducers
import ru.landgrafhomyak.db.serdha0.api.misc.DatabaseType
import ru.landgrafhomyak.db.serdha0.api.misc.Reducer
import ru.landgrafhomyak.db.serdha0.api.runtime.InputRow
import ru.landgrafhomyak.db.serdha0.api.runtime.OutputRow
public class Max<RT, DT : DatabaseType._VirtualType<RT, *, *>> private constructor(
context: Reducer.Constructor.Scope<Max<RT, DT>>,
private val _type: DT
) : Reducer.Action<Max<RT, DT>> {
@Suppress("PropertyName", "MemberVisibilityCanBePrivate")
public val C_MaxValue: Reducer.BidirectionalColumn<RT, DT, Max<RT, DT>> = context.bidirectionalColumn("max_value", this._type)
override fun calculate(acc: OutputRow<Max<RT, DT>>, row: OutputRow<Max<RT, DT>>, newAcc: InputRow<Max<RT, DT>>) {
val accumulatedValue = acc[this.C_MaxValue]
val newValue = row[this.C_MaxValue]
if (this._type._compare(accumulatedValue, newValue) < 0)
newAcc[this.C_MaxValue] = newValue
else
newAcc[this.C_MaxValue] = accumulatedValue
}
public class Constructor<RT, DT : DatabaseType._VirtualType<RT, *, *>>(private val type: DT) : Reducer.Constructor<Max<RT, DT>> {
override fun createReducer(context: Reducer.Constructor.Scope<Max<RT, DT>>): Reducer.Action<Max<RT, DT>> =
Max(context, this.type)
}
}

View File

@ -0,0 +1,28 @@
package ru.landgrafhomyak.db.serdha0.user_commons.reducers
import ru.landgrafhomyak.db.serdha0.api.misc.DatabaseType
import ru.landgrafhomyak.db.serdha0.api.misc.Reducer
import ru.landgrafhomyak.db.serdha0.api.runtime.InputRow
import ru.landgrafhomyak.db.serdha0.api.runtime.OutputRow
public class Min<RT, DT : DatabaseType._VirtualType<RT, *, *>> private constructor(
context: Reducer.Constructor.Scope<Min<RT, DT>>,
private val _type: DT
) : Reducer.Action<Min<RT, DT>> {
@Suppress("PropertyName", "MemberVisibilityCanBePrivate")
public val C_MinValue: Reducer.BidirectionalColumn<RT, DT, Min<RT, DT>> = context.bidirectionalColumn("min_value", this._type)
override fun calculate(acc: OutputRow<Min<RT, DT>>, row: OutputRow<Min<RT, DT>>, newAcc: InputRow<Min<RT, DT>>) {
val accumulatedValue = acc[this.C_MinValue]
val newValue = row[this.C_MinValue]
if (this._type._compare(accumulatedValue, newValue) > 0)
newAcc[this.C_MinValue] = newValue
else
newAcc[this.C_MinValue] = accumulatedValue
}
public class Constructor<RT, DT : DatabaseType._VirtualType<RT, *, *>>(private val type: DT) : Reducer.Constructor<Min<RT, DT>> {
override fun createReducer(context: Reducer.Constructor.Scope<Min<RT, DT>>): Reducer.Action<Min<RT, DT>> =
Min(context, this.type)
}
}