arangodb-java-driver
arangodb-java-driver copied to clipboard
Control over null values conversion during query execution
Hello, can you explain please, why do not we have a control over a null values conversion, when exection queries with java driver? https://github.com/arangodb/arangodb-java-driver/blob/67a54095469e1a095fd7204bc1c6c4605437e736/src/main/java/com/arangodb/internal/InternalArangoDatabase.java#L177 This is hardcoded behaviour
:+1: I've got a similar issue but with deserialization.
val str = db.query("RETURN null", classOf[String]).next()
assert(str == null) // FAILS - actual result is a string "null"
That is counter intuitive and took me several hours to find a workaround like this:
val str = Option(db.query("RETURN null", classOf[Object]).next()
assert(str == null) // OK - now it returns null as expected, just needs to be casted to String
Hi @wajda ,
this happens because deserializing to String
is intended as deserializing to json string, except if the VPack being deserialized is a VPack String. This seems to me a bug, since also the case of VPack null value should be excluded.
This should be fixed by https://github.com/arangodb/arangodb-java-driver/pull/411
Thank you Michele for the quick turnaround!
Fixed in https://github.com/arangodb/arangodb-java-driver/releases/tag/v7.0.0-ALPHA.1
Since vertion 7.0.0, keepNull behavior can be specified using Jackson API by:
- adding annotations on related fields, or
- registering custom serializers
see https://github.com/arangodb/arangodb-java-driver/blob/v7/docs/v7_java-reference-serialization.md.
Furthermore, to read and write raw JSON strings a new wrapper class RawJson
has been introduced, see https://github.com/arangodb/arangodb-java-driver/blob/v7/docs/v7_detailed_changes.md#user-data
https://github.com/arangodb/arangodb-java-driver/releases/tag/v7.0.0-RC.4
Closing as fixed in version 7.0.0.
keepNull
behavior can be specified using Jackson API by:
- adding annotations on related fields, or
- registering custom serializers
see https://github.com/arangodb/docs/blob/113c2351a0153171adfc74c313454af6bb5c7f08/drivers/java-reference-serialization.md.
Furthermore, to read and write raw JSON strings a new wrapper class com.arangodb.util.RawJson
has been introduced, see https://github.com/arangodb/docs/blob/113c2351a0153171adfc74c313454af6bb5c7f08/drivers/java-changes-v7.md#user-data