No-value Behavior

No-value Behavior

The no-value strategy handles dynamic condition arguments that are null or empty collections. Literal field == null and field != null in a condition lambda mean SQL IS NULL and IS NOT NULL.

Default Behavior

For dynamic condition values that enter the no-value strategy, the default logic is:

Control dynamic no-value predicates

Use Kotlin conditions to decide which predicate participates. Use .takeIf(...) to keep a predicate when its condition is true, .takeUnless(...) to keep it when the condition is false, and ordinary if/else or when when a missing value needs an explicit fallback.

val age: Int? = null
val namePattern: String? = null

where { (it.age == age).takeIf(age != null) }
where { (it.status == 0).takeUnless(includeInactive) }
where {
    if (namePattern != null) {
        it.name like namePattern
    } else {
        false.asSql()
    }
}
where { it.age.isNull.takeIf(age == null) }

The Boolean arguments of takeIf/takeUnless and the conditions of if/when are ordinary Kotlin control flow. They do not become SQL predicates.

No-value outcomes

Kronos uses these outcomes internally when it handles no-value conditions:

namedescriptiontypedefault
IgnoreIgnore this conditional statementOutcomeignore
FalseThe conditional statement is falseOutcomefalse
TrueThe conditional statement is trueOutcometrue
JudgeNullConvert to `is null` or `is not null`OutcomejudgeNull
AutoUse Kronos default behaviorOutcomeauto