Skip to content

Handle nanosecond normalization in IsoDuration #497

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

Merged
merged 2 commits into from
May 7, 2018

Conversation

lutovich
Copy link
Contributor

@lutovich lutovich commented May 7, 2018

No description provided.

Previously, test code that generated random durations could create a
duration with negative amount of nanoseconds. Such duration is now
normalized by the database so that nanoseconds value is always in
range from 0 to 999_999_999.

This commit makes tests only create random durations with nanoseconds
in that range. Otherwise some test assertions fail because they expect
non-normalized value to be returned back.
@lutovich lutovich requested a review from zhenlineo May 7, 2018 13:04
@lutovich lutovich changed the base branch from 1.7 to 1.6 May 7, 2018 13:04
@lutovich lutovich force-pushed the 1.6-ns-normalization branch from defe4b5 to 1bda475 Compare May 7, 2018 13:10
@lutovich lutovich requested a review from sherfert May 7, 2018 13:13
Database normalizes nanoseconds to be in range from 0 to 999_999_999.
`IsoDuration` previously did no calculations in it's `#toString()`
and returned incorrect result.

This commit makes it return correct string representation despite
normalized second and nanosecond components. It will also do
normalization in the constructor using
`java.time.Duration#ofSeconds(long, long)` in order to return correct
strings for durations created on the client side and not returned
from the database.
@lutovich lutovich force-pushed the 1.6-ns-normalization branch from 1bda475 to edc09ce Compare May 7, 2018 14:23
Copy link

@sherfert sherfert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I can see in the tests, it looks fine to me. I can not see any obvious flaws in the implementation. The implementation is different from the one in the server, what is the reason?

@lutovich
Copy link
Contributor Author

lutovich commented May 7, 2018

@sherfert server also does other conversions like 12 months -> year, etc. We do not want this it drivers for now. So this is a minimal fix for seconds & nanoseconds handling.

@zhenlineo zhenlineo merged commit 1cf40b7 into neo4j:1.6 May 7, 2018
@lutovich lutovich deleted the 1.6-ns-normalization branch May 7, 2018 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants