neo4jrb / activegraph

An active model wrapper for the Neo4j Graph Database for Ruby.
http://neo4jrb.io
MIT License
1.4k stars 276 forks source link

Support neo4j temporal types #1539

Open drpump opened 5 years ago

drpump commented 5 years ago

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 commented 5 years ago

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.

klobuczek commented 5 years ago

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.

hahashraf commented 4 years ago

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:

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

hahashraf commented 4 years ago

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

klobuczek commented 4 years ago

@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.