-
Notifications
You must be signed in to change notification settings - Fork 826
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
feat: improve ResultSet#getObject(int, Class) #932
Conversation
0ad8ac6
to
bd53fed
Compare
Codecov Report
@@ Coverage Diff @@
## master #932 +/- ##
===========================================
+ Coverage 65.88% 65.9% +0.02%
- Complexity 3556 3560 +4
===========================================
Files 166 166
Lines 15223 15238 +15
Branches 2458 2464 +6
===========================================
+ Hits 10030 10043 +13
+ Misses 4024 4023 -1
- Partials 1169 1172 +3 |
bd53fed
to
7c73c07
Compare
@@ -3166,13 +3166,15 @@ public void updateArray(String columnName, Array x) throws SQLException { | |||
if (sqlType == Types.NUMERIC || sqlType == Types.DECIMAL) { | |||
return type.cast(getBigDecimal(columnIndex)); | |||
} else { | |||
throw new SQLException("conversion to " + type + " from " + sqlType + " not supported"); | |||
throw new PSQLException(GT.tr("Unsupported type conversion to {1}.", type), |
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.
@marschall , would you please keep " from " + sqlType
in the error message?
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.
done
7c73c07
to
7b3b0e2
Compare
@@ -3166,13 +3166,15 @@ public void updateArray(String columnName, Array x) throws SQLException { | |||
if (sqlType == Types.NUMERIC || sqlType == Types.DECIMAL) { | |||
return type.cast(getBigDecimal(columnIndex)); | |||
} else { | |||
throw new SQLException("conversion to " + type + " from " + sqlType + " not supported"); | |||
throw new PSQLException(GT.tr("conversion to {1} from {2} not supported", type, sqlType), |
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.
Are you sure placeholders are 1-based?
We use MessageFormat (
message = MessageFormat.format(message, args); |
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 must have copy and pasted from the wrong place, eg. https://github.com/pgjdbc/pgjdbc/blob/master/pgjdbc/src/main/java/org/postgresql/jdbc/TimestampUtils.java#L349
Fixed
In the review of pgjdbc#813 various issues with the initial implementation of CallableStatement#getObject(int, Class) showed up that ResultSet#getObject(int, Class) also has. This commit gives both methods the same behavior. This commit contains the following changes - make errors localizable - add support for SMALLINT <-> Short - add support for BIGINT <-> BigInteger - add support for TIMESTAMP <-> java.util.Date - swap INTEGER and SMALLINT position
7b3b0e2
to
381aa85
Compare
In the review of #813 various issues with the initial implementation of
CallableStatement#getObject(int, Class) showed up that
ResultSet#getObject(int, Class) also has. This commit gives both
methods the same behavior.
This commit contains the following changes