Skip to content

JSON datatype support #2558

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

Open
wants to merge 54 commits into
base: main
Choose a base branch
from
Open

JSON datatype support #2558

wants to merge 54 commits into from

Conversation

divang
Copy link
Contributor

@divang divang commented Dec 6, 2024

To add support for the new JSON datatype, the following changes have been made to the codebase:

  • Extended TDS feature support
  • Added JDBC JSON data type support in DataTypes
  • Implemented JSON strategy in DTV
  • Included JSON character encoding and constants
  • Handled JSON datatype support in ResultSet, TVP, and IOBuffer
  • Supported JSON as IN/OUT parameters in SQL prepared and callable statements
  • Managed JSON datatype in SQLServerBulkCopy and related bulk copy scenarios

Copy link

codecov bot commented Dec 6, 2024

Codecov Report

Attention: Patch coverage is 82.22222% with 8 lines in your changes missing coverage. Please review.

Project coverage is 50.09%. Comparing base (5bb3353) to head (508a1b9).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
.../microsoft/sqlserver/jdbc/SQLServerConnection.java 75.00% 3 Missing and 2 partials ⚠️
...oft/sqlserver/jdbc/SQLServerParameterMetaData.java 0.00% 1 Missing and 1 partial ⚠️
...in/java/com/microsoft/sqlserver/jdbc/IOBuffer.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #2558      +/-   ##
============================================
- Coverage     51.01%   50.09%   -0.93%     
+ Complexity     3921     3829      -92     
============================================
  Files           147      147              
  Lines         33483    33544      +61     
  Branches       5609     5619      +10     
============================================
- Hits          17081    16803     -278     
- Misses        13991    14347     +356     
+ Partials       2411     2394      -17     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@divang divang marked this pull request as draft December 10, 2024 20:23
@lilgreenbird
Copy link
Contributor

/azp run public-mssql-jdbc.windows

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link

No pipelines are associated with this pull request.

@lilgreenbird
Copy link
Contributor

/azp run public-mssql-jdbc.linux

@lilgreenbird
Copy link
Contributor

/azp run CI-MacOS

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

1 similar comment
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 11 out of 26 changed files in this pull request and generated no comments.

Files not reviewed (15)
  • src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResource.java: Evaluated as low risk
  • src/main/java/com/microsoft/sqlserver/jdbc/Parameter.java: Evaluated as low risk
  • src/test/java/com/microsoft/sqlserver/jdbc/bulkCopy/BulkCopyCSVTest.java: Evaluated as low risk
  • src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataTable.java: Evaluated as low risk
  • src/main/java/com/microsoft/sqlserver/jdbc/Column.java: Evaluated as low risk
  • src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java: Evaluated as low risk
  • src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java: Evaluated as low risk
  • src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSetMetaData.java: Evaluated as low risk
  • src/main/java/com/microsoft/sqlserver/jdbc/DataTypes.java: Evaluated as low risk
  • src/test/java/com/microsoft/sqlserver/jdbc/bulkCopy/SqlTypeMapping.java: Evaluated as low risk
  • src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java: Evaluated as low risk
  • src/main/java/microsoft/sql/Types.java: Evaluated as low risk
  • src/main/java/com/microsoft/sqlserver/jdbc/dtv.java: Evaluated as low risk
  • src/test/java/com/microsoft/sqlserver/jdbc/callablestatement/CallableStatementTest.java: Evaluated as low risk
  • src/test/java/com/microsoft/sqlserver/jdbc/tvp/TVPTypesTest.java: Evaluated as low risk

@@ -29,6 +29,7 @@ private Constants() {}
* reqExternalSetup - For tests requiring external setup
* clientCertAuth - - For tests requiring client certificate authentication setup
* Fedauth - - - - - - For Fedauth tests
* JSONTest - - - - - For tests requiring JSON setup
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need to add a separate tag for this? this should always run along with the other datatype tests

Copy link
Collaborator

Choose a reason for hiding this comment

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

@lilgreenbird We would need to exclude these tests against test endpoints that don't support JSON. (I'm kind of surprised we don't have one for Data Classification, for example. But it looks like we've used SQL Server version for that, which isn't quite proper.)

Copy link
Contributor

Choose a reason for hiding this comment

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

we need a new tag for new SQL Server version that supports JSON. (SQL Server 2023 or ?)

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, why not? data classification was in 2019 only

@@ -158,8 +158,7 @@ public static void setup() throws Exception {
// no config file used
}

connectionString = getConfiguredPropertyOrEnv(Constants.MSSQL_JDBC_TEST_CONNECTION_PROPERTIES);

connectionString = getConfiguredPropertyOrEnv(Constants.MSSQL_JDBC_TEST_CONNECTION_PROPERTIES);
Copy link
Contributor

Choose a reason for hiding this comment

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

why remove the blank line?

Copy link
Contributor

@lilgreenbird lilgreenbird left a comment

Choose a reason for hiding this comment

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

the tests need to take into consideration the SQL server version. JSON support is only avail on SQL 2023 (or ?) so this means we need to exclude this for xSQLv16 and below. Need new tag for this new SQL Server version

@github-project-automation github-project-automation bot moved this from Under Peer Review to In progress in MSSQL JDBC Mar 27, 2025
@@ -1459,6 +1461,7 @@ final void executeOp(DTVExecuteOp op) throws SQLServerException {
case NVARCHAR:
case LONGNVARCHAR:
case NCLOB:
case JSON:
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we're missing a case in the else (line #1599). This makes me think we're also missing a test case that will go to that path. Check SQL_VARIANT to see where this is tested.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we also need a case for JSON in readSqlVariant, and, a test for that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In progress
Development

Successfully merging this pull request may close these issues.

8 participants