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

[FEATURE REQUEST] Support getting java.time objects from CallableStatement #1392

Closed
CasualSuperman opened this issue Jul 27, 2020 · 2 comments
Labels
Enhancement An enhancement to the driver. Lower priority than bugs.
Projects

Comments

@CasualSuperman
Copy link
Contributor

Is your feature request related to a problem? If so, please give a short summary of the problem and how the feature would resolve it

I use Java 8 time types throughout my code, and would like to avoid using legacy types. This works when using a ResultSet, since it has been updated to support LocalDateTime, etc. (#744), but CallableStatement lacks support for these types.

Describe the preferred solution

I would like to be able to call CallableStatement::getObject(1, LocalDateTime.class) and receive and object, rather than an exception.

Describe alternatives you've considered

I could get a java.sql.Timestamp and use .toLocalDateTime(), but this comes with a performance penalty (#1070), and introduces legacy types into my code.

Additional context

This would require more up-front work, but the code in SQLServerResultSet::getObject(int, Class) is almost identical to SQLServerCallableStatement::getObject(int, Class), and seems eligible for abstraction so that the same types are maintained between CallableStatements and ResultSets, and code duplication is removed. I recognize this difficult (I tried it briefly) since ResultSet and CallableStatement share many methods, but they are not specified by the same interface.

Reference Implementation

SQLServerResultSet

@CasualSuperman CasualSuperman added the Enhancement An enhancement to the driver. Lower priority than bugs. label Jul 27, 2020
@peterbae
Copy link
Contributor

Thanks for the suggestion. I think this change makes sense and the team will soon look into supporting this type with getObject in SQLServerCallableStatement, and also possibly remove code duplication.

CasualSuperman added a commit to CasualSuperman/mssql-jdbc that referenced this issue Jul 28, 2020
This PR adds support for the requested functionality in microsoft#1392, but does not address the mentioned code duplication.
The added library code was copied verbatim from SQLServerResultSet.
CasualSuperman added a commit to CasualSuperman/mssql-jdbc that referenced this issue Jul 28, 2020
This PR adds support for the requested functionality in microsoft#1392, but does not address the mentioned code duplication.
The added library code was copied verbatim from SQLServerResultSet.
CasualSuperman added a commit to CasualSuperman/mssql-jdbc that referenced this issue Jul 28, 2020
This PR adds support for the requested functionality in microsoft#1392, but does not address the mentioned code duplication.
The added library code was copied verbatim from SQLServerResultSet.
CasualSuperman added a commit to CasualSuperman/mssql-jdbc that referenced this issue Jul 28, 2020
This PR adds support for the requested functionality in microsoft#1392, but does not address the mentioned code duplication.
The added library code was copied verbatim from SQLServerResultSet.
@peterbae peterbae added this to In progress in MSSQL JDBC Aug 10, 2020
CasualSuperman added a commit to CasualSuperman/mssql-jdbc that referenced this issue Aug 13, 2020
This PR adds support for the requested functionality in microsoft#1392, but does not address the mentioned code duplication.
The added library code was copied verbatim from SQLServerResultSet.
@ulvii
Copy link
Contributor

ulvii commented Sep 1, 2020

#1393 merged.

@ulvii ulvii closed this as completed Sep 1, 2020
MSSQL JDBC automation moved this from In progress to Closed Issues Sep 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement An enhancement to the driver. Lower priority than bugs.
Projects
MSSQL JDBC
  
Closed Issues
Development

No branches or pull requests

3 participants