From 29f24350573459462aecbe7437c004bfb5ab21f5 Mon Sep 17 00:00:00 2001 From: Andrew Golovashevich Date: Sat, 4 Jan 2025 17:04:14 +0300 Subject: [PATCH] 'ColumnType' -> 'DatabaseType', removed 'STRING' database type, 'BYTE_ARRAY' -> 'BINARY_DATA' --- .../serdha/api/v0/Expression.kt | 535 +++++++++--------- .../api/v0/ddl/table/CheckConstraint.kt | 4 +- .../serdha/api/v0/ddl/table/Column.kt | 10 +- .../api/v0/ddl/table/DefaultConstraint.kt | 11 +- .../api/v0/ddl/table/ForeignRowReference.kt | 8 +- .../serdha/api/v0/ddl/table/TableCreator.kt | 19 +- .../serdha/api/v0/ddl/table/TableUpdater.kt | 18 +- .../serdha/api/v0/ddl/types/ColumnType.kt | 285 ---------- .../serdha/api/v0/ddl/types/DatabaseType.kt | 146 +++++ .../api/v0/ddl/types/DatabaseTypesProvider.kt | 151 +++++ .../serdha/api/v0/dml/CreateCopyQueryScope.kt | 4 +- .../api/v0/dml/CreateDeleteQueryScope.kt | 4 +- .../api/v0/dml/CreateInsertQueryScope.kt | 14 +- .../api/v0/dml/CreateSelectQueryScope.kt | 4 +- .../api/v0/dml/CreateUpdateQueryScope.kt | 8 +- .../serdha/api/v0/dml/InputParam.kt | 4 +- .../serdha/api/v0/dml/SelectedTable.kt | 3 +- .../api/v0/dml/_CommonCreateQueryScope.kt | 11 +- .../v0/dml/_CreateInsertOrCopyQueryScope.kt | 8 +- 19 files changed, 629 insertions(+), 618 deletions(-) delete mode 100644 src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/ddl/types/ColumnType.kt create mode 100644 src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/ddl/types/DatabaseType.kt create mode 100644 src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/ddl/types/DatabaseTypesProvider.kt diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/Expression.kt b/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/Expression.kt index 1929ad8..ebe38a2 100644 --- a/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/Expression.kt +++ b/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/Expression.kt @@ -4,455 +4,454 @@ import kotlinx.datetime.Instant import kotlinx.datetime.LocalDate import kotlinx.datetime.LocalDateTime import kotlinx.datetime.LocalTime -import ru.landgrafhomyak.serdha.api.v0.ddl.types.ColumnType +import ru.landgrafhomyak.serdha.api.v0.ddl.types.DatabaseType -public interface Expression, OwnerBuilderUserExtension : Any> { +public interface Expression, OwnerBuilderUserExtension : Any> { public interface Builder { - public fun > equals( - left: Expression<*, DatabaseType, OwnerBuilderUserExtension>, - right: Expression<*, DatabaseType, OwnerBuilderUserExtension>, - ): Expression + public fun
> equals( + left: Expression<*, DT, OwnerBuilderUserExtension>, + right: Expression<*, DT, OwnerBuilderUserExtension>, + ): Expression - public fun > notEquals( - left: Expression<*, DatabaseType, OwnerBuilderUserExtension>, - right: Expression<*, DatabaseType, OwnerBuilderUserExtension>, - ): Expression = + public fun
> notEquals( + left: Expression<*, DT, OwnerBuilderUserExtension>, + right: Expression<*, DT, OwnerBuilderUserExtension>, + ): Expression = this.logicalNot(this.equals(left, right)) public fun isNull( - e: Expression<*, ColumnType.Nullable<*, *>, OwnerBuilderUserExtension>, - ): Expression + e: Expression<*, DatabaseType.Nullable<*, *>, OwnerBuilderUserExtension>, + ): Expression public fun isNotNull( - e: Expression<*, ColumnType.Nullable<*, *>, OwnerBuilderUserExtension>, - ): Expression = + e: Expression<*, DatabaseType.Nullable<*, *>, OwnerBuilderUserExtension>, + ): Expression = this.logicalNot(this.isNull(e)) public fun logicalAnd( - left: Expression<*, ColumnType.BOOLEAN, OwnerBuilderUserExtension>, - right: Expression<*, ColumnType.BOOLEAN, OwnerBuilderUserExtension>, - ): Expression + left: Expression<*, DatabaseType.BOOLEAN, OwnerBuilderUserExtension>, + right: Expression<*, DatabaseType.BOOLEAN, OwnerBuilderUserExtension>, + ): Expression public fun logicalOr( - left: Expression<*, ColumnType.BOOLEAN, OwnerBuilderUserExtension>, - right: Expression<*, ColumnType.BOOLEAN, OwnerBuilderUserExtension>, - ): Expression + left: Expression<*, DatabaseType.BOOLEAN, OwnerBuilderUserExtension>, + right: Expression<*, DatabaseType.BOOLEAN, OwnerBuilderUserExtension>, + ): Expression public fun logicalXor( - left: Expression<*, ColumnType.BOOLEAN, OwnerBuilderUserExtension>, - right: Expression<*, ColumnType.BOOLEAN, OwnerBuilderUserExtension>, - ): Expression = + left: Expression<*, DatabaseType.BOOLEAN, OwnerBuilderUserExtension>, + right: Expression<*, DatabaseType.BOOLEAN, OwnerBuilderUserExtension>, + ): Expression = this.notEquals(left, right) public fun logicalNot( - e: Expression<*, ColumnType.BOOLEAN, OwnerBuilderUserExtension>, - ): Expression + e: Expression<*, DatabaseType.BOOLEAN, OwnerBuilderUserExtension>, + ): Expression public fun cmpIntegersLess( - left: Expression, - right: Expression, - ): Expression + left: Expression, + right: Expression, + ): Expression public fun cmpIntegersLess( - left: Expression, - right: Expression, - ): Expression + left: Expression, + right: Expression, + ): Expression public fun cmpIntegersLess( - left: Expression, - right: Expression, - ): Expression + left: Expression, + right: Expression, + ): Expression public fun cmpIntegersLess( - left: Expression, - right: Expression, - ): Expression + left: Expression, + right: Expression, + ): Expression public fun cmpIntegersLess( - left: Expression, - right: Expression, - ): Expression + left: Expression, + right: Expression, + ): Expression public fun cmpIntegersLess( - left: Expression, - right: Expression, - ): Expression + left: Expression, + right: Expression, + ): Expression public fun cmpIntegersLess( - left: Expression, - right: Expression, - ): Expression + left: Expression, + right: Expression, + ): Expression public fun cmpIntegersLess( - left: Expression, - right: Expression, - ): Expression + left: Expression, + right: Expression, + ): Expression public fun cmpIntegersLessOrEquals( - left: Expression, - right: Expression, - ): Expression + left: Expression, + right: Expression, + ): Expression public fun cmpIntegersLessOrEquals( - left: Expression, - right: Expression, - ): Expression + left: Expression, + right: Expression, + ): Expression public fun cmpIntegersLessOrEquals( - left: Expression, - right: Expression, - ): Expression + left: Expression, + right: Expression, + ): Expression public fun cmpIntegersLessOrEquals( - left: Expression, - right: Expression, - ): Expression + left: Expression, + right: Expression, + ): Expression public fun cmpIntegersLessOrEquals( - left: Expression, - right: Expression, - ): Expression + left: Expression, + right: Expression, + ): Expression public fun cmpIntegersLessOrEquals( - left: Expression, - right: Expression, - ): Expression + left: Expression, + right: Expression, + ): Expression public fun cmpIntegersLessOrEquals( - left: Expression, - right: Expression, - ): Expression + left: Expression, + right: Expression, + ): Expression public fun cmpIntegersLessOrEquals( - left: Expression, - right: Expression, - ): Expression + left: Expression, + right: Expression, + ): Expression public fun cmpIntegersGreater( - left: Expression, - right: Expression, - ): Expression + left: Expression, + right: Expression, + ): Expression public fun cmpIntegersGreater( - left: Expression, - right: Expression, - ): Expression + left: Expression, + right: Expression, + ): Expression public fun cmpIntegersGreater( - left: Expression, - right: Expression, - ): Expression + left: Expression, + right: Expression, + ): Expression public fun cmpIntegersGreater( - left: Expression, - right: Expression, - ): Expression + left: Expression, + right: Expression, + ): Expression public fun cmpIntegersGreater( - left: Expression, - right: Expression, - ): Expression + left: Expression, + right: Expression, + ): Expression public fun cmpIntegersGreater( - left: Expression, - right: Expression, - ): Expression + left: Expression, + right: Expression, + ): Expression public fun cmpIntegersGreater( - left: Expression, - right: Expression, - ): Expression + left: Expression, + right: Expression, + ): Expression public fun cmpIntegersGreater( - left: Expression, - right: Expression, - ): Expression + left: Expression, + right: Expression, + ): Expression public fun cmpIntegersGreaterOrEquals( - left: Expression, - right: Expression, - ): Expression + left: Expression, + right: Expression, + ): Expression public fun cmpIntegersGreaterOrEquals( - left: Expression, - right: Expression, - ): Expression + left: Expression, + right: Expression, + ): Expression public fun cmpIntegersGreaterOrEquals( - left: Expression, - right: Expression, - ): Expression + left: Expression, + right: Expression, + ): Expression public fun cmpIntegersGreaterOrEquals( - left: Expression, - right: Expression, - ): Expression + left: Expression, + right: Expression, + ): Expression public fun cmpIntegersGreaterOrEquals( - left: Expression, - right: Expression, - ): Expression + left: Expression, + right: Expression, + ): Expression public fun cmpIntegersGreaterOrEquals( - left: Expression, - right: Expression, - ): Expression + left: Expression, + right: Expression, + ): Expression public fun cmpIntegersGreaterOrEquals( - left: Expression, - right: Expression, - ): Expression + left: Expression, + right: Expression, + ): Expression public fun cmpIntegersGreaterOrEquals( - left: Expression, - right: Expression, - ): Expression + left: Expression, + right: Expression, + ): Expression public fun extendIntegerToS16( - e: Expression, - ): Expression + e: Expression, + ): Expression public fun extendIntegerToS16( - e: Expression, - ): Expression + e: Expression, + ): Expression public fun extendIntegerToU16( - e: Expression, - ): Expression + e: Expression, + ): Expression public fun extendIntegerToS32( - e: Expression, - ): Expression + e: Expression, + ): Expression public fun extendIntegerToS32( - e: Expression, - ): Expression + e: Expression, + ): Expression public fun extendIntegerToS32( - e: Expression, - ): Expression + e: Expression, + ): Expression public fun extendIntegerToS32( - e: Expression, - ): Expression + e: Expression, + ): Expression public fun extendIntegerToU32( - e: Expression, - ): Expression + e: Expression, + ): Expression public fun extendIntegerToU32( - e: Expression, - ): Expression + e: Expression, + ): Expression public fun extendIntegerToS64( - e: Expression, - ): Expression + e: Expression, + ): Expression public fun extendIntegerToS64( - e: Expression, - ): Expression + e: Expression, + ): Expression public fun extendIntegerToS64( - e: Expression, - ): Expression + e: Expression, + ): Expression public fun extendIntegerToS64( - e: Expression, - ): Expression + e: Expression, + ): Expression public fun extendIntegerToS64( - e: Expression, - ): Expression + e: Expression, + ): Expression public fun extendIntegerToS64( - e: Expression, - ): Expression + e: Expression, + ): Expression public fun extendIntegerToU64( - e: Expression, - ): Expression + e: Expression, + ): Expression public fun extendIntegerToU64( - e: Expression, - ): Expression + e: Expression, + ): Expression public fun extendIntegerToU64( - e: Expression, - ): Expression + e: Expression, + ): Expression public fun extendFractionalToDouble( - e: Expression - ): Expression + e: Expression + ): Expression public fun cmpFractionalLess( - left: Expression, - right: Expression, - ): Expression + left: Expression, + right: Expression, + ): Expression public fun cmpFractionalLess( - left: Expression, - right: Expression, - ): Expression + left: Expression, + right: Expression, + ): Expression public fun cmpFractionalLessOrEquals( - left: Expression, - right: Expression, - ): Expression + left: Expression, + right: Expression, + ): Expression public fun cmpFractionalLessOrEquals( - left: Expression, - right: Expression, - ): Expression + left: Expression, + right: Expression, + ): Expression public fun cmpFractionalGreater( - left: Expression, - right: Expression, - ): Expression + left: Expression, + right: Expression, + ): Expression public fun cmpFractionalGreater( - left: Expression, - right: Expression, - ): Expression + left: Expression, + right: Expression, + ): Expression public fun cmpFractionalGreaterOrEquals( - left: Expression, - right: Expression, - ): Expression + left: Expression, + right: Expression, + ): Expression public fun cmpFractionalGreaterOrEquals( - left: Expression, - right: Expression, - ): Expression + left: Expression, + right: Expression, + ): Expression public fun cmpLocalDateEarlier( - left: Expression, - right: Expression, - ): Expression + left: Expression, + right: Expression, + ): Expression public fun cmpLocalDateEarlierOrSimultaneous( - left: Expression, - right: Expression, - ): Expression + left: Expression, + right: Expression, + ): Expression public fun cmpLocalDateLater( - left: Expression, - right: Expression, - ): Expression + left: Expression, + right: Expression, + ): Expression public fun cmpLocalDateLaterOrSimultaneous( - left: Expression, - right: Expression, - ): Expression + left: Expression, + right: Expression, + ): Expression public fun cmpLocalTimeEarlier( - left: Expression, - right: Expression, - ): Expression + left: Expression, + right: Expression, + ): Expression public fun cmpLocalTimeEarlierOrSimultaneous( - left: Expression, - right: Expression, - ): Expression + left: Expression, + right: Expression, + ): Expression public fun cmpLocalTimeLater( - left: Expression, - right: Expression, - ): Expression + left: Expression, + right: Expression, + ): Expression public fun cmpLocalTimeLaterOrSimultaneous( - left: Expression, - right: Expression, - ): Expression + left: Expression, + right: Expression, + ): Expression public fun cmpLocalDateTimeEarlier( - left: Expression, - right: Expression, - ): Expression + left: Expression, + right: Expression, + ): Expression public fun cmpLocalDateTimeEarlierOrSimultaneous( - left: Expression, - right: Expression, - ): Expression + left: Expression, + right: Expression, + ): Expression public fun cmpLocalDateTimeLater( - left: Expression, - right: Expression, - ): Expression + left: Expression, + right: Expression, + ): Expression public fun cmpLocalDateTimeLaterOrSimultaneous( - left: Expression, - right: Expression, - ): Expression + left: Expression, + right: Expression, + ): Expression public fun cmpInstantEarlier( - left: Expression, - right: Expression, - ): Expression + left: Expression, + right: Expression, + ): Expression public fun cmpInstantEarlierOrSimultaneous( - left: Expression, - right: Expression, - ): Expression + left: Expression, + right: Expression, + ): Expression public fun cmpInstantLater( - left: Expression, - right: Expression, - ): Expression + left: Expression, + right: Expression, + ): Expression public fun cmpInstantLaterOrSimultaneous( - left: Expression, - right: Expression, - ): Expression + left: Expression, + right: Expression, + ): Expression public fun dateComponentOf( - dt: Expression, - ): Expression + dt: Expression, + ): Expression public fun timeComponentOf( - dt: Expression, - ): Expression + dt: Expression, + ): Expression public fun joinDateTime( - date: Expression, - time: Expression, - ): Expression + date: Expression, + time: Expression, + ): Expression - public fun constantOf(v: String): Expression - public fun constantOf(v: Boolean): Expression - public fun constantOf(v: Byte): Expression - public fun constantOf(v: UByte): Expression - public fun constantOf(v: Short): Expression - public fun constantOf(v: UShort): Expression - public fun constantOf(v: Int): Expression - public fun constantOf(v: UInt): Expression - public fun constantOf(v: Long): Expression - public fun constantOf(v: ULong): Expression - public fun constantOf(v: Float): Expression - public fun constantOf(v: Double): Expression - public fun constantOf(v: LocalDate): Expression - public fun constantOf(v: LocalTime): Expression - public fun constantOf(v: LocalDateTime): Expression - public fun constantOf(v: Instant): Expression + public fun constantOf(v: Boolean): Expression + public fun constantOf(v: Byte): Expression + public fun constantOf(v: UByte): Expression + public fun constantOf(v: Short): Expression + public fun constantOf(v: UShort): Expression + public fun constantOf(v: Int): Expression + public fun constantOf(v: UInt): Expression + public fun constantOf(v: Long): Expression + public fun constantOf(v: ULong): Expression + public fun constantOf(v: Float): Expression + public fun constantOf(v: Double): Expression + public fun constantOf(v: LocalDate): Expression + public fun constantOf(v: LocalTime): Expression + public fun constantOf(v: LocalDateTime): Expression + public fun constantOf(v: Instant): Expression @OptIn(ExperimentalUnsignedTypes::class) - public fun constantOf(v: ByteArray): Expression + public fun constantOf(v: ByteArray): Expression - public fun , RetRuntimeType, RetDatabaseType : ColumnType> ifNull( - nullable: Expression, OwnerBuilderUserExtension>, - onValue: (Expression) -> Expression, - onNull: () -> Expression - ): Expression + public fun , RetRuntimeType, RetDT : DatabaseType> ifNull( + nullable: Expression, OwnerBuilderUserExtension>, + onValue: (Expression) -> Expression, + onNull: () -> Expression + ): Expression - public fun > notNullAnd( - nullable: Expression, OwnerBuilderUserExtension>, - onValue: (Expression) -> Expression, - ): Expression + public fun > notNullAnd( + nullable: Expression, OwnerBuilderUserExtension>, + onValue: (Expression) -> Expression, + ): Expression - public fun > nullOr( - nullable: Expression, OwnerBuilderUserExtension>, - onValue: (Expression) -> Expression, - ): Expression + public fun > nullOr( + nullable: Expression, OwnerBuilderUserExtension>, + onValue: (Expression) -> Expression, + ): Expression } } \ No newline at end of file diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/ddl/table/CheckConstraint.kt b/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/ddl/table/CheckConstraint.kt index 0e59b08..a9ff3e8 100644 --- a/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/ddl/table/CheckConstraint.kt +++ b/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/ddl/table/CheckConstraint.kt @@ -2,7 +2,7 @@ package ru.landgrafhomyak.serdha.api.v0.ddl.table import kotlin.jvm.JvmName import ru.landgrafhomyak.serdha.api.v0.Expression -import ru.landgrafhomyak.serdha.api.v0.ddl.types.ColumnType +import ru.landgrafhomyak.serdha.api.v0.ddl.types.DatabaseType /** * Descriptor of 'check' constraint on columns. Used for schema manipulations. @@ -30,7 +30,7 @@ public interface CheckConstraint { */ @Suppress("INAPPLICABLE_JVM_NAME") @get:JvmName("expression") - public val expression: Expression + public val expression: Expression /** diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/ddl/table/Column.kt b/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/ddl/table/Column.kt index 04a414f..d401d91 100644 --- a/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/ddl/table/Column.kt +++ b/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/ddl/table/Column.kt @@ -1,17 +1,17 @@ package ru.landgrafhomyak.serdha.api.v0.ddl.table import kotlin.jvm.JvmName -import ru.landgrafhomyak.serdha.api.v0.ddl.types.ColumnType +import ru.landgrafhomyak.serdha.api.v0.ddl.types.DatabaseType import ru.landgrafhomyak.serdha.api.v0.dml.SelectedTable /** * Descriptor of data column (of table or query). Used for schema manipulations and [access in queries builder][SelectedTable.selectColumn]. * - * @param RuntimeType Type in programming language to which database type is converted. - * @param DatabaseType Descriptor of column type on database side. + * @param RT Type in programming language to which database type is converted. + * @param DT Descriptor of column type on database side. * @param TableUserExtension Type of [owner's table][Column.table] user expression for static reporting errors when this descriptor passed to wrong table. */ -public interface Column, TableUserExtension : Any> { +public interface Column, TableUserExtension : Any> { /** * Name of column for debugging, errors and raw schema access. */ @@ -25,7 +25,7 @@ public interface Column, Tab */ @Suppress("INAPPLICABLE_JVM_NAME") @get:JvmName("type") - public val type: DatabaseType + public val type: DT /** * Table, that contains this column. For debugging. diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/ddl/table/DefaultConstraint.kt b/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/ddl/table/DefaultConstraint.kt index a83c19e..6c7c4b0 100644 --- a/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/ddl/table/DefaultConstraint.kt +++ b/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/ddl/table/DefaultConstraint.kt @@ -2,16 +2,15 @@ package ru.landgrafhomyak.serdha.api.v0.ddl.table import kotlin.jvm.JvmName import ru.landgrafhomyak.serdha.api.v0.Expression -import ru.landgrafhomyak.serdha.api.v0.ddl.types.ColumnType /** * Descriptor of default value attached to [column][Column]. Used for schema manipulations. * - * @param RuntimeType Type in programming language to which database type is converted. - * @param DatabaseType Descriptor of column type on database side. + * @param RT Type in programming language to which database type is converted. + * @param DT Descriptor of column type on database side. * @param TableUserExtension Type of [owner's table][Column.table] user expression for static reporting errors when this descriptor passed to wrong table. */ -public interface DefaultConstraint, TableUserExtension : Any> { +public interface DefaultConstraint, TableUserExtension : Any> { /** * Name of constraint for debugging, errors and raw schema access. */ @@ -31,12 +30,12 @@ public interface DefaultConstraint + public val attachedToColumn: Column /** * Expression used to initialize cell. */ @Suppress("INAPPLICABLE_JVM_NAME") @get:JvmName("expression") - public val expression: Expression + public val expression: Expression } \ No newline at end of file diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/ddl/table/ForeignRowReference.kt b/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/ddl/table/ForeignRowReference.kt index 0097836..6247537 100644 --- a/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/ddl/table/ForeignRowReference.kt +++ b/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/ddl/table/ForeignRowReference.kt @@ -1,7 +1,7 @@ package ru.landgrafhomyak.serdha.api.v0.ddl.table import kotlin.jvm.JvmName -import ru.landgrafhomyak.serdha.api.v0.ddl.types.ColumnType +import ru.landgrafhomyak.serdha.api.v0.ddl.types.DatabaseType import ru.landgrafhomyak.serdha.api.v0.ddl.types.RowId /** @@ -23,7 +23,7 @@ public interface ForeignRowReference, ColumnType.ROW_ID, ContainerTableUserExtension> + public val fromColumn: Column, DatabaseType.ROW_ID, ContainerTableUserExtension> /** * Table referenced by this foreign key. For debugging. @@ -37,7 +37,7 @@ public interface ForeignRowReference, ColumnType.ROW_ID, TargetTableUserExtension> + public val toColumn: Column, DatabaseType.ROW_ID, TargetTableUserExtension> /** @@ -52,7 +52,7 @@ public interface ForeignRowReference { public val expressionBuilder: Expression.Builder - public val types: ColumnType.Builder + public val types: DatabaseTypesProvider - public fun > column(name: String, type: DatabaseType): Column + public fun > column(name: String, type: DatabaseType): Column public fun index(name: String, vararg columns: Column<*, *, TableUserExtension>): Index public fun uniqueIndex(name: String, distinctNulls: Boolean, vararg columns: Column<*, *, TableUserExtension>): UniqueIndex - public fun checkConstraint(name: String, constraint: Expression): CheckConstraint - public fun > defaultValue(c: Column, expr: Expression): DefaultConstraint + public fun checkConstraint(name: String, constraint: Expression): CheckConstraint + public fun > defaultValue(c: Column, expr: Expression): DefaultConstraint @Suppress("PropertyName") - public val rowId_column: Column, ColumnType>, TableUserExtension> + public val rowId_column: Column, DatabaseType>, TableUserExtension> @Suppress("PropertyName") public val rowId_uniqueConstraint: UniqueIndex public fun selfRowReference( onDelete: ForeignRowReference.OnDeleteAction, - toColumn: Column, ColumnType.ROW_ID, TargetTableUserWrapper>, + toColumn: Column, DatabaseType.ROW_ID, TargetTableUserWrapper>, ): ForeignRowReference public fun foreignRowReference( - fromColumn: Column, ColumnType.ROW_ID, TableUserExtension>, + fromColumn: Column, DatabaseType.ROW_ID, TableUserExtension>, toTable: Table, - toColumn: Column, ColumnType.ROW_ID, TargetTableUserWrapper>, + toColumn: Column, DatabaseType.ROW_ID, TargetTableUserWrapper>, onDelete: ForeignRowReference.OnDeleteAction, ): ForeignRowReference } \ No newline at end of file diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/ddl/table/TableUpdater.kt b/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/ddl/table/TableUpdater.kt index fd1e664..f971321 100644 --- a/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/ddl/table/TableUpdater.kt +++ b/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/ddl/table/TableUpdater.kt @@ -1,18 +1,18 @@ package ru.landgrafhomyak.serdha.api.v0.ddl.table import ru.landgrafhomyak.serdha.api.v0.Expression -import ru.landgrafhomyak.serdha.api.v0.ddl.types.ColumnType +import ru.landgrafhomyak.serdha.api.v0.ddl.types.DatabaseType public interface TableUpdater : TableCreator { public val oldExpressionBuilder: Expression.Builder - public fun > keepColumn(c: Column): Column - public fun > renameAndKeepColumn(c: Column, newName: String): Column - public fun > mapAndKeepColumn(c: Column<*, *, TableOldUserExtension>, newValue: Expression, where: Expression?): Column - public fun > mapAndKeepColumn(c: Column<*, *, TableOldUserExtension>, newValue: Expression): Column = this.mapAndKeepColumn(c, newValue, null) - public fun > mapAndRenameAndKeepColumn(c: Column<*, *, TableOldUserExtension>, newName: String, newValue: Expression, where: Expression?): Column - public fun > mapAndRenameAndKeepColumn(c: Column<*, *, TableOldUserExtension>, newName: String, newValue: Expression): Column = this.mapAndRenameAndKeepColumn(c, newName, newValue, null) + public fun > keepColumn(c: Column): Column + public fun > renameAndKeepColumn(c: Column, newName: String): Column + public fun > mapAndKeepColumn(c: Column<*, *, TableOldUserExtension>, newValue: Expression, where: Expression?): Column + public fun > mapAndKeepColumn(c: Column<*, *, TableOldUserExtension>, newValue: Expression): Column = this.mapAndKeepColumn(c, newValue, null) + public fun > mapAndRenameAndKeepColumn(c: Column<*, *, TableOldUserExtension>, newName: String, newValue: Expression, where: Expression?): Column + public fun > mapAndRenameAndKeepColumn(c: Column<*, *, TableOldUserExtension>, newName: String, newValue: Expression): Column = this.mapAndRenameAndKeepColumn(c, newName, newValue, null) public fun deleteColumn(c: Column<*, *, TableOldUserExtension>) public fun keepIndex(i: Index): Index @@ -27,8 +27,8 @@ public interface TableUpdater, newName: String): UniqueIndex public fun deleteUniqueIndex(i: UniqueIndex) - public fun > keepDefaultValue(c: Column, d: DefaultConstraint): DefaultConstraint - public fun > changeDefaultValue(c: Column, d: DefaultConstraint<*, *, TableOldUserExtension>): DefaultConstraint + public fun > keepDefaultValue(c: Column, d: DefaultConstraint): DefaultConstraint + public fun > changeDefaultValue(c: Column, d: DefaultConstraint<*, *, TableOldUserExtension>): DefaultConstraint public fun deleteDefaultValue(i: DefaultConstraint<*, *, TableOldUserExtension>) public fun keepForeignRowReference( diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/ddl/types/ColumnType.kt b/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/ddl/types/ColumnType.kt deleted file mode 100644 index dd3d1ca..0000000 --- a/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/ddl/types/ColumnType.kt +++ /dev/null @@ -1,285 +0,0 @@ -package ru.landgrafhomyak.serdha.api.v0.ddl.types - -import kotlin.jvm.JvmField -import kotlin.jvm.JvmName -import kotlinx.datetime.Instant -import kotlinx.datetime.LocalDate -import kotlinx.datetime.LocalDateTime -import kotlinx.datetime.LocalTime -import ru.landgrafhomyak.serdha.api.v0.ddl.table.Table - -/** - * Descriptor of a database type. - * - * @param RuntimeType Type in programming language to which database type is converted. - */ -@Suppress("ClassName", "RemoveRedundantQualifierName") -public interface ColumnType<@Suppress("unused") RuntimeType> { - /** - * Name of database type for debugging and errors. - */ - @Suppress("INAPPLICABLE_JVM_NAME") - @get:JvmName("name") - public val name: String - - /** - * Provider of database types descriptors. - */ - @Suppress("FunctionName", "PropertyName") - public interface Builder { - /** - * Type of internal row id. Can't be casted to types like integers or pointers. - * @param TableUserExtension User's extension type for target table. For static type checking. - * @param table Descriptor of table whose row_id type will be obtained. - */ - @Suppress("INAPPLICABLE_JVM_NAME") - @JvmName("ROW_ID") - public fun ROW_ID(table: Table): ColumnType> - - /** - * Descriptor of a boolean type. Fields of this type can contain only 2 values: `true` and `false`. - */ - @Suppress("INAPPLICABLE_JVM_NAME") - @get:JvmName("BOOLEAN") - public val BOOLEAN: BOOLEAN - - /** - * Descriptor of a signed integer type with size at least 8 bits. Can contain values in range `-128..127`. - */ - @Suppress("INAPPLICABLE_JVM_NAME") - @get:JvmName("INT_S8") - public val INT_S8: INT_S8 - - /** - * Descriptor of an unsigned integer type with size at least 8 bits. Can contain values in range `0..255`. - */ - @Suppress("INAPPLICABLE_JVM_NAME") - @get:JvmName("INT_U8") - public val INT_U8: INT_U8 - - /** - * Descriptor of a signed integer type with size at least 16 bits. Can contain values in range `-32768..32767`. - */ - @Suppress("INAPPLICABLE_JVM_NAME") - @get:JvmName("INT_S16") - public val INT_S16: INT_S16 - - /** - * Descriptor of an unsigned integer type with size at least 16 bits. Can contain values in range `0..65535`. - */ - @Suppress("INAPPLICABLE_JVM_NAME") - @get:JvmName("INT_U16") - public val INT_U16: INT_U16 - - /** - * Descriptor of a signed integer type with size at least 32 bits. Can contain values in range `-2147483648..2147483647`. - */ - @Suppress("INAPPLICABLE_JVM_NAME") - @get:JvmName("INT_S32") - public val INT_S32: INT_S32 - - /** - * Descriptor of an unsigned integer type with size at least 32 bits. Can contain values in range `0..4294967295`. - */ - @Suppress("INAPPLICABLE_JVM_NAME") - @get:JvmName("INT_U32") - public val INT_U32: INT_U32 - - /** - * Descriptor of a signed integer type with size at least 64 bits. Can contain values in range `-9223372036854775808..9223372036854775807`. - */ - @Suppress("INAPPLICABLE_JVM_NAME") - @get:JvmName("INT_S64") - public val INT_S64: INT_S64 - - /** - * Descriptor of an unsigned integer type with size at least 64 bits. Can contain values in range `0..18446744073709551615`. - */ - @Suppress("INAPPLICABLE_JVM_NAME") - @get:JvmName("INT_U64") - public val INT_U64: INT_U64 - - /** - * Descriptor of a local date type in some format like `(year, month, day)`. Day component can contain values in `1..31`, month in `1..12` and year in `-32768..32767`. - */ - @Suppress("INAPPLICABLE_JVM_NAME") - @get:JvmName("LOCAL_DATE") - public val LOCAL_DATE: LOCAL_DATE - - /** - * Descriptor of a local time type in some format like `(hour, minute, second)`. Hour component can contain values in `0..23`, minute in `0..59` and second in `0..59`. - */ - @Suppress("INAPPLICABLE_JVM_NAME") - @get:JvmName("LOCAL_TIME") - public val LOCAL_TIME: LOCAL_TIME - - /** - * Descriptor of union of types [LOCAL_DATE][ColumnType.Builder.LOCAL_DATE] and [LOCAL_TIME][ColumnType.Builder.LOCAL_TIME]. - */ - @Suppress("INAPPLICABLE_JVM_NAME") - @get:JvmName("LOCAL_DATETIME") - public val LOCAL_DATETIME: LOCAL_DATETIME - - /** - * Descriptor of a timestamp type. Can contain values in `-9223372036854775808..9223372036854775807` - */ - @Suppress("INAPPLICABLE_JVM_NAME") - @get:JvmName("INSTANT") - public val INSTANT: INSTANT - - /** - * Descriptor of a single-precision floating-point number with size at least 32 bits. See [IEEE 754](https://en.wikipedia.org/wiki/IEEE_754). - */ - @Suppress("INAPPLICABLE_JVM_NAME") - @get:JvmName("FLOAT_32") - public val FLOAT_32: FLOAT_32 - - /** - * Descriptor of a double-precision floating-point number with size at least 64 bits. See [IEEE 754](https://en.wikipedia.org/wiki/IEEE_754). - */ - @Suppress("INAPPLICABLE_JVM_NAME") - @get:JvmName("FLOAT_64") - public val FLOAT_64: FLOAT_64 - - //todo - public val STRING: STRING - - //todo - public fun STRING(size: UInt): STRING - - //todo - public val BYTE_ARRAY: BYTE_ARRAY - - //todo - public fun BYTE_ARRAY(size: UInt): BYTE_ARRAY - - - /** - * Returns descriptor of a new type, which can contain all values of [original type][notNullType] or `null` value. - * - * Descriptors of nullable types are returned without any modifications. - */ - @Suppress("INAPPLICABLE_JVM_NAME") - @JvmName("nullableOf") - public fun > nullableOf(notNullType: D): Nullable - } - - // todo - public abstract class _VirtualType(@Suppress("MemberVisibilityCanBePrivate") @JvmField public val wraps: ColumnType) - - /** - * Descriptor of a nullable database type for static type-checking. - * @see ColumnType.Builder.nullableOf - */ - public interface Nullable> : ColumnType - - /** - * Descriptor of an internal row id type for static type-checking. - * @param TargetTableUserWrapper User's extension type for target table. For static type checking. - * @see ColumnType.Builder.ROW_ID - */ - public interface ROW_ID : ColumnType> - - /** - * Descriptor of a boolean type for static type-checking. - * @see ColumnType.Builder.BOOLEAN - */ - public interface BOOLEAN : ColumnType - - /** - * Descriptor of an integer type for static type-checking. - * @see ColumnType.Builder.INT_S8 - */ - public interface INT_S8 : ColumnType - - /** - * Descriptor of an integer type for static type-checking. - * @see ColumnType.Builder.INT_U8 - */ - public interface INT_U8 : ColumnType - - /** - * Descriptor of an integer type for static type-checking. - * @see ColumnType.Builder.INT_S16 - */ - public interface INT_S16 : ColumnType - - /** - * Descriptor of an integer type for static type-checking. - * @see ColumnType.Builder.INT_U16 - */ - public interface INT_U16 : ColumnType - - /** - * Descriptor of an integer type for static type-checking. - * @see ColumnType.Builder.INT_S32 - */ - public interface INT_S32 : ColumnType - - /** - * Descriptor of an integer type for static type-checking. - * @see ColumnType.Builder.INT_U32 - */ - public interface INT_U32 : ColumnType - - /** - * Descriptor of an integer type for static type-checking. - * @see ColumnType.Builder.INT_S64 - */ - public interface INT_S64 : ColumnType - - /** - * Descriptor of an integer type for static type-checking. - * @see ColumnType.Builder.INT_U64 - */ - public interface INT_U64 : ColumnType - - /** - * Descriptor of a date type for static type-checking. - * @see ColumnType.Builder.LOCAL_DATE - */ - public interface LOCAL_DATE : ColumnType - - /** - * Descriptor of a time type for static type-checking. - * @see ColumnType.Builder.LOCAL_TIME - */ - public interface LOCAL_TIME : ColumnType - - /** - * Descriptor of a date-time type for static type-checking. - * @see ColumnType.Builder.LOCAL_DATETIME - */ - public interface LOCAL_DATETIME : ColumnType - - /** - * Descriptor of a date-time type for static type-checking. - * @see ColumnType.Builder.INSTANT - */ - public interface INSTANT : ColumnType - - /** - * Descriptor of a floating-point number type for static type-checking. - * @see ColumnType.Builder.FLOAT_32 - */ - public interface FLOAT_32 : ColumnType - - /** - * Descriptor of a floating-point number type for static type-checking. - * @see ColumnType.Builder.FLOAT_64 - */ - public interface FLOAT_64 : ColumnType - - /** - * Descriptor of a string type for static type-checking. - * @see ColumnType.Builder.STRING - */ - public interface STRING : ColumnType - - /** - * Descriptor of a raw binary data type for static type-checking. - * @see ColumnType.Builder.BYTE_ARRAY - */ - @OptIn(ExperimentalUnsignedTypes::class) - public interface BYTE_ARRAY : ColumnType -} diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/ddl/types/DatabaseType.kt b/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/ddl/types/DatabaseType.kt new file mode 100644 index 0000000..b8e4e19 --- /dev/null +++ b/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/ddl/types/DatabaseType.kt @@ -0,0 +1,146 @@ +package ru.landgrafhomyak.serdha.api.v0.ddl.types + +import kotlin.jvm.JvmField +import kotlin.jvm.JvmName +import kotlinx.datetime.Instant +import kotlinx.datetime.LocalDate +import kotlinx.datetime.LocalDateTime +import kotlinx.datetime.LocalTime + +/** + * Descriptor of a database type. + * + * @param RuntimeType Type in programming language to which database type is converted. + */ +@Suppress("ClassName", "RemoveRedundantQualifierName") +public interface DatabaseType<@Suppress("unused") RuntimeType> { + /** + * Name of database type for debugging and errors. + */ + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("name") + public val name: String + + // todo + public abstract class _VirtualType(@Suppress("MemberVisibilityCanBePrivate") @JvmField public val wraps: DatabaseType) + + /** + * Descriptor of a nullable database type for static type-checking. + * @see DatabaseTypesProvider.nullableOf + */ + public interface Nullable> : DatabaseType + + /** + * Descriptor of an internal row id type for static type-checking. + * @param TargetTableUserWrapper User's extension type for target table. For static type checking. + * @see DatabaseTypesProvider.ROW_ID + */ + public interface ROW_ID : DatabaseType> + + /** + * Descriptor of a boolean type for static type-checking. + * @see DatabaseTypesProvider.BOOLEAN + */ + public interface BOOLEAN : DatabaseType + + /** + * Descriptor of an integer type for static type-checking. + * @see DatabaseTypesProvider.INT_S8 + */ + public interface INT_S8 : DatabaseType + + /** + * Descriptor of an integer type for static type-checking. + * @see DatabaseTypesProvider.INT_U8 + */ + public interface INT_U8 : DatabaseType + + /** + * Descriptor of an integer type for static type-checking. + * @see DatabaseTypesProvider.INT_S16 + */ + public interface INT_S16 : DatabaseType + + /** + * Descriptor of an integer type for static type-checking. + * @see DatabaseTypesProvider.INT_U16 + */ + public interface INT_U16 : DatabaseType + + /** + * Descriptor of an integer type for static type-checking. + * @see DatabaseTypesProvider.INT_S32 + */ + public interface INT_S32 : DatabaseType + + /** + * Descriptor of an integer type for static type-checking. + * @see DatabaseTypesProvider.INT_U32 + */ + public interface INT_U32 : DatabaseType + + /** + * Descriptor of an integer type for static type-checking. + * @see DatabaseTypesProvider.INT_S64 + */ + public interface INT_S64 : DatabaseType + + /** + * Descriptor of an integer type for static type-checking. + * @see DatabaseTypesProvider.INT_U64 + */ + public interface INT_U64 : DatabaseType + + /** + * Descriptor of a date type for static type-checking. + * @see DatabaseTypesProvider.LOCAL_DATE + */ + public interface LOCAL_DATE : DatabaseType + + /** + * Descriptor of a time type for static type-checking. + * @see DatabaseTypesProvider.LOCAL_TIME + */ + public interface LOCAL_TIME : DatabaseType + + /** + * Descriptor of a date-time type for static type-checking. + * @see DatabaseTypesProvider.LOCAL_DATETIME + */ + public interface LOCAL_DATETIME : DatabaseType + + /** + * Descriptor of a date-time type for static type-checking. + * @see DatabaseTypesProvider.INSTANT + */ + public interface INSTANT : DatabaseType + + /** + * Descriptor of a floating-point number type for static type-checking. + * @see DatabaseTypesProvider.FLOAT_32 + */ + public interface FLOAT_32 : DatabaseType + + /** + * Descriptor of a floating-point number type for static type-checking. + * @see DatabaseTypesProvider.FLOAT_64 + */ + public interface FLOAT_64 : DatabaseType + + /** + * Descriptor of a raw binary data type for static type-checking. + * @see DatabaseTypesProvider.BINARY_DATA + */ + @OptIn(ExperimentalUnsignedTypes::class) + public interface BINARY_DATA : DatabaseType { + /** + * Maximum count of bytes that can be stored by values of this type ot `null` if there is no limit. + */ + public val maxSizeOrNull: UInt? + + /** + * `true` if value can't hold less than [maxSizeOrNull][DatabaseType.BINARY_DATA.maxSizeOrNull] bytes. + */ + public val isFixedSize: Boolean + } +} diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/ddl/types/DatabaseTypesProvider.kt b/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/ddl/types/DatabaseTypesProvider.kt new file mode 100644 index 0000000..3966d77 --- /dev/null +++ b/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/ddl/types/DatabaseTypesProvider.kt @@ -0,0 +1,151 @@ +package ru.landgrafhomyak.serdha.api.v0.ddl.types + +import kotlin.jvm.JvmName +import ru.landgrafhomyak.serdha.api.v0.ddl.table.Table + +/** + * Provider of database types descriptors. + */ +@Suppress("FunctionName", "PropertyName") +public interface DatabaseTypesProvider { + /** + * Type of internal row id. Can't be casted to types like integers or pointers. + * @param TableUserExtension User's extension type for target table. For static type checking. + * @param table Descriptor of table whose row_id type will be obtained. + */ + @Suppress("INAPPLICABLE_JVM_NAME") + @JvmName("ROW_ID") + public fun ROW_ID(table: Table): DatabaseType> + + /** + * Descriptor of a boolean type. Fields of this type can contain only 2 values: `true` and `false`. + */ + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("BOOLEAN") + public val BOOLEAN: DatabaseType.BOOLEAN + + /** + * Descriptor of a signed integer type with size at least 8 bits. Can contain values in range `-128..127`. + */ + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("INT_S8") + public val INT_S8: DatabaseType.INT_S8 + + /** + * Descriptor of an unsigned integer type with size at least 8 bits. Can contain values in range `0..255`. + */ + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("INT_U8") + public val INT_U8: DatabaseType.INT_U8 + + /** + * Descriptor of a signed integer type with size at least 16 bits. Can contain values in range `-32768..32767`. + */ + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("INT_S16") + public val INT_S16: DatabaseType.INT_S16 + + /** + * Descriptor of an unsigned integer type with size at least 16 bits. Can contain values in range `0..65535`. + */ + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("INT_U16") + public val INT_U16: DatabaseType.INT_U16 + + /** + * Descriptor of a signed integer type with size at least 32 bits. Can contain values in range `-2147483648..2147483647`. + */ + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("INT_S32") + public val INT_S32: DatabaseType.INT_S32 + + /** + * Descriptor of an unsigned integer type with size at least 32 bits. Can contain values in range `0..4294967295`. + */ + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("INT_U32") + public val INT_U32: DatabaseType.INT_U32 + + /** + * Descriptor of a signed integer type with size at least 64 bits. Can contain values in range `-9223372036854775808..9223372036854775807`. + */ + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("INT_S64") + public val INT_S64: DatabaseType.INT_S64 + + /** + * Descriptor of an unsigned integer type with size at least 64 bits. Can contain values in range `0..18446744073709551615`. + */ + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("INT_U64") + public val INT_U64: DatabaseType.INT_U64 + + /** + * Descriptor of a local date type in some format like `(year, month, day)`. Day component can contain values in `1..31`, month in `1..12` and year in `-32768..32767`. + */ + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("LOCAL_DATE") + public val LOCAL_DATE: DatabaseType.LOCAL_DATE + + /** + * Descriptor of a local time type in some format like `(hour, minute, second)`. Hour component can contain values in `0..23`, minute in `0..59` and second in `0..59`. + */ + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("LOCAL_TIME") + public val LOCAL_TIME: DatabaseType.LOCAL_TIME + + /** + * Descriptor of union of types [LOCAL_DATE][DatabaseType.Builder.LOCAL_DATE] and [LOCAL_TIME][DatabaseType.Builder.LOCAL_TIME]. + */ + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("LOCAL_DATETIME") + public val LOCAL_DATETIME: DatabaseType.LOCAL_DATETIME + + /** + * Descriptor of a timestamp type. Can contain values in `-9223372036854775808..9223372036854775807` + */ + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("INSTANT") + public val INSTANT: DatabaseType.INSTANT + + /** + * Descriptor of a single-precision floating-point number with size at least 32 bits. See [IEEE 754](https://en.wikipedia.org/wiki/IEEE_754). + */ + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("FLOAT_32") + public val FLOAT_32: DatabaseType.FLOAT_32 + + /** + * Descriptor of a double-precision floating-point number with size at least 64 bits. See [IEEE 754](https://en.wikipedia.org/wiki/IEEE_754). + */ + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("FLOAT_64") + public val FLOAT_64: DatabaseType.FLOAT_64 + + /** + * Descriptor of a raw binary data type without size restrictions (must be controlled by user). + */ + @Suppress("INAPPLICABLE_JVM_NAME") + @get:JvmName("BINARY_DATA") + public val BINARY_DATA: DatabaseType.BINARY_DATA + + /** + * Descriptor of a raw binary data type that can holds maximum [size] bytes. + * + * @param size Maximum count of bytes that can be stored in the value of this type. + * @param isFixedSize If `true`, the type will restrict values with less than [size] bytes. + */ + @Suppress("INAPPLICABLE_JVM_NAME") + @JvmName("BINARY_DATA") + public fun BINARY_DATA(size: UInt, isFixedSize: Boolean): DatabaseType.BINARY_DATA + + + /** + * Returns descriptor of a new type, which can contain all values of [original type][notNullType] or `null` value. + * + * Descriptors of nullable types are returned itself without any modifications. + */ + @Suppress("INAPPLICABLE_JVM_NAME") + @JvmName("nullableOf") + public fun > nullableOf(notNullType: D): DatabaseType.Nullable +} \ No newline at end of file diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/dml/CreateCopyQueryScope.kt b/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/dml/CreateCopyQueryScope.kt index 8e66806..7ea3bf6 100644 --- a/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/dml/CreateCopyQueryScope.kt +++ b/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/dml/CreateCopyQueryScope.kt @@ -2,8 +2,8 @@ package ru.landgrafhomyak.serdha.api.v0.dml import ru.landgrafhomyak.serdha.api.v0.Expression import ru.landgrafhomyak.serdha.api.v0.ddl.table.Column -import ru.landgrafhomyak.serdha.api.v0.ddl.types.ColumnType +import ru.landgrafhomyak.serdha.api.v0.ddl.types.DatabaseType public interface CreateCopyQueryScope :_CreateInsertOrCopyQueryScope { - public fun > insert(column: Column, expression: Expression) + public fun > insert(column: Column, expression: Expression) } \ No newline at end of file diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/dml/CreateDeleteQueryScope.kt b/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/dml/CreateDeleteQueryScope.kt index 21845a7..9143081 100644 --- a/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/dml/CreateDeleteQueryScope.kt +++ b/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/dml/CreateDeleteQueryScope.kt @@ -1,12 +1,12 @@ package ru.landgrafhomyak.serdha.api.v0.dml import ru.landgrafhomyak.serdha.api.v0.Expression -import ru.landgrafhomyak.serdha.api.v0.ddl.types.ColumnType +import ru.landgrafhomyak.serdha.api.v0.ddl.types.DatabaseType public interface CreateDeleteQueryScope : _CommonCreateQueryScope { public val targetTable: SelectedTable - public fun where(expression: Expression) + public fun where(expression: Expression) public fun limit(size: UInt) diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/dml/CreateInsertQueryScope.kt b/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/dml/CreateInsertQueryScope.kt index c312a79..12e718c 100644 --- a/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/dml/CreateInsertQueryScope.kt +++ b/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/dml/CreateInsertQueryScope.kt @@ -2,19 +2,19 @@ package ru.landgrafhomyak.serdha.api.v0.dml import ru.landgrafhomyak.serdha.api.v0.Expression import ru.landgrafhomyak.serdha.api.v0.ddl.table.Column -import ru.landgrafhomyak.serdha.api.v0.ddl.types.ColumnType +import ru.landgrafhomyak.serdha.api.v0.ddl.types.DatabaseType -public interface CreateInsertQueryScope :_CreateInsertOrCopyQueryScope { +public interface CreateInsertQueryScope : _CreateInsertOrCopyQueryScope { public class DataParam<@Suppress("unused") QueryUserExtension : Any> private constructor() public val dataExpressionBuilder: Expression.Builder> - public fun > dataParam(name: String, type: DatabaseType): InputParam> + public fun > dataParam(name: String, type: DT): InputParam> - public fun > insertParam( - column: Column, + public fun > insertParam( + column: Column, paramName: String = column.name, - ): InputParam> + ): InputParam> - public fun > insert(column: Column, expression: Expression>) + public fun > insert(column: Column, expression: Expression>) } \ No newline at end of file diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/dml/CreateSelectQueryScope.kt b/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/dml/CreateSelectQueryScope.kt index f01e510..b1d6c1f 100644 --- a/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/dml/CreateSelectQueryScope.kt +++ b/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/dml/CreateSelectQueryScope.kt @@ -1,10 +1,10 @@ package ru.landgrafhomyak.serdha.api.v0.dml import ru.landgrafhomyak.serdha.api.v0.Expression -import ru.landgrafhomyak.serdha.api.v0.ddl.types.ColumnType +import ru.landgrafhomyak.serdha.api.v0.ddl.types.DatabaseType public interface CreateSelectQueryScope : _CommonCreateQueryScope, _CommonCreateQueryScope._ReturningClauseScope{ - public fun where(expression: Expression) + public fun where(expression: Expression) public fun limit(size: UInt) diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/dml/CreateUpdateQueryScope.kt b/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/dml/CreateUpdateQueryScope.kt index 494a955..aa046f2 100644 --- a/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/dml/CreateUpdateQueryScope.kt +++ b/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/dml/CreateUpdateQueryScope.kt @@ -2,16 +2,16 @@ package ru.landgrafhomyak.serdha.api.v0.dml import ru.landgrafhomyak.serdha.api.v0.Expression import ru.landgrafhomyak.serdha.api.v0.ddl.table.Column -import ru.landgrafhomyak.serdha.api.v0.ddl.types.ColumnType +import ru.landgrafhomyak.serdha.api.v0.ddl.types.DatabaseType public interface CreateUpdateQueryScope : _CommonCreateQueryScope { public val targetTable: SelectedTable - public fun > selectOldColumnValue(c: Column): Expression + public fun > selectOldColumnValue(c: Column): Expression - public fun > updateColumn(c: Column, e: Expression) + public fun > updateColumn(c: Column, e: Expression) - public fun where(expression: Expression) + public fun where(expression: Expression) public fun limit(size: UInt) diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/dml/InputParam.kt b/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/dml/InputParam.kt index a35bf4d..2e5e2fe 100644 --- a/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/dml/InputParam.kt +++ b/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/dml/InputParam.kt @@ -1,9 +1,9 @@ package ru.landgrafhomyak.serdha.api.v0.dml import ru.landgrafhomyak.serdha.api.v0.Expression -import ru.landgrafhomyak.serdha.api.v0.ddl.types.ColumnType +import ru.landgrafhomyak.serdha.api.v0.ddl.types.DatabaseType -public interface InputParam, OwnerQueryUserExtension : Any> : Expression { +public interface InputParam, OwnerQueryUserExtension : Any> : Expression { public val name: String public val userWrapper: OwnerQueryUserExtension } \ No newline at end of file diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/dml/SelectedTable.kt b/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/dml/SelectedTable.kt index 94dcf89..044eabb 100644 --- a/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/dml/SelectedTable.kt +++ b/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/dml/SelectedTable.kt @@ -2,8 +2,7 @@ package ru.landgrafhomyak.serdha.api.v0.dml import ru.landgrafhomyak.serdha.api.v0.Expression import ru.landgrafhomyak.serdha.api.v0.ddl.table.Column -import ru.landgrafhomyak.serdha.api.v0.ddl.types.ColumnType public interface SelectedTable { - public fun > selectColumn(column: Column): Expression + public fun > selectColumn(column: Column): Expression } \ No newline at end of file diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/dml/_CommonCreateQueryScope.kt b/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/dml/_CommonCreateQueryScope.kt index 8f97047..20679fd 100644 --- a/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/dml/_CommonCreateQueryScope.kt +++ b/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/dml/_CommonCreateQueryScope.kt @@ -3,21 +3,22 @@ package ru.landgrafhomyak.serdha.api.v0.dml import ru.landgrafhomyak.serdha.api.v0.Expression import ru.landgrafhomyak.serdha.api.v0.LowLevelApi import ru.landgrafhomyak.serdha.api.v0.ddl.table.Column -import ru.landgrafhomyak.serdha.api.v0.ddl.types.ColumnType +import ru.landgrafhomyak.serdha.api.v0.ddl.types.DatabaseType import ru.landgrafhomyak.serdha.api.v0.ddl.table.Table +import ru.landgrafhomyak.serdha.api.v0.ddl.types.DatabaseTypesProvider import ru.landgrafhomyak.serdha.api.v0.runtime.ParametersSetter import ru.landgrafhomyak.serdha.api.v0.runtime._ParametersSetter @Suppress("ClassName") public interface _CommonCreateQueryScope { - public val types: ColumnType.Builder + public val types: DatabaseTypesProvider public fun selectTable(t: Table): SelectedTable public interface CanBeSubquery<@Suppress("unused") SelectedQueryUserExtension : Any> public interface SubqueryParametersSetter : ParametersSetter { - public operator fun > set(c: InputParam, value: Expression) + public operator fun > set(c: InputParam, value: Expression) } public fun selectQuery(q: CanBeSubquery, p: (SubqueryParametersSetter) -> Unit): SelectedTable @@ -54,12 +55,12 @@ public interface _CommonCreateQueryScope { ): SelectedDiff = this._selectCopy(q, p) { rr -> for (e in data) r(e, rr) } - public fun > param(name: String, type: DatabaseType): InputParam + public fun > param(name: String, type: DT): InputParam public val expressionBuilder: Expression.Builder public interface _ReturningClauseScope { - public fun > returnExpression(expression: Expression): Column + public fun > returnExpression(expression: Expression): Column public val isDistinct: Boolean diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/dml/_CreateInsertOrCopyQueryScope.kt b/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/dml/_CreateInsertOrCopyQueryScope.kt index f1431e8..9bbcebc 100644 --- a/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/dml/_CreateInsertOrCopyQueryScope.kt +++ b/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/dml/_CreateInsertOrCopyQueryScope.kt @@ -2,8 +2,8 @@ package ru.landgrafhomyak.serdha.api.v0.dml import ru.landgrafhomyak.serdha.api.v0.Expression import ru.landgrafhomyak.serdha.api.v0.ddl.table.Column -import ru.landgrafhomyak.serdha.api.v0.ddl.types.ColumnType import ru.landgrafhomyak.serdha.api.v0.ddl.table.UniqueIndex +import ru.landgrafhomyak.serdha.api.v0.ddl.types.DatabaseType @Suppress("ClassName") public interface _CreateInsertOrCopyQueryScope : _CommonCreateQueryScope { @@ -11,9 +11,9 @@ public interface _CreateInsertOrCopyQueryScope { - public fun > oldColumnValue(c: Column): Expression + public fun > oldColumnValue(c: Column): Expression - public fun > updateColumn(c: Column, e: Expression) + public fun > updateColumn(c: Column, e: Expression) } public fun onConflictUpdate(u: UniqueIndex, c: (_UpsertClauseScope) -> Unit) @@ -26,7 +26,7 @@ public interface _CreateInsertOrCopyQueryScope : _CommonCreateQueryScope._ReturningClauseScope { - public fun > oldColumnValue(c: Column): Expression + public fun > oldColumnValue(c: Column): Expression } public val returningUpdated: _ReturningUpdatedClauseScope