Skip to content

Commit

Permalink
fix(modelql)!: disable implicit queries to avoid accidental performan…
Browse files Browse the repository at this point in the history
…ce issues

You should fix the unintended implicit queries or use .query explicitly.
You can also set the environment variable MODELQL_IMPLICIT_QUERIES_ENABLED=true to re-enable this
feature.
  • Loading branch information
slisson committed Dec 8, 2024
1 parent b7734da commit b6cd91a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ class TypedModelQLTest {
.untyped()
.toList()
}.map { it.typed<StaticMethodDeclaration>() }
assertEquals("plus", result[0].name)
assertEquals("plus", result[0].query { it.name })
}

@Test
Expand All @@ -239,7 +239,7 @@ class TypedModelQLTest {
.filter { it.visibility.instanceOf(C_PublicVisibility) }
.toList()
}
assertEquals("plus", result[0].name)
assertEquals("plus", result[0].query { it.name })
}

@Test
Expand All @@ -257,8 +257,9 @@ class TypedModelQLTest {
.member
.ofConcept(C_StaticMethodDeclaration)
.first()
.name
}
assertEquals(expected, actual.name)
assertEquals(expected, actual)
}

@Test
Expand Down Expand Up @@ -297,7 +298,7 @@ class TypedModelQLTest {
.first()
}
assertNotEquals(expected, oldValue)
assertEquals(expected, actual.variableDeclaration.name)
assertEquals(expected, actual.query { it.variableDeclaration.name })
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
package org.modelix.modelql.client

actual val implicitQueriesEnabled: Boolean
get() = false
get() = false
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import org.modelix.model.api.IChildLinkReference
import org.modelix.model.api.IConceptReference
import org.modelix.model.api.INode
import org.modelix.model.api.IPropertyReference
import org.modelix.model.api.IReferenceLinkReference
import org.modelix.model.api.NodeReference
import org.modelix.model.api.PBranch
import org.modelix.model.api.getRootNode
Expand All @@ -43,6 +44,7 @@ import org.modelix.modelql.core.fold
import org.modelix.modelql.core.map
import org.modelix.modelql.core.memoize
import org.modelix.modelql.core.notEqualTo
import org.modelix.modelql.core.orNull
import org.modelix.modelql.core.plus
import org.modelix.modelql.core.sum
import org.modelix.modelql.core.toList
Expand All @@ -58,6 +60,7 @@ import org.modelix.modelql.untyped.descendants
import org.modelix.modelql.untyped.nodeReference
import org.modelix.modelql.untyped.property
import org.modelix.modelql.untyped.query
import org.modelix.modelql.untyped.reference
import org.modelix.modelql.untyped.remove
import org.modelix.modelql.untyped.resolve
import org.modelix.modelql.untyped.setProperty
Expand Down Expand Up @@ -258,7 +261,7 @@ class ModelQLClientTest {
fun `test IMonoStep nodeRefAndConcept`() = runTest { httpClient ->
val client = ModelQLClient("http://localhost/query", httpClient)

val nullNode = client.getRootNode().getReferenceTarget("nonExistentReference")
val nullNode = client.getRootNode().query { it.reference(IReferenceLinkReference.fromName("nonExistentReference")).orNull() }

assertEquals(null, nullNode)
}
Expand Down

0 comments on commit b6cd91a

Please sign in to comment.