activegraph icon indicating copy to clipboard operation
activegraph copied to clipboard

Support neo4j temporal types

Open drpump opened this issue 5 years ago • 5 comments

Neo4j 3.4 introduced temporal types, including datetime and local_datetime. The neo4j gem does not yet support these: it converts Ruby Date, Time, DateTime types into an integer, and duration types are not utilised. Please add support for these temporal types.

drpump avatar Mar 10 '19 12:03 drpump

I should be able to spare some time to work on this, but don't know enough about the neo4j API or the ruby gems to drive it.

drpump avatar Mar 10 '19 12:03 drpump

All those types will be supported in neo4j-ruby-driver. They already are in the jruby version. There is work remaining to make the neo4j gem fully leverage the driver. That will probably happen along with discontinuing support for any adaptor except the the (bolt) driver.

klobuczek avatar May 07 '19 17:05 klobuczek

Not sure if this helps or hurts, and I know this issue is old and is currently being worked on (via neo4j-ruby-driver w/ seabolt), but figured I'd chime in.

I wanted to use neo4j and neo4j-core (thanks so much for all the work!) but I really wanted to utilize the temporal types introduced in Neo4j 3.4, so I spent some time digging into the official java driver and got the current Bolt adaptor working with Date/DateTime/Time ruby classes.

neo4j-core: https://github.com/ashie1287/neo4j-core/commit/3c6332ecd4d52c99d72774c362611c8cabaf8f3c

neo4j: https://github.com/ashie1287/neo4j/commit/97a5cf1426c374f67492b4a249b8d2ad5acd239d

Unfortunately, there's no documentation for Bolt v2, v3, or v4, so that's why I went off the java driver implementation. I also discovered this developer site, but it's still lacking. https://neo4j-drivers.github.io

The implementation is minimal, pretty hacky, and definitely breaks support for existing projects (that use Integer for temporal types, or use Neo4j < 3.4), but it does work for my needs (tested with Neo4j 3.5.9 and 3.5.5, which is the version GrapheneDB is currently on). It also jumps from Bolt v1 to Bolt v3 (with neo4j 3.5.5, I couldn't successfully negotiate handshake for v2, sending v2 still put the connection on v1).

As with everyone, my time is limited, but I'm curious to hear if it's worth cleaning up the implementation and submitting a PR. I'd most likely need a lot of direction, and I think it'd be a lot of work, specifically:

  • Supporting all of Bolt v1, v2 and v3
  • Supporting projects using Neo4j < 3.4
  • Supporting projects still using Integer for temporal types

Either way, just wanted to share and try to give back a little. Thanks again for all the work!

hahashraf avatar Oct 21 '19 23:10 hahashraf

Ah, also just seeing https://github.com/neo4jrb/neo4j/pull/1575 , not sure if that invalidates anything above.

hahashraf avatar Oct 21 '19 23:10 hahashraf

@ashie1287 thanks for that. The temporal types are implemented here: https://github.com/neo4jrb/neo4j-ruby-driver/tree/master/lib/neo4j/driver/types and the conversion here https://github.com/neo4jrb/neo4j-ruby-driver/tree/master/ffi/neo4j/driver/internal/value.

The type mapping might be not ideal https://github.com/neo4jrb/neo4j-ruby-driver/blob/master/docs/dev_manual_examples.rb#L265-L287. I would very much appreciate any feedback.

klobuczek avatar Oct 24 '19 07:10 klobuczek