Skip to content

Commit cc40e83

Browse files
authored
Merge pull request #227 from modelix/bugfix/MODELIX-528_fix_isEmpty
fix(modelql): let isEmpty return true on empty inputs
2 parents 31a340e + df7a7a9 commit cc40e83

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

modelql-client/src/jvmTest/kotlin/org/modelix/modelql/client/HtmlBuilderTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ class HtmlBuilderTest {
175175
}
176176
}
177177
}
178-
val expected = """<html><body><ul><li>null<ul><li>abc<ul><li>model1a<ul></ul></li><li>model1b<ul></ul></li></ul></li></ul></li></ul></body></html>"""
178+
val expected = """<html><body><ul><li>null<ul><li>abc<ul><li>model1a</li><li>model1b</li></ul></li></ul></li></ul></body></html>"""
179179
assertEquals(expected, actual)
180180
}
181181
}

modelql-core/src/commonMain/kotlin/org/modelix/modelql/core/IsEmptyStep.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import kotlinx.serialization.serializer
2525

2626
class IsEmptyStep() : AggregationStep<Any?, Boolean>() {
2727
override suspend fun aggregate(input: StepFlow<Any?>): IStepOutput<Boolean> {
28-
return input.take(1).map { false }.onEmpty { emit(false) }.single().asStepOutput(this)
28+
return input.take(1).map { false }.onEmpty { emit(true) }.single().asStepOutput(this)
2929
}
3030

3131
override fun aggregate(input: Sequence<IStepOutput<Any?>>): IStepOutput<Boolean> = input.none().asStepOutput(this)

modelql-core/src/commonTest/kotlin/org/modelix/modelql/core/ModelQLTest.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,14 @@ class ModelQLTest {
151151
assertEquals("alternative", result)
152152
}
153153

154+
@Test
155+
fun testIsEmpty() = runTestWithTimeout {
156+
val result: Boolean = remoteProductDatabaseQuery { db ->
157+
db.products.filter { it.id.equalTo(-1) }.isEmpty()
158+
}
159+
assertTrue(result)
160+
}
161+
154162
@Test
155163
fun test2() = runTestWithTimeout {
156164
val result: List<String> = remoteProductDatabaseQuery { db ->

0 commit comments

Comments
 (0)