diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/misc/DatabaseType.kt b/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/misc/DatabaseType.kt index 0a5d616..f4abc53 100644 --- a/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/misc/DatabaseType.kt +++ b/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/misc/DatabaseType.kt @@ -15,118 +15,33 @@ import ru.landgrafhomyak.serdha.api.v0.table.RowId */ @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) + public abstract class _VirtualType( + @Suppress("MemberVisibilityCanBePrivate") @JvmField + public val wraps: DatabaseType + ) : DatabaseType { + @Suppress("FunctionName") + public abstract fun _unwrap(w: WRT): SRT - /** - * Descriptor of a nullable database type for static type-checking. - * @see DatabaseTypesProvider.nullableOf - */ - public interface Nullable> : DatabaseType + @Suppress("FunctionName") + public abstract fun _wrap(w: SRT): WRT - /** - * 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> + @Suppress("FunctionName") + public abstract fun _equals(l: SRT, r: SRT): Boolean + + @Suppress("FunctionName") + public abstract fun _compare(l: SRT, r: SRT): Int + } + + public interface _ROW_ID?, TargetTableUserWrapper : Any> : DatabaseType + public interface ROW_ID : _ROW_ID, TargetTableUserWrapper> + public interface NULLABLE_ROW_ID : _ROW_ID?, TargetTableUserWrapper> - /** - * 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 + public interface NULLABLE_BOOLEAN : DatabaseType /** * Descriptor of a raw binary data type for static type-checking. diff --git a/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/misc/DatabaseTypesProvider.kt b/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/misc/DatabaseTypesProvider.kt index 10a1f83..117bcd2 100644 --- a/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/misc/DatabaseTypesProvider.kt +++ b/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/misc/DatabaseTypesProvider.kt @@ -18,110 +18,17 @@ public interface DatabaseTypesProvider { @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") + @JvmName("NULLABLE_ROW_ID") + public fun NULLABLE_ROW_ID(table: Table): DatabaseType> + @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 + @get:JvmName("NULLABLE_BOOLEAN") + public val NULLABLE_BOOLEAN: DatabaseType.NULLABLE_BOOLEAN /** * Descriptor of a raw binary data type without size restrictions (must be controlled by user). @@ -139,14 +46,4 @@ public interface DatabaseTypesProvider { @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/misc/Expression.kt b/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/misc/Expression.kt index 6b3e327..aa877af 100644 --- a/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/misc/Expression.kt +++ b/src/commonMain/kotlin/ru/landgrafhomyak/serdha/api/v0/misc/Expression.kt @@ -1,456 +1,7 @@ package ru.landgrafhomyak.serdha.api.v0.misc -import kotlinx.datetime.Instant -import kotlinx.datetime.LocalDate -import kotlinx.datetime.LocalDateTime -import kotlinx.datetime.LocalTime - public interface Expression, OwnerBuilderUserExtension : Any> { public interface Builder { - public fun
> equals( - left: Expression<*, DT, OwnerBuilderUserExtension>, - right: Expression<*, DT, 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<*, DatabaseType.Nullable<*, *>, OwnerBuilderUserExtension>, - ): Expression - - public fun isNotNull( - e: Expression<*, DatabaseType.Nullable<*, *>, OwnerBuilderUserExtension>, - ): Expression = - this.logicalNot(this.isNull(e)) - - public fun logicalAnd( - left: Expression<*, DatabaseType.BOOLEAN, OwnerBuilderUserExtension>, - right: Expression<*, DatabaseType.BOOLEAN, OwnerBuilderUserExtension>, - ): Expression - - public fun logicalOr( - left: Expression<*, DatabaseType.BOOLEAN, OwnerBuilderUserExtension>, - right: Expression<*, DatabaseType.BOOLEAN, OwnerBuilderUserExtension>, - ): Expression - - public fun logicalXor( - left: Expression<*, DatabaseType.BOOLEAN, OwnerBuilderUserExtension>, - right: Expression<*, DatabaseType.BOOLEAN, OwnerBuilderUserExtension>, - ): Expression = - this.notEquals(left, right) - - public fun logicalNot( - e: Expression<*, DatabaseType.BOOLEAN, OwnerBuilderUserExtension>, - ): Expression - - public fun cmpIntegersLess( - left: Expression, - right: Expression, - ): Expression - - public fun cmpIntegersLess( - left: Expression, - right: Expression, - ): Expression - - public fun cmpIntegersLess( - left: Expression, - right: Expression, - ): Expression - - public fun cmpIntegersLess( - left: Expression, - right: Expression, - ): Expression - - public fun cmpIntegersLess( - left: Expression, - right: Expression, - ): Expression - - public fun cmpIntegersLess( - left: Expression, - right: Expression, - ): Expression - - public fun cmpIntegersLess( - left: Expression, - right: Expression, - ): Expression - - public fun cmpIntegersLess( - left: Expression, - right: Expression, - ): Expression - - public fun cmpIntegersLessOrEquals( - left: Expression, - right: Expression, - ): Expression - - public fun cmpIntegersLessOrEquals( - left: Expression, - right: Expression, - ): Expression - - public fun cmpIntegersLessOrEquals( - left: Expression, - right: Expression, - ): Expression - - public fun cmpIntegersLessOrEquals( - left: Expression, - right: Expression, - ): Expression - - public fun cmpIntegersLessOrEquals( - left: Expression, - right: Expression, - ): Expression - - public fun cmpIntegersLessOrEquals( - left: Expression, - right: Expression, - ): Expression - - public fun cmpIntegersLessOrEquals( - left: Expression, - right: Expression, - ): Expression - - public fun cmpIntegersLessOrEquals( - left: Expression, - right: Expression, - ): Expression - - public fun cmpIntegersGreater( - left: Expression, - right: Expression, - ): Expression - - public fun cmpIntegersGreater( - left: Expression, - right: Expression, - ): Expression - - public fun cmpIntegersGreater( - left: Expression, - right: Expression, - ): Expression - - public fun cmpIntegersGreater( - left: Expression, - right: Expression, - ): Expression - - public fun cmpIntegersGreater( - left: Expression, - right: Expression, - ): Expression - - public fun cmpIntegersGreater( - left: Expression, - right: Expression, - ): Expression - - public fun cmpIntegersGreater( - left: Expression, - right: Expression, - ): Expression - - public fun cmpIntegersGreater( - left: Expression, - right: Expression, - ): Expression - - public fun cmpIntegersGreaterOrEquals( - left: Expression, - right: Expression, - ): Expression - - public fun cmpIntegersGreaterOrEquals( - left: Expression, - right: Expression, - ): Expression - - public fun cmpIntegersGreaterOrEquals( - left: Expression, - right: Expression, - ): Expression - - public fun cmpIntegersGreaterOrEquals( - left: Expression, - right: Expression, - ): Expression - - public fun cmpIntegersGreaterOrEquals( - left: Expression, - right: Expression, - ): Expression - - public fun cmpIntegersGreaterOrEquals( - left: Expression, - right: Expression, - ): Expression - - public fun cmpIntegersGreaterOrEquals( - left: Expression, - right: Expression, - ): Expression - - public fun cmpIntegersGreaterOrEquals( - left: Expression, - right: Expression, - ): Expression - - public fun extendIntegerToS16( - e: Expression, - ): Expression - - public fun extendIntegerToS16( - e: Expression, - ): Expression - - public fun extendIntegerToU16( - e: Expression, - ): Expression - - public fun extendIntegerToS32( - e: Expression, - ): Expression - - public fun extendIntegerToS32( - e: Expression, - ): Expression - - public fun extendIntegerToS32( - e: Expression, - ): Expression - - public fun extendIntegerToS32( - e: Expression, - ): Expression - - public fun extendIntegerToU32( - e: Expression, - ): Expression - - public fun extendIntegerToU32( - e: Expression, - ): Expression - - public fun extendIntegerToS64( - e: Expression, - ): Expression - - public fun extendIntegerToS64( - e: Expression, - ): Expression - - public fun extendIntegerToS64( - e: Expression, - ): Expression - - public fun extendIntegerToS64( - e: Expression, - ): Expression - - public fun extendIntegerToS64( - e: Expression, - ): Expression - - public fun extendIntegerToS64( - e: Expression, - ): Expression - - public fun extendIntegerToU64( - e: Expression, - ): Expression - - public fun extendIntegerToU64( - e: Expression, - ): Expression - - public fun extendIntegerToU64( - e: Expression, - ): Expression - - public fun extendFractionalToDouble( - e: Expression - ): Expression - - public fun cmpFractionalLess( - left: Expression, - right: Expression, - ): Expression - - public fun cmpFractionalLess( - left: Expression, - right: Expression, - ): Expression - - public fun cmpFractionalLessOrEquals( - left: Expression, - right: Expression, - ): Expression - - public fun cmpFractionalLessOrEquals( - left: Expression, - right: Expression, - ): Expression - - public fun cmpFractionalGreater( - left: Expression, - right: Expression, - ): Expression - - public fun cmpFractionalGreater( - left: Expression, - right: Expression, - ): Expression - - public fun cmpFractionalGreaterOrEquals( - left: Expression, - right: Expression, - ): Expression - - public fun cmpFractionalGreaterOrEquals( - left: Expression, - right: Expression, - ): Expression - - public fun cmpLocalDateEarlier( - left: Expression, - right: Expression, - ): Expression - - public fun cmpLocalDateEarlierOrSimultaneous( - left: Expression, - right: Expression, - ): Expression - - public fun cmpLocalDateLater( - left: Expression, - right: Expression, - ): Expression - - public fun cmpLocalDateLaterOrSimultaneous( - left: Expression, - right: Expression, - ): Expression - - public fun cmpLocalTimeEarlier( - left: Expression, - right: Expression, - ): Expression - - public fun cmpLocalTimeEarlierOrSimultaneous( - left: Expression, - right: Expression, - ): Expression - - public fun cmpLocalTimeLater( - left: Expression, - right: Expression, - ): Expression - - public fun cmpLocalTimeLaterOrSimultaneous( - left: Expression, - right: Expression, - ): Expression - - public fun cmpLocalDateTimeEarlier( - left: Expression, - right: Expression, - ): Expression - - public fun cmpLocalDateTimeEarlierOrSimultaneous( - left: Expression, - right: Expression, - ): Expression - - public fun cmpLocalDateTimeLater( - left: Expression, - right: Expression, - ): Expression - - public fun cmpLocalDateTimeLaterOrSimultaneous( - left: Expression, - right: Expression, - ): Expression - - public fun cmpInstantEarlier( - left: Expression, - right: Expression, - ): Expression - - public fun cmpInstantEarlierOrSimultaneous( - left: Expression, - right: Expression, - ): Expression - - public fun cmpInstantLater( - left: Expression, - right: Expression, - ): Expression - - public fun cmpInstantLaterOrSimultaneous( - left: Expression, - right: Expression, - ): Expression - - public fun dateComponentOf( - dt: Expression, - ): Expression - - public fun timeComponentOf( - dt: Expression, - ): Expression - - - public fun joinDateTime( - date: Expression, - time: Expression, - ): 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 , 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 > nullOr( - nullable: Expression, OwnerBuilderUserExtension>, - onValue: (Expression) -> Expression, - ): Expression } } \ No newline at end of file