Skip to content

Do not convert from LocalDateTime to Timestamp by default. #985

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

Closed

Conversation

schauder
Copy link
Contributor

@schauder schauder commented Jun 7, 2021

Most supported databases don't need that conversion.

Db2 does need it and gets it through JdbcDb2Dialect.

As part of the effort it became obvious that the filtering for conversions between Date and JSR310 data types was broken.
It is fixed now, which required a dedicated reading conversion from LocalDateTime to Date for JdbcMySqlDialect.

Closes #974

Please review the part about filtering conversions especially carefully. After looking at the git history for some time I was rather confused.

schauder added 2 commits June 2, 2021 14:07
Most supported databases don't need that conversion.

Db2 does need it and gets it through JdbcDb2Dialect.

As part of the effort it became obvious that the filtering for conversions between Date and JSR310 data types was broken.
It is fixed now, which required a dedicated reading conversion from LocalDateTime to Date for JdbcMySqlDialect.

Closes #974
@schauder schauder requested a review from mp911de June 7, 2021 13:54
private static final StoreConversions STORE_CONVERSIONS = StoreConversions.of(JdbcSimpleTypes.HOLDER,
STORE_CONVERTERS);

private static final Predicate<ConvertiblePair> excludeConversionsBetweenDateAndJsr310Types= cp -> !isDateTimeApiConversion(cp);
Copy link
Member

Choose a reason for hiding this comment

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

Could we rewrite this into a method-reference form?

*
* @since 2.3
*/
public JdbcCustomConversions(StoreConversions storeConversions, List<?> userConverters) {
super(new ConverterConfiguration(storeConversions, userConverters, JdbcCustomConversions::isDateTimeApiConversion));
super(new ConverterConfiguration(storeConversions, userConverters, cp -> !isDateTimeApiConversion(cp)));
Copy link
Member

Choose a reason for hiding this comment

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

should this reuse excludeConversionsBetweenDateAndJsr310Types?

JdbcCustomConversions customConversions = new JdbcCustomConversions(
(List<?>) new JdbcMySqlDialect().getConverters());

SoftAssertions.assertSoftly(softly -> {
Copy link
Member

Choose a reason for hiding this comment

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

Let's stick to static imports for AssertJ.

Use static import for `SoftAssertions.assertSoftly` everywhere.
Polishing of the conversion filter.

See #974
mp911de pushed a commit that referenced this pull request Jun 10, 2021
Most supported databases don't need that conversion.

Db2 does need it and gets it through JdbcDb2Dialect.

As part of the effort it became obvious that the filtering for conversions between Date and JSR310 data types was broken.
It is fixed now, which required a dedicated reading conversion from LocalDateTime to Date for JdbcMySqlDialect.

Closes #974
Original pull request: #985.
@mp911de mp911de added the type: enhancement A general enhancement label Jun 10, 2021
@mp911de
Copy link
Member

mp911de commented Jun 10, 2021

That's merged now.

@mp911de mp911de closed this Jun 10, 2021
@mp911de mp911de deleted the issue/974-no-conversion-to-timestamp-for-postgres branch June 10, 2021 12:28
@mp911de mp911de added this to the 2.3 M1 (2021.1.0) milestone Jun 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
2 participants