Skip to content

Switch to JSR 310 Date and Time API #233

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 3 commits into from
Sep 1, 2021
Merged

Conversation

dragneelfps
Copy link
Contributor

@dragneelfps dragneelfps commented May 28, 2021

  • Removes joda from encoding/decoding

  • common

  • mysql

  • postgres

continuation of #229

@dragneelfps
Copy link
Contributor Author

Getting following in CI build.. :/

docker: Error response from daemon: toomanyrequests: You have reached your pull rate limit. You may increase the limit by authenticating and upgrading: https://www.docker.com/increase-rate-limit.

@oshai
Copy link
Contributor

oshai commented May 30, 2021

Hi, thanks for the PR!
There was some interest for it in the past. For reference see #131 and #157.
Ideally, if we could have both implementation as a non-breaking change it would be preferred.
But I understand this might complicate things a lot.
Since this is a breaking change we will need to bump the major version when merged.

@dragneelfps
Copy link
Contributor Author

dragneelfps commented May 30, 2021

I could try to have Joda Time supported as well. But the thing is, do we really want to continue supporting it?
I prefer the major version upgrade. But seems odd going from 1.1.7 to 2.0.0.
Suggestions on how to move forward with this please?

@oshai
Copy link
Contributor

oshai commented Jun 1, 2021

Bump version to 2.0.0 sounds reasonable to me.
Please rebase changes from master again, build should work now in CI.

@dragneelfps dragneelfps force-pushed the master branch 2 times, most recently from a6c447a to 6ea3c8f Compare June 2, 2021 03:11
@oshai
Copy link
Contributor

oshai commented Jun 2, 2021

Note that some tests are still failing on CI.

@dragneelfps
Copy link
Contributor Author

dragneelfps commented Jun 5, 2021

I fixed most. Just having issues understanding logic behind

assertThat(dateTime.millis).isGreaterThan(915779106000L)

can you help, @oshai ?

@oshai
Copy link
Contributor

oshai commented Jun 5, 2021

I fixed most. Just having issues understanding logic behind

assertThat(dateTime.millis).isGreaterThan(915779106000L)

can you help, @oshai ?

I didn't wrote it originally, but from reading the code I think it checks the following:

  • set timestamp that includes mills/micros
  • check that the timestamp millis conversion is greater than the second before and smaller from the second after

There might be a problem either with the timezone or the millis if I have to guess.

@dragneelfps
Copy link
Contributor Author

I noticed something, postgres is returning timestamps in UTC string, even when I insert it with non UTC offset.
The tests are expecting non UTC offset. So I changed a bit and is actually testing if the two timestamps are equal as OffsetDateTime
Is this correct approach?
I am guessing postgres returning UTC string is related to server settings (which I am not really changing). Is this correct assumption?

@codecov
Copy link

codecov bot commented Jun 5, 2021

Codecov Report

Merging #233 (c8313ef) into master (a5a881f) will increase coverage by 0.14%.
The diff coverage is 64.28%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #233      +/-   ##
============================================
+ Coverage     80.03%   80.17%   +0.14%     
- Complexity     1074     1079       +5     
============================================
  Files           265      266       +1     
  Lines          3916     3919       +3     
  Branches        522      523       +1     
============================================
+ Hits           3134     3142       +8     
+ Misses          534      531       -3     
+ Partials        248      246       -2     
Impacted Files Coverage Δ
.../src/main/java/com/github/jasync/sql/db/RowData.kt 84.00% <ø> (ø)
.../com/github/jasync/sql/db/column/SQLTimeEncoder.kt 66.66% <0.00%> (ø)
.../jasync/sql/db/mysql/binary/decoder/DateDecoder.kt 100.00% <ø> (ø)
...ync/sql/db/mysql/binary/encoder/CalendarEncoder.kt 0.00% <0.00%> (ø)
...ync/sql/db/mysql/binary/encoder/DateTimeEncoder.kt 25.00% <0.00%> (ø)
...ync/sql/db/mysql/binary/encoder/JavaDateEncoder.kt 25.00% <0.00%> (ø)
...nc/sql/db/mysql/binary/encoder/LocalTimeEncoder.kt 0.00% <0.00%> (ø)
.../db/mysql/binary/encoder/ReadableInstantEncoder.kt 0.00% <0.00%> (ø)
...sync/sql/db/mysql/binary/encoder/SQLDateEncoder.kt 25.00% <0.00%> (ø)
...sync/sql/db/mysql/binary/encoder/SQLTimeEncoder.kt 25.00% <0.00%> (+5.00%) ⬆️
... and 17 more

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 a5a881f...c8313ef. Read the comment docs.

- Removes joda from encoding/decoding
- Using Threeten for PeriodDuration
@oshai
Copy link
Contributor

oshai commented Jun 5, 2021

I noticed something, postgres is returning timestamps in UTC string, even when I insert it with non UTC offset.
The tests are expecting non UTC offset. So I changed a bit and is actually testing if the two timestamps are equal as OffsetDateTime
Is this correct approach?
I am guessing postgres returning UTC string is related to server settings (which I am not really changing). Is this correct assumption?

According to https://www.postgresql.org/docs/9.1/datatype-datetime.html 8.5.2. Date/Time Output:

The default is the ISO format
and it looks like:

ISO | ISO 8601/SQL standard | 1997-12-17 07:37:16-08

(without time zone)

Conversion on test makes sense (to see it's the same date as inserted). It's just not clear how this was changed from pervious impl.

I still need to review all changes, but it will take some time.

Copy link
Contributor

@oshai oshai left a comment

Choose a reason for hiding this comment

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

Thanks again for the PR.
I left some comments in code and have some more general things:

  • I saw that in some cases there is no test coverage: do you think it's an issue with the framework, or can you please add tests to cover those cases?
  • I saw in many places move from millis to nano. Is it because java 8 uses nano and joda/db use millis?

About the migration to 2.x: I am thinking if we can add a suggestion to users how to do that more easily? Do you have any suggestion?

@@ -66,8 +66,8 @@ open class ConnectionHelper : ContainerHelper() {
"""CREATE TEMPORARY TABLE posts (
id INT NOT NULL AUTO_INCREMENT,
created_at_date DATE not null,
created_at_datetime DATETIME not null,
created_at_timestamp TIMESTAMP not null,
created_at_datetime DATETIME(6) not null,
Copy link
Contributor

Choose a reason for hiding this comment

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

why was it changed?

@dragneelfps
Copy link
Contributor Author

I saw that in some cases there is no test coverage: do you think it's an issue with the framework, or can you please add tests to cover those cases?

Can you point me to which cases are you talking about specifically?

I saw in many places move from millis to nano. Is it because java 8 uses nano and joda/db use millis?

Yes. Java uses nano, joda uses millis, db micro(at least in mysql)

@oshai
Copy link
Contributor

oshai commented Jun 13, 2021

Can you point me to which cases are you talking about specifically?

Look at LocalDateTimeEncoderDecoder:17 and see more examples in 'files changed' with the warning: Added line #Lxx was not covered by tests

@oshai
Copy link
Contributor

oshai commented Jun 24, 2021

@dragneelfps before merging there was still one answered question in the review about DATETIME(6).

In addition, will you have some time to improve test coverage?

@github-actions
Copy link

Stale pull request message

@oshai
Copy link
Contributor

oshai commented Aug 24, 2021

I will merge this PR soon. Will create 1.x branch before that.

@oshai
Copy link
Contributor

oshai commented Aug 30, 2021

Thanks for the PR!
I merged it and will release a new version and update docs soon.

@oshai oshai merged commit 46ab065 into jasync-sql:master Sep 1, 2021
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.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy