Skip to content
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

Merged
merged 1 commit into from
Sep 26, 2017

Conversation

marschall
Copy link
Contributor

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

  • 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

@codecov-io
Copy link

codecov-io commented Sep 3, 2017

Codecov Report

Merging #932 into master will increase coverage by 0.02%.
The diff coverage is 27.5%.

@@             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

@@ -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),
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -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),
Copy link
Member

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);
), and it is 0-based (see https://docs.oracle.com/javase/7/docs/api/java/text/MessageFormat.html )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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
@vlsi vlsi added this to the 42.1.5 milestone Sep 26, 2017
@vlsi vlsi merged commit fcb28c7 into pgjdbc:master Sep 26, 2017
@vlsi vlsi modified the milestones: 42.1.5, 42.2.0 Jan 8, 2018
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.

None yet

3 participants