Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Persisting literal values more conservativly #1907

Merged
merged 2 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,14 @@ class Literal<T> : Expression() {

class ValueConverter : AttributeConverter<Any?, Any?> {
override fun toGraphProperty(value: Any?): Any? {
return if (value is BigInteger) {
value.toString()
} else {
value
// Neo4J only supports a limited set of primitive values natively, everything else, we need
// to convert to a string.
return when (value) {
null -> null
(value is Number && value !is BigInteger) -> value
is Boolean -> value
is String -> value
else -> value.toString()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import de.fraunhofer.aisec.cpg.graph.Persistable
import de.fraunhofer.aisec.cpg.graph.edges.collections.EdgeCollection
import de.fraunhofer.aisec.cpg.graph.edges.collections.EdgeList
import de.fraunhofer.aisec.cpg.helpers.neo4j.NameConverter
import java.math.BigInteger
import kotlin.reflect.KClass
import kotlin.reflect.KProperty1
import kotlin.reflect.KTypeProjection
Expand Down Expand Up @@ -134,8 +133,6 @@ fun Any.convert(
properties.put(originalKey, this.name)
} else if (this is Uuid) {
properties.put(originalKey, this.toString())
} else if (this is BigInteger) {
properties.put(originalKey, this.toString())
} else {
properties.put(originalKey, this)
}
Expand Down
Loading