Skip to content

Commit

Permalink
Persisting literal values more conservativly
Browse files Browse the repository at this point in the history
Fixes issues with python interface files
  • Loading branch information
oxisto committed Dec 18, 2024
1 parent 698937e commit c5c25f8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,13 @@ 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) {
(value is Number && value !is BigInteger) -> value
is Boolean -> value
null -> null
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

0 comments on commit c5c25f8

Please sign in to comment.