Nullable expressions unwrapper

This commit is contained in:
Andrew Golovashevich 2024-12-29 16:56:47 +03:00
parent b413a7ee9f
commit ed5d63cc28

View File

@ -7,20 +7,13 @@ import kotlinx.datetime.LocalTime
import ru.landgrafhomyak.serdha.api.v0.ddl.ColumnType import ru.landgrafhomyak.serdha.api.v0.ddl.ColumnType
public interface Expression<RuntimeType, DatabaseType : ColumnType<RuntimeType>, OwnerBuilderUserExtension : Any> { public interface Expression<RuntimeType, DatabaseType : ColumnType<RuntimeType>, OwnerBuilderUserExtension : Any> {
public interface Builder<OwnerBuilderUserExtension : Any> { public interface Builder<OwnerBuilderUserExtension : Any> {
@Target(AnnotationTarget.FUNCTION) public fun <DatabaseType : ColumnType<*>> equals(
@Retention(AnnotationRetention.BINARY)
@RequiresOptIn
public annotation class DynamicTyping
public fun <RuntimeType, DatabaseType : ColumnType<RuntimeType>> equals(
left: Expression<*, DatabaseType, OwnerBuilderUserExtension>, left: Expression<*, DatabaseType, OwnerBuilderUserExtension>,
right: Expression<*, DatabaseType, OwnerBuilderUserExtension>, right: Expression<*, DatabaseType, OwnerBuilderUserExtension>,
): Expression<Boolean, ColumnType.BOOLEAN, OwnerBuilderUserExtension> ): Expression<Boolean, ColumnType.BOOLEAN, OwnerBuilderUserExtension>
public fun <RuntimeType, DatabaseType : ColumnType<RuntimeType>> notEquals( public fun <DatabaseType : ColumnType<*>> notEquals(
left: Expression<*, DatabaseType, OwnerBuilderUserExtension>, left: Expression<*, DatabaseType, OwnerBuilderUserExtension>,
right: Expression<*, DatabaseType, OwnerBuilderUserExtension>, right: Expression<*, DatabaseType, OwnerBuilderUserExtension>,
): Expression<Boolean, ColumnType.BOOLEAN, OwnerBuilderUserExtension> = ): Expression<Boolean, ColumnType.BOOLEAN, OwnerBuilderUserExtension> =
@ -442,7 +435,24 @@ public interface Expression<RuntimeType, DatabaseType : ColumnType<RuntimeType>,
public fun constantOf(v: LocalTime): Expression<LocalTime, ColumnType.LOCAL_TIME, OwnerBuilderUserExtension> public fun constantOf(v: LocalTime): Expression<LocalTime, ColumnType.LOCAL_TIME, OwnerBuilderUserExtension>
public fun constantOf(v: LocalDateTime): Expression<LocalDateTime, ColumnType.LOCAL_DATETIME, OwnerBuilderUserExtension> public fun constantOf(v: LocalDateTime): Expression<LocalDateTime, ColumnType.LOCAL_DATETIME, OwnerBuilderUserExtension>
public fun constantOf(v: Instant): Expression<Instant, ColumnType.INSTANT, OwnerBuilderUserExtension> public fun constantOf(v: Instant): Expression<Instant, ColumnType.INSTANT, OwnerBuilderUserExtension>
@OptIn(ExperimentalUnsignedTypes::class) @OptIn(ExperimentalUnsignedTypes::class)
public fun constantOf(v: ByteArray): Expression<UByteArray, ColumnType.BYTE_ARRAY, OwnerBuilderUserExtension> public fun constantOf(v: ByteArray): Expression<UByteArray, ColumnType.BYTE_ARRAY, OwnerBuilderUserExtension>
public fun <ArgRuntimeType : Any, ArgDatabaseType : ColumnType<ArgRuntimeType>, RetRuntimeType, RetDatabaseType : ColumnType<RetRuntimeType>> ifNull(
nullable: Expression<ArgRuntimeType?, ColumnType.Nullable<ArgRuntimeType, ArgDatabaseType>, OwnerBuilderUserExtension>,
onValue: (Expression<ArgRuntimeType, ArgDatabaseType, OwnerBuilderUserExtension>) -> Expression<RetRuntimeType, RetDatabaseType, OwnerBuilderUserExtension>,
onNull: () -> Expression<RetRuntimeType, RetDatabaseType, OwnerBuilderUserExtension>
): Expression<RetRuntimeType, RetDatabaseType, OwnerBuilderUserExtension>
public fun <ArgRuntimeType : Any, ArgDatabaseType : ColumnType<ArgRuntimeType>> notNullAnd(
nullable: Expression<ArgRuntimeType?, ColumnType.Nullable<ArgRuntimeType, ArgDatabaseType>, OwnerBuilderUserExtension>,
onValue: (Expression<ArgRuntimeType, ArgDatabaseType, OwnerBuilderUserExtension>) -> Expression<Boolean, ColumnType.BOOLEAN, OwnerBuilderUserExtension>,
): Expression<Boolean, ColumnType.BOOLEAN, OwnerBuilderUserExtension>
public fun <ArgRuntimeType : Any, ArgDatabaseType : ColumnType<ArgRuntimeType>> nullOr(
nullable: Expression<ArgRuntimeType?, ColumnType.Nullable<ArgRuntimeType, ArgDatabaseType>, OwnerBuilderUserExtension>,
onValue: (Expression<ArgRuntimeType, ArgDatabaseType, OwnerBuilderUserExtension>) -> Expression<Boolean, ColumnType.BOOLEAN, OwnerBuilderUserExtension>,
): Expression<Boolean, ColumnType.BOOLEAN, OwnerBuilderUserExtension>
} }
} }