-
Notifications
You must be signed in to change notification settings - Fork 197
Microsecond bug in neo4j.time.DateTime.to_native() #525
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Did some more digging and it seems the problem is from float multiplication at this line neo4j-python-driver/neo4j/time/arithmetic.py Line 118 in a2e781a
Where A simple solution is accepting the floating point arithmetic error and just round to closest number before casting to int. |
Thanks for the investigation. I also had a look at it an will most likely take the second approach, storing integer nanoseconds instead of float sub-seconds. |
The fix will be available in 4.4 it required slightly altering the API so I can't publish it in a patch release. |
Converting a
neo4j.time.DateTime
to the built-indatetime.datetime
using yourto_native
method will sometimes give wrong microseconds. I suspect this is a rounding error related somehow to this line:neo4j-python-driver/neo4j/time/__init__.py
Line 1549 in f6b0254
Driver version: Python driver 4.2.1
Operating System: CentOS Linux 7
Steps to reproduce
Result:
Expected behavior
native_from_neo4j
should always be the same asnative_from_datetime
in my example.Actual behavior
native_from_neo4j
is sometimes off by 1 microsecond compared tonative_from_datetime
The text was updated successfully, but these errors were encountered: