Skip to content

Commit

Permalink
Persisting literal values more conservativly (#1907)
Browse files Browse the repository at this point in the history
* Persisting literal values more conservativly

Fixes issues with python interface files

* Avoid toString() call for strings
  • Loading branch information
oxisto authored Dec 18, 2024
1 parent 698937e commit e39f15d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
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

0 comments on commit e39f15d

Please sign in to comment.