Raw queries compiler and executors in transaction

This commit is contained in:
Andrew Golovashevich 2025-05-08 00:00:19 +03:00
parent 0f3f32d7f3
commit a991b87158
4 changed files with 62 additions and 17 deletions

View File

@ -0,0 +1,12 @@
package ru.landgrafhomyak.db.sql_skeleton_0.api.queries
public interface QueriesCompiler<RUNTIME_KEY : Any> {
public fun <qUE : Any?> raw_void2void(constructor: RawStatement.Void2Void.ImplementationsProvider<qUE>): RawStatement.Void2Void<qUE, RUNTIME_KEY>
public fun <qUE : Any> raw_void2row(constructor: RawStatement.Void2Row.ImplementationsProvider<qUE>): RawStatement.Void2Row<qUE, RUNTIME_KEY>
public fun <qUE : Any> raw_void2rowOrNull(constructor: RawStatement.Void2RowOrNull.ImplementationsProvider<qUE>): RawStatement.Void2RowOrNull<qUE, RUNTIME_KEY>
public fun <qUE : Any> raw_void2table(constructor: RawStatement.Void2Table.ImplementationsProvider<qUE>): RawStatement.Void2Table<qUE, RUNTIME_KEY>
public fun <qUE : Any> raw_params2void(constructor: RawStatement.Params2Void.ImplementationsProvider<qUE>): RawStatement.Params2Void<qUE, RUNTIME_KEY>
public fun <qUE : Any> raw_params2row(constructor: RawStatement.Params2Row.ImplementationsProvider<qUE>): RawStatement.Params2Row<qUE, RUNTIME_KEY>
public fun <qUE : Any> raw_params2rowOrNull(constructor: RawStatement.Params2RowOrNull.ImplementationsProvider<qUE>): RawStatement.Params2RowOrNull<qUE, RUNTIME_KEY>
public fun <qUE : Any> raw_params2table(constructor: RawStatement.Params2Table.ImplementationsProvider<qUE>): RawStatement.Params2Table<qUE, RUNTIME_KEY>
}

View File

@ -22,10 +22,6 @@ public interface InputRow<qUE : Any> {
public operator fun set(c: QueryParam<Char, qUE>, value: Char): Unit = this.set<Char>(c, value)
public operator fun set(c: QueryParam<Boolean, qUE>, value: Boolean): Unit = this.set<Boolean>(c, value)
public interface WithRedirect<QueryUserExtension : Any, ParentQueryUserExtension : Any> : InputRow<QueryUserExtension> {
public fun <RT> redirect(c: QueryParam<RT, QueryUserExtension>, value: QueryParam<RT, ParentQueryUserExtension>)
}
@Suppress("ClassName")
@LowLevelApi
public interface _Scope<QueryUserExtension : Any, out Next> : InputRow<QueryUserExtension> {
@ -38,12 +34,19 @@ public interface InputRow<qUE : Any> {
public suspend fun _abort()
}
@Suppress("ClassName")
@LowLevelApi
public interface _Iterator<QueryUserExtension : Any, out Next> : _Scope<QueryUserExtension, Next> {
public interface _Iterator<QueryUserExtension : Any, out Next> : _Scope<QueryUserExtension, Next>, InputRow<QueryUserExtension> {
@Suppress("FunctionName")
@LowLevelApi
public fun _next(): Boolean
public suspend fun _next(): Boolean
@Suppress("FunctionName")
@LowLevelApi
public override suspend fun _abort()
@Suppress("FunctionName")
@LowLevelApi
public override suspend fun _finish(): Next
}
}

View File

@ -24,17 +24,29 @@ public interface OutputRow<qUE : Any> {
@Suppress("ClassName")
@LowLevelApi
public interface _Iterator<QueryUserExtension : Any, out Next> : OutputRow<QueryUserExtension> {
public interface _Scope<QueryUserExtension : Any, out Next> : OutputRow<QueryUserExtension> {
@Suppress("FunctionName")
@LowLevelApi
public suspend fun _finish(): Next
@Suppress("FunctionName")
@LowLevelApi
public suspend fun _abort()
}
@Suppress("ClassName")
@LowLevelApi
public interface _Iterator<QueryUserExtension : Any, out Next> : _Scope<QueryUserExtension, Next>, OutputRow<QueryUserExtension> {
@Suppress("FunctionName")
@LowLevelApi
public suspend fun _next(): Boolean
@Suppress("FunctionName")
@LowLevelApi
public suspend fun _abort()
public override suspend fun _abort()
@Suppress("FunctionName")
@LowLevelApi
public suspend fun _finish(): Next
public override suspend fun _finish(): Next
}
}

View File

@ -3,22 +3,40 @@ package ru.landgrafhomyak.db.sql_skeleton_0.api.runtime
import ru.landgrafhomyak.db.sql_skeleton_0.api.LowLevelApi
import ru.landgrafhomyak.db.sql_skeleton_0.api.queries._Statement
public interface Transaction {
@Suppress("FunctionName")
@LowLevelApi
public suspend fun <QueryUserExtension : Any> _executeQuery(compiledQuery: _Statement.Void2Table<QueryUserExtension>): OutputRow._Iterator<QueryUserExtension, Unit>
public interface Transaction<RUNTIME_KEY : Any> {
public suspend fun <qUE : Any?> executeQuery_void2void(compiledQuery: _Statement.Void2Void<qUE, RUNTIME_KEY>)
@Suppress("FunctionName")
@LowLevelApi
public suspend fun <QueryUserExtension : Any> _executeQuery(compiledQuery: _Statement.Params2Table<QueryUserExtension>): InputRow._Scope<QueryUserExtension, OutputRow._Iterator<QueryUserExtension, Unit>>
public suspend fun <qUE : Any> _executeQuery_void2row(compiledQuery: _Statement.Void2Row<qUE, RUNTIME_KEY>): OutputRow._Scope<qUE, Unit>
@Suppress("FunctionName")
@LowLevelApi
public suspend fun <QueryUserExtension : Any> _executeQuery(compiledQuery: _Statement.Table2Void<QueryUserExtension>): InputRow._Iterator<QueryUserExtension, Unit>
public suspend fun <qUE : Any> _executeQuery_void2rowOrNull(compiledQuery: _Statement.Void2RowOrNull<qUE, RUNTIME_KEY>): OutputRow._Scope<qUE, Unit>?
@Suppress("FunctionName")
@LowLevelApi
public suspend fun <QueryUserExtension : Any> _executeQuery(compiledQuery: _Statement.Params2Void<QueryUserExtension>): InputRow._Scope<QueryUserExtension, Unit>
public suspend fun <qUE : Any> _executeQuery_void2table(compiledQuery: _Statement.Void2RowOrNull<qUE, RUNTIME_KEY>): OutputRow._Iterator<qUE, Unit>
@Suppress("FunctionName")
@LowLevelApi
public suspend fun <qUE : Any> _executeQuery_params2void(compiledQuery: _Statement.Void2Void<qUE, RUNTIME_KEY>): InputRow._Scope<qUE, Unit>
@Suppress("FunctionName")
@LowLevelApi
public suspend fun <qUE : Any> _executeQuery_params2row(compiledQuery: _Statement.Void2Row<qUE, RUNTIME_KEY>): InputRow._Scope<qUE, OutputRow._Scope<qUE, Unit>>
@Suppress("FunctionName")
@LowLevelApi
public suspend fun <qUE : Any> _executeQuery_params2rowOrNull(compiledQuery: _Statement.Void2RowOrNull<qUE, RUNTIME_KEY>):InputRow._Scope<qUE, OutputRow._Scope<qUE, Unit>?>
@Suppress("FunctionName")
@LowLevelApi
public suspend fun <qUE : Any> _executeQuery_params2table(compiledQuery: _Statement.Void2RowOrNull<qUE, RUNTIME_KEY>): InputRow._Scope<qUE, OutputRow._Iterator<qUE, Unit>>
@Suppress("FunctionName")
@LowLevelApi
public suspend fun <qUE : Any> _executeBatch_params2void(compiledQuery: _Statement.Void2Void<qUE, RUNTIME_KEY>): InputRow._Iterator<qUE, Unit>
public suspend fun rollback()