-
Notifications
You must be signed in to change notification settings - Fork 437
correct processing of OffsetDateTime in SQLServerDataTable #2651
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
Conversation
@@ -275,8 +276,12 @@ private void internalAddrow(JDBCType jdbcType, Object val, Object[] rowValues, | |||
|
|||
// java.sql.Date, java.sql.Time and java.sql.Timestamp are subclass of java.util.Date | |||
if (val instanceof java.util.Date || val instanceof microsoft.sql.DateTimeOffset | |||
|| val instanceof OffsetDateTime || val instanceof OffsetTime) | |||
|| val instanceof OffsetTime) | |||
rowValues[key] = val.toString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a unit test for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was trying to ammend an existing unit test with OffsetDateTime and SQLServerDataTable, but I was not able to find any. Could you please point me?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you consider adding one in SQLServerDataTableTest.java ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing, I will add a column of type TIMESTAMP_WITH_TIMEZONE there and fill it with OffsetDateTime - that's exactly what I do in my application where I have found this bug (and have solved it with this change to the JDBC driver).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@machavan is the unit test now OK, or is anything else needed before merge?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@LeosBitto it looks fine. We will run our ADO tests on this PR and then move ahead for merging it.
…ZONE and a OffsetDateTime value
@microsoft-github-policy-service agree |
@LeosBitto, You can close this PR. |
Closing the PR. |
When OffsetDateTime contains zero seconds, calling toString() produces the following format: 2025-04-26T19:42+02:00 (without seconds) which is rejected by the server with the message "Conversion failed when converting date and/or time from character string." (SQL Error: 241, SQLState: S0001)