File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed
commonMain/kotlin/org/modelix/modelql/core
commonTest/kotlin/org/modelix/modelql/core Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -492,7 +492,7 @@ class QueryInput<E> : ProducingStep<E>(), IMonoStep<E> {
492
492
}
493
493
494
494
override fun createStream (context : IStreamInstantiationContext ): StepStream <E > {
495
- throw RuntimeException ( " The stream for the query input step is expected to be created by the query" )
495
+ throw IllegalArgumentException ( " Unsupported cross- query usage of $this in ${owner. query} " )
496
496
}
497
497
498
498
override fun canBeEmpty (): Boolean = false
Original file line number Diff line number Diff line change @@ -360,6 +360,19 @@ class ModelQLTest {
360
360
assertEquals(" Samsung Universe 9" , result)
361
361
}
362
362
363
+ @Test
364
+ fun testIllegalCrossQueryStreams () = runTestWithTimeout {
365
+ val ex = assertFailsWith(IllegalArgumentException ::class ) {
366
+ remoteProductDatabaseQuery<String > { db ->
367
+ // The `elements` query uses the outside `db` instead of the input `it`.
368
+ // The query is only allowed to use values from its input, otherwise it wouldn't be cacheable.
369
+ db.find({ db.products }, { it.id }, 3 .asMono()).title
370
+ }
371
+ }
372
+ val expectedMessage = " Unsupported cross-query usage of"
373
+ assertEquals(expectedMessage, (ex.message ? : " " ).take(expectedMessage.length))
374
+ }
375
+
363
376
@Test
364
377
fun testFindAll () = runTestWithTimeout {
365
378
val result: List <String > = remoteProductDatabaseQuery { db ->
You can’t perform that action at this time.
0 commit comments