-
Notifications
You must be signed in to change notification settings - Fork 24
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
Aligning serverZoneId
Behavior with connectionTimeZone
(mysql-connector-j)
#190
Comments
WDYT? @mirromutth |
Hello @mirromutth, I would appreciate your input on this proposed change. Could you please share your thoughts? May I kindly join the discussion below, if you don't mind?). micronaut-projects/micronaut-data#2388 (comment). (additional ref: #166) |
Currently, the default behavior should be same as If user set the As I said in #166 , JDBC driver // JVM is not in UTC
Class.forName("com.mysql.cj.jdbc.Driver");
String url = "jdbc:mysql://localhost:3306/r2dbc?connectionTimeZone=UTC";
String user = "root";
String password = "******";
try (Connection conn = DriverManager.getConnection(url, user, password);
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT CURRENT_TIMESTAMP(6) AS n")) {
int count = 0;
while (rs.next()) {
assertThat(rs.getObject(1)).isInstanceOf(LocalDateTime.class)
.asInstanceOf(new InstanceOfAssertFactory<>(LocalDateTime.class, Assertions::assertThat))
.isCloseToUtcNow(new TemporalUnitLessThanOffset(200, ChronoUnit.MILLIS));
++count;
}
assertThat(count).isOne();
} This shows whatever the user sets If the user wants to use time zone conversion, they need to use The Maybe we should:
Or we can create an alias Additionally, when the driver sends a date time, it will judge whether to convert through the Simply put:
|
Issue
The current behavior in r2dbc-mysql when the
serverZoneId
property is not explicitly set is to use the server's timezone. However, this differs from the behavior of theconnectionTimeZone
(previouslyserverTimeZone
) property in mysql-connector-j, causing inconsistency for users familiar with MySQL's JDBC driver.Proposal
I propose aligning the behavior of
serverZoneId
in r2dbc-mysql with the equivalent property inmysql-connector-j
, 'sconnectionTimeZone
. Specifically, whenserverZoneId
is not set, it should default to using the JVM's default timezone, similar to the behavior ofconnectionTimeZone
.Rationale
Consistency across different MySQL drivers is crucial for users who may work with multiple technologies or migrate between them. Aligning r2dbc-mysql with the behavior of mysql-connector-j would reduce surprises for users and make it easier for them to switch between these drivers without encountering unexpected timezone-related issues. (e.g., micronaut-projects/micronaut-data#2388)
Refs
The text was updated successfully, but these errors were encountered: