From 35a668ad378e2597d990dceddf9deeae63821d16 Mon Sep 17 00:00:00 2001 From: Andrew Golovashevich Date: Mon, 19 May 2025 20:04:54 +0300 Subject: [PATCH] Common way to declare parameters and columns in raw statements --- .../skeleton1/api/statement/RawStatement.kt | 28 ++++++++++++++----- .../statement/StatementIODeclarationScope.kt | 15 ++++++++++ 2 files changed, 36 insertions(+), 7 deletions(-) create mode 100644 src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/statement/StatementIODeclarationScope.kt diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/statement/RawStatement.kt b/src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/statement/RawStatement.kt index 134a305..e116539 100644 --- a/src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/statement/RawStatement.kt +++ b/src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/statement/RawStatement.kt @@ -28,7 +28,9 @@ public interface RawStatement : _Statement { public interface Void2Row : RawStatement, _Statement.Void2Row { override val uExt: sUE - public interface Constructor<@Suppress("unused") sUE : Any> + public interface Constructor { + public fun declareIO(scope: StatementIODeclarationScope.Output): sUE + } public interface ImplementationsProvider { public fun provideStatementImplementations_void2row(scope: Scope) @@ -48,7 +50,9 @@ public interface RawStatement : _Statement { public interface Void2RowOrNull : RawStatement, _Statement.Void2RowOrNull { override val uExt: sUE - public interface Constructor<@Suppress("unused") sUE : Any> + public interface Constructor { + public fun declareIO(scope: StatementIODeclarationScope.Output): sUE + } public interface ImplementationsProvider { public fun provideStatementImplementations_void2rowOrNull(scope: Scope) @@ -69,7 +73,9 @@ public interface RawStatement : _Statement { public interface Void2Table : RawStatement, _Statement.Void2Table { override val uExt: sUE - public interface Constructor<@Suppress("unused") sUE : Any> + public interface Constructor { + public fun declareIO(scope: StatementIODeclarationScope.Output): sUE + } public interface ImplementationsProvider { public fun provideStatementImplementations_void2table(selector: Selector) @@ -89,7 +95,9 @@ public interface RawStatement : _Statement { public interface Params2Void : RawStatement, _Statement.Params2Void { override val uExt: sUE - public interface Constructor<@Suppress("unused") sUE : Any> + public interface Constructor { + public fun declareIO(scope: StatementIODeclarationScope.Input): sUE + } public interface ImplementationsProvider { public fun provideStatementImplementations_params2void(scope: Scope) @@ -109,7 +117,9 @@ public interface RawStatement : _Statement { public interface Params2Row : RawStatement, _Statement.Params2Row { override val uExt: sUE - public interface Constructor<@Suppress("unused") sUE : Any> + public interface Constructor { + public fun declareIO(scope: StatementIODeclarationScope.InputOutput): sUE + } public interface ImplementationsProvider { public fun provideStatementImplementations_params2row(scope: Scope) @@ -129,7 +139,9 @@ public interface RawStatement : _Statement { public interface Params2RowOrNull : RawStatement, _Statement.Params2RowOrNull { override val uExt: sUE - public interface Constructor<@Suppress("unused") sUE : Any> + public interface Constructor { + public fun declareIO(scope: StatementIODeclarationScope.InputOutput): sUE + } public interface ImplementationsProvider { public fun provideStatementImplementations_params2rowOrNull(scope: Scope) @@ -149,7 +161,9 @@ public interface RawStatement : _Statement { public interface Params2Table : RawStatement, _Statement.Params2Table { override val uExt: sUE - public interface Constructor<@Suppress("unused") sUE : Any> + public interface Constructor { + public fun declareIO(scope: StatementIODeclarationScope.InputOutput): sUE + } public interface ImplementationsProvider { public fun provideStatementImplementations_params2table(scope: Scope) diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/statement/StatementIODeclarationScope.kt b/src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/statement/StatementIODeclarationScope.kt new file mode 100644 index 0000000..1a38d72 --- /dev/null +++ b/src/commonMain/kotlin/ru/landgrafhomyak/db/skeleton1/api/statement/StatementIODeclarationScope.kt @@ -0,0 +1,15 @@ +package ru.landgrafhomyak.db.skeleton1.api.statement + +import ru.landgrafhomyak.db.skeleton1.api.DatabaseType + +public interface StatementIODeclarationScope<@Suppress("unused") sUE : Any, @Suppress("unused") IK : Any> { + public interface Input : StatementIODeclarationScope { + public fun inputParam(type: DatabaseType.ImplementationsProvider): InputParam + } + + public interface Output : StatementIODeclarationScope { + public fun outputColumn(type: DatabaseType.ImplementationsProvider): OutputColumn + } + + public interface InputOutput : StatementIODeclarationScope, Input, Output +} \ No newline at end of file