FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: Timestamp.of(java.sql.Timestamp) pre-epoch on exact second by olavloite · Pull Request #179 · googleapis/java-core · GitHub

This repository was archived by the owner on Dec 3, 2023. It is now read-only.
/ java-core Public archive

fix: Timestamp.of(java.sql.Timestamp) pre-epoch on exact second - #179

Merged
chingor13 merged 4 commits into
masterfrom
fix-sql-timestamp-on-exact-second-pre-epoch
Mar 12, 2020
Merged

fix: Timestamp.of(java.sql.Timestamp) pre-epoch on exact second#179
chingor13 merged 4 commits into
masterfrom
fix-sql-timestamp-on-exact-second-pre-epoch

Conversation

Copy link
Copy Markdown
Contributor

The fix for negative timestamps in #160 did not take into account the possibility that the pre-epoch timestamp could be on an exact second value. In that case, the additional correction of the calculated second value should not be applied.

Fixes googleapis/java-spanner-jdbc#85

googlebot added the cla: yes This human has signed the Contributor License Agreement. label Mar 12, 2020

codecov Bot commented Mar 12, 2020
edited
Loading

Copy link
Copy Markdown

Codecov Report

Merging #179 into master will not change coverage.
The diff coverage is 100%.

@@            Coverage Diff            @@
##             master     #179   +/-   ##
=========================================
  Coverage     67.76%   67.76%           
- Complexity      378      379    +1     
=========================================
  Files            36       36           
  Lines          1967     1967           
  Branches        259      259           
=========================================
  Hits           1333     1333           
  Misses          526      526           
  Partials        108      108
Impacted Files Coverage Δ Complexity Δ
...core/src/main/java/com/google/cloud/Timestamp.java 90.62% <100%> (ø) 26 <0> (+1) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ae35d0e...b9e2161. Read the comment docs.

}

@Test
public void ofSqlTimestampOnExactSecond() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Can you make this method name more conventional? e.g. testOf_exactSecond or some such.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Done. Although this means that the name of this test is not in line with the other test cases in this file, such as for example ofSqlTimestampPreEpoch.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Section 8.5.2 of the Google style guide addresses this:

When adding new code to a file that is not in Google Style, reformatting the existing code first is recommended, subject to the advice in Section 8.5.1, Reformatting existing code.

If this reformatting is not done, new code is still required to be added in Google Style, even if this creates inconsistencies.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I've updated all the test cases for Timestamp.of(java.sql.Timestamp) to use consistent naming and assertEquals instead of assertThat....

olavloite requested a review from elharo March 12, 2020 12:37
// works. For example, -1001 / 1000 == -1. In this case of timestamps, we want this result to be
// -2. This causes any pre-epoch timestamp to be off by 1 second - fix this by adjusting the
// seconds value by 1 if the timestamp < 0.
// seconds value by 1 if the timestamp < 0 and the division by 1000 has a remainder.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

to be technical, a non-zero remainder. Suggest rephrasing as "the timestamp is less than zero and is not divisible by 1000."

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Changed to fix this by subtracting 1 from the seconds value if the seconds value is less than zero and is not divisible by 1000.

olavloite requested a review from elharo March 12, 2020 16:59

codyoss left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Good catch

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

spanner-jdbc: JdbcTypeConverterTest failure

5 participants


Back | FazBrowse Home | New Git URL