Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
6cbdcc8
JSON feature extension
lilgreenbird Nov 28, 2024
e9aff9f
Added JSON data type support in DataTypes
Dec 4, 2024
bd40818
JSON startegy in DTV
Dec 10, 2024
53d5a3c
Fix Json character encoding and JSON constants.
Dec 18, 2024
db34b09
Added JSON datatype test case
Dec 18, 2024
01e292e
Added JSON datatype test cases in ResultSet, TVP and Regression scena…
Dec 18, 2024
6fb71f8
Added JSON datatype support
Dec 19, 2024
84c412e
Added JSON support in IOBuffer.java
Dec 19, 2024
35ec418
Json datatype support: SQLServerCallableStatement
Ananya2 Jan 3, 2025
931a12e
Updated callableStatementTest.java
Ananya2 Jan 3, 2025
46851ea
Fixed JSON op.execute method mapping
Jan 22, 2025
abf379d
Added test cases for the TVP type in Callable Statements.
Ananya2 Jan 10, 2025
9cde9fa
Fixed Store procedure output param TDS metadata and fixed bulk copy t…
Jan 29, 2025
c336b12
Fixed BulkCopy JSON datatype issue.
Feb 11, 2025
de859f1
Removed duplicate code and used existing method to solve Bulk opy iss…
Feb 11, 2025
3e1b80f
Added test cases for Bulk copy
Feb 11, 2025
11be809
Enhanced JSON datatype regression test
Feb 12, 2025
dbc84c1
Added JSON metadata test case
Feb 12, 2025
ecad3dc
Hanlded review comment: removed JSON type in Textual category and pre…
Feb 17, 2025
2997ec9
Added JSON support for BulkCopyCSV, included test cases to validate i…
Ananya2 Feb 14, 2025
fbf598d
Added test for Bulk Copy
muskan124947 Feb 17, 2025
f378362
Add test for datatype conversions
muskan124947 Feb 17, 2025
cf52cf6
Validated nested JSON for bulkCopyCSV()
Ananya2 Feb 17, 2025
5b465bb
Removed local formatting done by default
muskan124947 Feb 17, 2025
d62610c
Fixed JSON displaySize and precision value in TypeInfo
Feb 18, 2025
e3c43cd
Enhance parseString() to support nested JSON and multiple key-value p…
Ananya2 Feb 18, 2025
caf6335
Fixed JSON datatype setObject issue
Feb 20, 2025
e461fbb
Updated regression test case for JSON datatype: mix of addBatch, exec…
Feb 20, 2025
21b4682
Updated as per the review comment to validate the getString() result …
Ananya2 Feb 20, 2025
7fa11b9
Updated and added more test scenarios for Bulk Copy
muskan124947 Feb 20, 2025
7a3dfd0
Added JSONFunctionTest to test JSON functions
muskan124947 Feb 20, 2025
cd8cf00
Optimized string parsing to avoid unnecessary allocations.
Ananya2 Feb 21, 2025
da0661b
formatted as per the older version
Ananya2 Feb 21, 2025
75b5860
Improve CSV parsing by correctly detecting JSON fields with double qu…
Ananya2 Feb 24, 2025
f515230
Remove reference to non-existent test file BulkCopyCSVTestInputNoColu…
Ananya2 Feb 24, 2025
058ac25
Updated JSONFunction Test class
muskan124947 Feb 24, 2025
60db92f
Adding tag JSONTest for some test cases
muskan124947 Feb 25, 2025
9b64c90
Added and validated test cases for JSON support in JOIN queries, glob…
Ananya2 Feb 26, 2025
93f54a1
Added test case to validate UDF returning JSON output; included metad…
Ananya2 Feb 26, 2025
3f1d913
Added tests for OPENJSON()
muskan124947 Feb 27, 2025
1997e48
Added tests for OPENJSON() function
muskan124947 Feb 27, 2025
d38358a
Added tests to handle large JSON file upto 2GB
muskan124947 Feb 27, 2025
f48c7bb
Add test cases to perform operations using Prepared Statement and use…
muskan124947 Feb 27, 2025
436e204
Updated test to insert large json data and verify no packet loss is t…
muskan124947 Mar 3, 2025
49798ef
Added JSONTest tag to all the test cases
muskan124947 Mar 7, 2025
0c55295
removed duplicate
Ananya2 Jul 1, 2025
808976d
Added JSONTest exclusion tag for test using JSON
Ananya2 Jul 1, 2025
d114551
added relevant comments
Ananya2 Jul 1, 2025
409cf3a
added JSONTest exclusion tag
Ananya2 Jul 1, 2025
9d20962
fixed pipeline failure
Ananya2 Jul 1, 2025
e408713
fixed failing JSON test cases
Ananya2 Jul 1, 2025
29b393a
Updated writeRPCJson and checkValidColumns methods.
Ananya2 Jul 3, 2025
449cefd
updated build.gradle file to add JSONTest exclusion tag
Ananya2 Jul 3, 2025
d2ccc2d
Refactor: conversion only required for temporal data types
Ananya2 Jul 3, 2025
9aa455d
Fixed registerOutParameter for json support and updated the writeRPCJ…
Ananya2 Jul 7, 2025
7b23fc8
added assertion and removed print statement
Ananya2 Jul 7, 2025
e358253
updated as per review comments.
Ananya2 Jul 10, 2025
f7a3e0b
Addressed review comments: randomized table/procedure names, and remo…
Ananya2 Jul 11, 2025
01c33e6
Resolved the formatting issue directly through the GitHub UI, as it w…
Ananya2 Jul 11, 2025
c10345f
Addressed PR review comments.
Ananya2 Jul 17, 2025
f8d3c0b
Added Bulk Copy tests with/without sendStringParametersAsUnicode, JSO…
Ananya2 Jul 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ allprojects {

test {
useJUnitPlatform {
excludeTags (hasProperty('excludedGroups') ? excludedGroups : 'xSQLv15','xGradle','reqExternalSetup','NTLM','MSI','clientCertAuth','fedAuth','kerberos','vectorTest')
excludeTags (hasProperty('excludedGroups') ? excludedGroups : 'xSQLv15','xGradle','reqExternalSetup','NTLM','MSI','clientCertAuth','fedAuth','kerberos','vectorTest','JSONTest')
}
}

Expand All @@ -46,7 +46,7 @@ if (!hasProperty('buildProfile') || (hasProperty('buildProfile') && buildProfile
targetCompatibility = 23
test {
useJUnitPlatform {
excludeTags(hasProperty('excludedGroups') ? excludedGroups : 'vectorTest')
excludeTags(hasProperty('excludedGroups') ? excludedGroups : 'vectorTest','JSONTest')
}
}
}
Expand All @@ -64,7 +64,7 @@ if (hasProperty('buildProfile') && buildProfile == "jre21") {
targetCompatibility = 21
test {
useJUnitPlatform {
excludeTags(hasProperty('excludedGroups') ? excludedGroups : 'vectorTest')
excludeTags(hasProperty('excludedGroups') ? excludedGroups : 'vectorTest','JSONTest')
}
}
}
Expand All @@ -82,7 +82,7 @@ if (hasProperty('buildProfile') && buildProfile == "jre17") {
targetCompatibility = 17
test {
useJUnitPlatform {
excludeTags(hasProperty('excludedGroups') ? excludedGroups : 'vectorTest')
excludeTags(hasProperty('excludedGroups') ? excludedGroups : 'vectorTest','JSONTest')
}
}
}
Expand All @@ -100,7 +100,7 @@ if (hasProperty('buildProfile') && buildProfile == "jre11") {
targetCompatibility = 11
test {
useJUnitPlatform {
excludeTags(hasProperty('excludedGroups') ? excludedGroups : 'vectorTest')
excludeTags(hasProperty('excludedGroups') ? excludedGroups : 'vectorTest','JSONTest')
}
}
}
Expand All @@ -114,7 +114,7 @@ if(hasProperty('buildProfile') && buildProfile == "jre8") {
targetCompatibility = 1.8
test {
useJUnitPlatform {
excludeTags (hasProperty('excludedGroups') ? excludedGroups : 'xSQLv15','xGradle','NTLM','reqExternalSetup','MSI','clientCertAuth','fedAuth','xJDBC42','vectorTest')
excludeTags (hasProperty('excludedGroups') ? excludedGroups : 'xSQLv15','xGradle','NTLM','reqExternalSetup','MSI','clientCertAuth','fedAuth','xJDBC42','vectorTest','JSONTest')
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@
reqExternalSetup - For tests requiring external setup (excluded by default)
clientCertAuth - - For tests requiring client certificate authentication
vectorTest - - For tests using vector data types (excluded by default)
JSONTest - For tests using JSON data type
setup (excluded by default) - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Default testing enabled with SQL Server 2019 (SQLv15) -->
<excludedGroups>xSQLv12,xSQLv15,NTLM,MSI,reqExternalSetup,clientCertAuth,fedAuth,kerberos,vectorTest</excludedGroups>
<excludedGroups>xSQLv12,xSQLv15,NTLM,MSI,reqExternalSetup,clientCertAuth,fedAuth,kerberos,vectorTest,JSONTest</excludedGroups>
<!-- Use -preview for preview release, leave empty for official release. -->
<releaseExt>-preview</releaseExt>
<!-- Driver Dependencies -->
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/microsoft/sqlserver/jdbc/Column.java
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ else if (jdbcType.isBinary()) {

// Update of Unicode SSType from textual JDBCType: Use Unicode.
if ((SSType.NCHAR == ssType || SSType.NVARCHAR == ssType || SSType.NVARCHARMAX == ssType
|| SSType.NTEXT == ssType || SSType.XML == ssType) &&
|| SSType.NTEXT == ssType || SSType.XML == ssType || SSType.JSON == ssType) &&

(JDBCType.CHAR == jdbcType || JDBCType.VARCHAR == jdbcType || JDBCType.LONGVARCHAR == jdbcType
|| JDBCType.CLOB == jdbcType)) {
Expand Down
37 changes: 26 additions & 11 deletions src/main/java/com/microsoft/sqlserver/jdbc/DataTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ enum TDSType {
UDT(0xF0), // -16
XML(0xF1), // -15
VECTOR(0xF5), // 245
JSON(0xF4), // -12

// LONGLEN types
SQL_VARIANT(0x62); // 98
Expand Down Expand Up @@ -151,7 +152,8 @@ enum SSType {
TIMESTAMP(Category.TIMESTAMP, "timestamp", JDBCType.BINARY),
GEOMETRY(Category.UDT, "geometry", JDBCType.GEOMETRY),
GEOGRAPHY(Category.UDT, "geography", JDBCType.GEOGRAPHY),
VECTOR(Category.VECTOR, "vector", JDBCType.VECTOR);
VECTOR(Category.VECTOR, "vector", JDBCType.VECTOR),
JSON(Category.JSON, "json", JDBCType.JSON);

final Category category;
private final String name;
Expand Down Expand Up @@ -208,7 +210,8 @@ enum Category {
UDT,
SQL_VARIANT,
XML,
VECTOR;
VECTOR,
JSON;

private static final Category[] VALUES = values();
}
Expand Down Expand Up @@ -272,7 +275,11 @@ enum GetterConversion {
JDBCType.Category.NUMERIC, JDBCType.Category.DATE, JDBCType.Category.TIME, JDBCType.Category.BINARY,
JDBCType.Category.TIMESTAMP, JDBCType.Category.NCHARACTER, JDBCType.Category.GUID)),

VECTOR(SSType.Category.VECTOR, EnumSet.of(JDBCType.Category.VECTOR));
VECTOR(SSType.Category.VECTOR, EnumSet.of(JDBCType.Category.VECTOR)),
JSON(SSType.Category.JSON, EnumSet.of(JDBCType.Category.CHARACTER, JDBCType.Category.LONG_CHARACTER,
JDBCType.Category.CLOB, JDBCType.Category.NCHARACTER, JDBCType.Category.LONG_NCHARACTER,
JDBCType.Category.NCLOB, JDBCType.Category.BINARY, JDBCType.Category.LONG_BINARY,
Comment thread
divang marked this conversation as resolved.
JDBCType.Category.BLOB, JDBCType.Category.JSON));

private final SSType.Category from;
private final EnumSet<JDBCType.Category> to;
Expand Down Expand Up @@ -462,6 +469,9 @@ JDBCType getJDBCType(SSType ssType, JDBCType jdbcTypeFromApp) {
case VECTOR:
jdbcType = JDBCType.VECTOR;
break;
case JSON:
jdbcType = JDBCType.JSON;
break;
case XML:
default:
jdbcType = JDBCType.LONGVARBINARY;
Expand Down Expand Up @@ -686,8 +696,9 @@ enum JDBCType {
GEOMETRY(Category.GEOMETRY, microsoft.sql.Types.GEOMETRY, Object.class.getName()),
GEOGRAPHY(Category.GEOGRAPHY, microsoft.sql.Types.GEOGRAPHY, Object.class.getName()),
LOCALDATETIME(Category.TIMESTAMP, java.sql.Types.TIMESTAMP, LocalDateTime.class.getName()),
VECTOR(Category.VECTOR, microsoft.sql.Types.VECTOR, microsoft.sql.Vector.class.getName());

VECTOR(Category.VECTOR, microsoft.sql.Types.VECTOR, microsoft.sql.Vector.class.getName()),
JSON(Category.JSON, microsoft.sql.Types.JSON, Object.class.getName());

final Category category;
private final int intValue;
private final String className;
Expand Down Expand Up @@ -736,7 +747,8 @@ enum Category {
SQL_VARIANT,
GEOMETRY,
GEOGRAPHY,
VECTOR;
VECTOR,
JSON;

private static final Category[] VALUES = values();
}
Expand All @@ -747,7 +759,7 @@ enum SetterConversion {
JDBCType.Category.TIME, JDBCType.Category.TIMESTAMP, JDBCType.Category.DATETIMEOFFSET,
JDBCType.Category.CHARACTER, JDBCType.Category.LONG_CHARACTER, JDBCType.Category.NCHARACTER,
JDBCType.Category.LONG_NCHARACTER, JDBCType.Category.BINARY, JDBCType.Category.LONG_BINARY,
JDBCType.Category.GUID, JDBCType.Category.SQL_VARIANT)),
JDBCType.Category.GUID, JDBCType.Category.SQL_VARIANT, JDBCType.Category.JSON)),

LONG_CHARACTER(JDBCType.Category.LONG_CHARACTER, EnumSet.of(JDBCType.Category.CHARACTER,
JDBCType.Category.LONG_CHARACTER, JDBCType.Category.NCHARACTER, JDBCType.Category.LONG_NCHARACTER,
Expand Down Expand Up @@ -811,7 +823,8 @@ enum SetterConversion {

GEOGRAPHY(JDBCType.Category.GEOGRAPHY, EnumSet.of(JDBCType.Category.GEOGRAPHY)),

VECTOR(JDBCType.Category.VECTOR, EnumSet.of(JDBCType.Category.VECTOR));
VECTOR(JDBCType.Category.VECTOR, EnumSet.of(JDBCType.Category.VECTOR)),
JSON(JDBCType.Category.JSON, EnumSet.of(JDBCType.Category.JSON));

private final JDBCType.Category from;
private final EnumSet<JDBCType.Category> to;
Expand Down Expand Up @@ -848,7 +861,7 @@ enum UpdaterConversion {
SSType.Category.DATETIMEOFFSET, SSType.Category.CHARACTER, SSType.Category.LONG_CHARACTER,
SSType.Category.NCHARACTER, SSType.Category.LONG_NCHARACTER, SSType.Category.XML,
SSType.Category.BINARY, SSType.Category.LONG_BINARY, SSType.Category.UDT, SSType.Category.GUID,
SSType.Category.TIMESTAMP, SSType.Category.SQL_VARIANT, SSType.Category.VECTOR)),
SSType.Category.TIMESTAMP, SSType.Category.SQL_VARIANT, SSType.Category.VECTOR, SSType.Category.JSON)),

LONG_CHARACTER(JDBCType.Category.LONG_CHARACTER, EnumSet.of(SSType.Category.CHARACTER,
SSType.Category.LONG_CHARACTER, SSType.Category.NCHARACTER, SSType.Category.LONG_NCHARACTER,
Expand Down Expand Up @@ -914,7 +927,8 @@ enum UpdaterConversion {
SQL_VARIANT(JDBCType.Category.SQL_VARIANT, EnumSet.of(SSType.Category.SQL_VARIANT)),

VECTOR(JDBCType.Category.VECTOR, EnumSet.of(SSType.Category.CHARACTER, SSType.Category.LONG_CHARACTER,
SSType.Category.VECTOR));
SSType.Category.VECTOR)),
JSON(JDBCType.Category.JSON, EnumSet.of(SSType.Category.JSON));

private final JDBCType.Category from;
private final EnumSet<SSType.Category> to;
Expand Down Expand Up @@ -989,7 +1003,7 @@ boolean isBinary() {
* @return true if the JDBC type is textual
*/
private final static EnumSet<Category> textualCategories = EnumSet.of(Category.CHARACTER, Category.LONG_CHARACTER,
Category.CLOB, Category.NCHARACTER, Category.LONG_NCHARACTER, Category.NCLOB);
Category.CLOB, Category.NCHARACTER, Category.LONG_NCHARACTER, Category.NCLOB);

boolean isTextual() {
return textualCategories.contains(category);
Expand All @@ -1016,6 +1030,7 @@ int asJavaSqlType() {
return java.sql.Types.CHAR;
case NVARCHAR:
case SQLXML:
case JSON:
return java.sql.Types.VARCHAR;
case VECTOR:
return microsoft.sql.Types.VECTOR;
Expand Down
29 changes: 29 additions & 0 deletions src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@ final class TDS {
static final byte TDS_FEATURE_EXT_VECTORSUPPORT = 0x0E;
static final byte VECTORSUPPORT_NOT_SUPPORTED = 0x00;
static final byte MAX_VECTORSUPPORT_VERSION = 0x01;
// JSON support
static final byte TDS_FEATURE_EXT_JSONSUPPORT = 0x0D;
static final byte JSONSUPPORT_NOT_SUPPORTED = 0x00;
static final byte MAX_JSONSUPPORT_VERSION = 0x01;

static final int TDS_TVP = 0xF3;
static final int TVP_ROW = 0x01;
Expand Down Expand Up @@ -245,6 +249,9 @@ static final String getTokenName(int tdsTokenType) {
return "TDS_FEATURE_EXT_SESSIONRECOVERY (0x01)";
case TDS_FEATURE_EXT_VECTORSUPPORT:
return "TDS_FEATURE_EXT_VECTORSUPPORT (0x0E)";
case TDS_FEATURE_EXT_JSONSUPPORT:
return "TDS_FEATURE_EXT_JSONSUPPORT (0x0D)";

default:
return "unknown token (0x" + Integer.toHexString(tdsTokenType).toUpperCase() + ")";
}
Expand Down Expand Up @@ -4864,6 +4871,26 @@ void writeRPCStringUnicode(String sValue) throws SQLServerException {
writeRPCStringUnicode(null, sValue, false, null);
}

void writeRPCJson(String sName, String sValue, boolean bOut) throws SQLServerException {
boolean bValueNull = (sValue == null);
int nValueLen = bValueNull ? 0 : (2 * sValue.length());

writeRPCNameValType(sName, bOut, TDSType.JSON);

// PLP encoding is used for JSON values.
writeVMaxHeader(nValueLen, bValueNull, /* collation = */ null);

if (!bValueNull) {
if (nValueLen > 0) {
writeInt(nValueLen);
writeString(sValue);
}

// PLP terminator
writeInt(0);
}
}

/**
* Writes a string value as Unicode for RPC
*
Expand Down Expand Up @@ -5249,6 +5276,7 @@ private void writeInternalTVPRowValues(JDBCType jdbcType, String currentColumnSt
case LONGVARCHAR:
case LONGNVARCHAR:
case SQLXML:
case JSON:
isShortValue = (2L * columnPair.getValue().precision) <= DataTypes.SHORT_VARTYPE_MAX_BYTES;
isNull = (null == currentColumnStringValue);
dataLength = isNull ? 0 : currentColumnStringValue.length() * 2;
Expand Down Expand Up @@ -5493,6 +5521,7 @@ void writeTVPColumnMetaData(TVP value) throws SQLServerException {
case LONGVARCHAR:
case LONGNVARCHAR:
case SQLXML:
case JSON:
writeByte(TDSType.NVARCHAR.byteValue());
isShortValue = (2L * pair.getValue().precision) <= DataTypes.SHORT_VARTYPE_MAX_BYTES;
// Use PLP encoding on Yukon and later with long values
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/microsoft/sqlserver/jdbc/Parameter.java
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,9 @@ private void setTypeDefinition(DTV dtv) {
case SQLXML:
param.typeDefinition = SSType.XML.toString();
break;

case JSON:
param.typeDefinition = SSType.JSON.toString();
break;
case TVP:
// definition should contain the TVP name and the keyword READONLY
String schema = param.schemaName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,10 @@ else if ((null != columnNames) && (columnNames.length >= positionInSource))
columnMetadata.put(positionInSource,
new ColumnMetadata(colName, java.sql.Types.LONGNVARCHAR, precision, scale, dateTimeFormatter));
break;
case microsoft.sql.Types.JSON:
columnMetadata.put(positionInSource,
new ColumnMetadata(colName, microsoft.sql.Types.JSON, precision, scale, dateTimeFormatter));
break;
/*
* Redirecting Float as Double based on data type mapping
* https://msdn.microsoft.com/library/ms378878%28v=sql.110%29.aspx
Expand Down Expand Up @@ -642,11 +646,13 @@ public void setEscapeColumnDelimitersCSV(boolean escapeDelimiters) {
this.escapeDelimiters = escapeDelimiters;
}


private static String[] escapeQuotesRFC4180(String[] tokens) throws SQLServerException {
if (null == tokens) {
return tokens;
}
for (int i = 0; i < tokens.length; i++) {

boolean escaped = false;
int j = 0;
StringBuilder sb = new StringBuilder();
Expand Down
20 changes: 14 additions & 6 deletions src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,8 @@ private void writeColumnMetaDataColumnData(TDSWriter tdsWriter, int idx) throws
collation = connection.getDatabaseCollation();

if ((java.sql.Types.NCHAR == bulkJdbcType) || (java.sql.Types.NVARCHAR == bulkJdbcType)
|| (java.sql.Types.LONGNVARCHAR == bulkJdbcType)) {
|| (java.sql.Types.LONGNVARCHAR == bulkJdbcType)
|| (microsoft.sql.Types.JSON == bulkJdbcType)) {
isStreaming = (DataTypes.SHORT_VARTYPE_MAX_CHARS < bulkPrecision)
|| (DataTypes.SHORT_VARTYPE_MAX_CHARS < destPrecision);
} else {
Expand Down Expand Up @@ -835,7 +836,8 @@ else if (((java.sql.Types.CHAR == bulkJdbcType) || (java.sql.Types.VARCHAR == bu
int baseDestPrecision = destCryptoMeta.baseTypeInfo.getPrecision();

if ((java.sql.Types.NCHAR == baseDestJDBCType) || (java.sql.Types.NVARCHAR == baseDestJDBCType)
|| (java.sql.Types.LONGNVARCHAR == baseDestJDBCType))
|| (java.sql.Types.LONGNVARCHAR == baseDestJDBCType)
|| (microsoft.sql.Types.JSON == baseDestJDBCType))
isStreaming = (DataTypes.SHORT_VARTYPE_MAX_CHARS < baseDestPrecision);
else
isStreaming = (DataTypes.SHORT_VARTYPE_MAX_BYTES < baseDestPrecision);
Expand Down Expand Up @@ -995,6 +997,7 @@ private void writeTypeInfo(TDSWriter tdsWriter, int srcJdbcType, int srcScale, i

case java.sql.Types.LONGVARCHAR:
case java.sql.Types.VARCHAR: // 0xA7
case microsoft.sql.Types.JSON:
Comment thread
divang marked this conversation as resolved.
if (unicodeConversionRequired(srcJdbcType, destSSType)) {
tdsWriter.writeByte(TDSType.NVARCHAR.byteValue());
if (isStreaming) {
Expand Down Expand Up @@ -1023,7 +1026,6 @@ private void writeTypeInfo(TDSWriter tdsWriter, int srcJdbcType, int srcScale, i
}
collation.writeCollation(tdsWriter);
break;

case java.sql.Types.BINARY: // 0xAD
tdsWriter.writeByte(TDSType.BIGBINARY.byteValue());
tdsWriter.writeShort((short) (srcPrecision));
Expand Down Expand Up @@ -1481,6 +1483,8 @@ private String getDestTypeFromSrcType(int srcColIndx, int destColIndx,
}
case microsoft.sql.Types.SQL_VARIANT:
return SSType.SQL_VARIANT.toString();
case microsoft.sql.Types.JSON:
return SSType.JSON.toString();
default: {
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_BulkTypeNotSupported"));
Object[] msgArgs = {JDBCType.of(bulkJdbcType).toString().toLowerCase(Locale.ENGLISH)};
Expand Down Expand Up @@ -2102,6 +2106,7 @@ private void writeNullToTdsWriter(TDSWriter tdsWriter, int srcJdbcType,
case java.sql.Types.LONGNVARCHAR:
case java.sql.Types.LONGVARBINARY:
case microsoft.sql.Types.VECTOR:
case microsoft.sql.Types.JSON:
if (isStreaming) {
tdsWriter.writeLong(PLPInputStream.PLP_NULL);
} else {
Expand Down Expand Up @@ -2352,6 +2357,7 @@ else if (null != sourceCryptoMeta) {
case java.sql.Types.LONGVARCHAR:
case java.sql.Types.CHAR: // Fixed-length, non-Unicode string data.
case java.sql.Types.VARCHAR: // Variable-length, non-Unicode string data.
case microsoft.sql.Types.JSON:
if (isStreaming) // PLP
{
// PLP_BODY rule in TDS
Expand Down Expand Up @@ -2490,7 +2496,6 @@ else if (null != sourceCryptoMeta) {
}
}
break;

case java.sql.Types.LONGVARBINARY:
case java.sql.Types.BINARY:
case java.sql.Types.VARBINARY:
Expand Down Expand Up @@ -3018,6 +3023,7 @@ private Object readColumnFromResultSet(int srcColOrdinal, int srcJdbcType, boole
case java.sql.Types.LONGNVARCHAR:
case java.sql.Types.NCHAR:
case java.sql.Types.NVARCHAR:
case microsoft.sql.Types.JSON:
// PLP if stream type and both the source and destination are not encrypted
// This is because AE does not support streaming types.
// Therefore an encrypted source or destination means the data must not actually be streaming data
Expand Down Expand Up @@ -3092,7 +3098,8 @@ private void writeColumn(TDSWriter tdsWriter, int srcColOrdinal, int destColOrdi
destPrecision = destColumnMetadata.get(destColOrdinal).precision;

if ((java.sql.Types.NCHAR == srcJdbcType) || (java.sql.Types.NVARCHAR == srcJdbcType)
|| (java.sql.Types.LONGNVARCHAR == srcJdbcType)) {
|| (java.sql.Types.LONGNVARCHAR == srcJdbcType)
|| (microsoft.sql.Types.JSON == srcJdbcType)) {
isStreaming = (DataTypes.SHORT_VARTYPE_MAX_CHARS < srcPrecision)
|| (DataTypes.SHORT_VARTYPE_MAX_CHARS < destPrecision);
} else {
Expand Down Expand Up @@ -3813,6 +3820,7 @@ void setDestinationTableMetadata(SQLServerResultSet rs) {
private boolean unicodeConversionRequired(int jdbcType, SSType ssType) {
return ((java.sql.Types.CHAR == jdbcType || java.sql.Types.VARCHAR == jdbcType
|| java.sql.Types.LONGNVARCHAR == jdbcType)
&& (SSType.NCHAR == ssType || SSType.NVARCHAR == ssType || SSType.NVARCHARMAX == ssType));
&& (SSType.NCHAR == ssType || SSType.NVARCHAR == ssType || SSType.NVARCHARMAX == ssType
|| SSType.JSON == ssType));
}
}
Loading
Loading