Skip to content

Commit a7fe77a

Browse files
divanglilgreenbirdDivang SharmaAnanya2muskan124947
authored
JSON datatype support (#2558)
* JSON datatype implementation. Co-authored-by: lilgreenbird <[email protected]> Co-authored-by: Divang Sharma <[email protected]> Co-authored-by: Ananya Garg <[email protected]> Co-authored-by: Muskan Gupta <[email protected]> Co-authored-by: Ananya Garg <[email protected]>
1 parent f393ca7 commit a7fe77a

30 files changed

+3237
-55
lines changed

build.gradle

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ allprojects {
2929

3030
test {
3131
useJUnitPlatform {
32-
excludeTags (hasProperty('excludedGroups') ? excludedGroups : 'xSQLv15','xGradle','reqExternalSetup','NTLM','MSI','clientCertAuth','fedAuth','kerberos','vectorTest')
32+
excludeTags (hasProperty('excludedGroups') ? excludedGroups : 'xSQLv15','xGradle','reqExternalSetup','NTLM','MSI','clientCertAuth','fedAuth','kerberos','vectorTest','JSONTest')
3333
}
3434
}
3535

@@ -46,7 +46,7 @@ if (!hasProperty('buildProfile') || (hasProperty('buildProfile') && buildProfile
4646
targetCompatibility = 23
4747
test {
4848
useJUnitPlatform {
49-
excludeTags(hasProperty('excludedGroups') ? excludedGroups : 'vectorTest')
49+
excludeTags(hasProperty('excludedGroups') ? excludedGroups : 'vectorTest','JSONTest')
5050
}
5151
}
5252
}
@@ -64,7 +64,7 @@ if (hasProperty('buildProfile') && buildProfile == "jre21") {
6464
targetCompatibility = 21
6565
test {
6666
useJUnitPlatform {
67-
excludeTags(hasProperty('excludedGroups') ? excludedGroups : 'vectorTest')
67+
excludeTags(hasProperty('excludedGroups') ? excludedGroups : 'vectorTest','JSONTest')
6868
}
6969
}
7070
}
@@ -82,7 +82,7 @@ if (hasProperty('buildProfile') && buildProfile == "jre17") {
8282
targetCompatibility = 17
8383
test {
8484
useJUnitPlatform {
85-
excludeTags(hasProperty('excludedGroups') ? excludedGroups : 'vectorTest')
85+
excludeTags(hasProperty('excludedGroups') ? excludedGroups : 'vectorTest','JSONTest')
8686
}
8787
}
8888
}
@@ -100,7 +100,7 @@ if (hasProperty('buildProfile') && buildProfile == "jre11") {
100100
targetCompatibility = 11
101101
test {
102102
useJUnitPlatform {
103-
excludeTags(hasProperty('excludedGroups') ? excludedGroups : 'vectorTest')
103+
excludeTags(hasProperty('excludedGroups') ? excludedGroups : 'vectorTest','JSONTest')
104104
}
105105
}
106106
}
@@ -114,7 +114,7 @@ if(hasProperty('buildProfile') && buildProfile == "jre8") {
114114
targetCompatibility = 1.8
115115
test {
116116
useJUnitPlatform {
117-
excludeTags (hasProperty('excludedGroups') ? excludedGroups : 'xSQLv15','xGradle','NTLM','reqExternalSetup','MSI','clientCertAuth','fedAuth','xJDBC42','vectorTest')
117+
excludeTags (hasProperty('excludedGroups') ? excludedGroups : 'xSQLv15','xGradle','NTLM','reqExternalSetup','MSI','clientCertAuth','fedAuth','xJDBC42','vectorTest','JSONTest')
118118
}
119119
}
120120
}

pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,11 @@
4747
reqExternalSetup - For tests requiring external setup (excluded by default)
4848
clientCertAuth - - For tests requiring client certificate authentication
4949
vectorTest - - For tests using vector data types (excluded by default)
50+
JSONTest - For tests using JSON data type
5051
setup (excluded by default) - - - - - - - - - - - - - - - - - - - - - - -
5152
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
5253
Default testing enabled with SQL Server 2019 (SQLv15) -->
53-
<excludedGroups>xSQLv12,xSQLv15,NTLM,MSI,reqExternalSetup,clientCertAuth,fedAuth,kerberos,vectorTest</excludedGroups>
54+
<excludedGroups>xSQLv12,xSQLv15,NTLM,MSI,reqExternalSetup,clientCertAuth,fedAuth,kerberos,vectorTest,JSONTest</excludedGroups>
5455
<!-- Use -preview for preview release, leave empty for official release. -->
5556
<releaseExt>-preview</releaseExt>
5657
<!-- Driver Dependencies -->

src/main/java/com/microsoft/sqlserver/jdbc/Column.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ else if (jdbcType.isBinary()) {
335335

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

340340
(JDBCType.CHAR == jdbcType || JDBCType.VARCHAR == jdbcType || JDBCType.LONGVARCHAR == jdbcType
341341
|| JDBCType.CLOB == jdbcType)) {

src/main/java/com/microsoft/sqlserver/jdbc/DataTypes.java

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ enum TDSType {
6767
UDT(0xF0), // -16
6868
XML(0xF1), // -15
6969
VECTOR(0xF5), // 245
70+
JSON(0xF4), // -12
7071

7172
// LONGLEN types
7273
SQL_VARIANT(0x62); // 98
@@ -151,7 +152,8 @@ enum SSType {
151152
TIMESTAMP(Category.TIMESTAMP, "timestamp", JDBCType.BINARY),
152153
GEOMETRY(Category.UDT, "geometry", JDBCType.GEOMETRY),
153154
GEOGRAPHY(Category.UDT, "geography", JDBCType.GEOGRAPHY),
154-
VECTOR(Category.VECTOR, "vector", JDBCType.VECTOR);
155+
VECTOR(Category.VECTOR, "vector", JDBCType.VECTOR),
156+
JSON(Category.JSON, "json", JDBCType.JSON);
155157

156158
final Category category;
157159
private final String name;
@@ -208,7 +210,8 @@ enum Category {
208210
UDT,
209211
SQL_VARIANT,
210212
XML,
211-
VECTOR;
213+
VECTOR,
214+
JSON;
212215

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

275-
VECTOR(SSType.Category.VECTOR, EnumSet.of(JDBCType.Category.VECTOR));
278+
VECTOR(SSType.Category.VECTOR, EnumSet.of(JDBCType.Category.VECTOR)),
279+
JSON(SSType.Category.JSON, EnumSet.of(JDBCType.Category.CHARACTER, JDBCType.Category.LONG_CHARACTER,
280+
JDBCType.Category.CLOB, JDBCType.Category.NCHARACTER, JDBCType.Category.LONG_NCHARACTER,
281+
JDBCType.Category.NCLOB, JDBCType.Category.BINARY, JDBCType.Category.LONG_BINARY,
282+
JDBCType.Category.BLOB, JDBCType.Category.JSON));
276283

277284
private final SSType.Category from;
278285
private final EnumSet<JDBCType.Category> to;
@@ -462,6 +469,9 @@ JDBCType getJDBCType(SSType ssType, JDBCType jdbcTypeFromApp) {
462469
case VECTOR:
463470
jdbcType = JDBCType.VECTOR;
464471
break;
472+
case JSON:
473+
jdbcType = JDBCType.JSON;
474+
break;
465475
case XML:
466476
default:
467477
jdbcType = JDBCType.LONGVARBINARY;
@@ -686,8 +696,9 @@ enum JDBCType {
686696
GEOMETRY(Category.GEOMETRY, microsoft.sql.Types.GEOMETRY, Object.class.getName()),
687697
GEOGRAPHY(Category.GEOGRAPHY, microsoft.sql.Types.GEOGRAPHY, Object.class.getName()),
688698
LOCALDATETIME(Category.TIMESTAMP, java.sql.Types.TIMESTAMP, LocalDateTime.class.getName()),
689-
VECTOR(Category.VECTOR, microsoft.sql.Types.VECTOR, microsoft.sql.Vector.class.getName());
690-
699+
VECTOR(Category.VECTOR, microsoft.sql.Types.VECTOR, microsoft.sql.Vector.class.getName()),
700+
JSON(Category.JSON, microsoft.sql.Types.JSON, Object.class.getName());
701+
691702
final Category category;
692703
private final int intValue;
693704
private final String className;
@@ -736,7 +747,8 @@ enum Category {
736747
SQL_VARIANT,
737748
GEOMETRY,
738749
GEOGRAPHY,
739-
VECTOR;
750+
VECTOR,
751+
JSON;
740752

741753
private static final Category[] VALUES = values();
742754
}
@@ -747,7 +759,7 @@ enum SetterConversion {
747759
JDBCType.Category.TIME, JDBCType.Category.TIMESTAMP, JDBCType.Category.DATETIMEOFFSET,
748760
JDBCType.Category.CHARACTER, JDBCType.Category.LONG_CHARACTER, JDBCType.Category.NCHARACTER,
749761
JDBCType.Category.LONG_NCHARACTER, JDBCType.Category.BINARY, JDBCType.Category.LONG_BINARY,
750-
JDBCType.Category.GUID, JDBCType.Category.SQL_VARIANT)),
762+
JDBCType.Category.GUID, JDBCType.Category.SQL_VARIANT, JDBCType.Category.JSON)),
751763

752764
LONG_CHARACTER(JDBCType.Category.LONG_CHARACTER, EnumSet.of(JDBCType.Category.CHARACTER,
753765
JDBCType.Category.LONG_CHARACTER, JDBCType.Category.NCHARACTER, JDBCType.Category.LONG_NCHARACTER,
@@ -811,7 +823,8 @@ enum SetterConversion {
811823

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

814-
VECTOR(JDBCType.Category.VECTOR, EnumSet.of(JDBCType.Category.VECTOR));
826+
VECTOR(JDBCType.Category.VECTOR, EnumSet.of(JDBCType.Category.VECTOR)),
827+
JSON(JDBCType.Category.JSON, EnumSet.of(JDBCType.Category.JSON));
815828

816829
private final JDBCType.Category from;
817830
private final EnumSet<JDBCType.Category> to;
@@ -848,7 +861,7 @@ enum UpdaterConversion {
848861
SSType.Category.DATETIMEOFFSET, SSType.Category.CHARACTER, SSType.Category.LONG_CHARACTER,
849862
SSType.Category.NCHARACTER, SSType.Category.LONG_NCHARACTER, SSType.Category.XML,
850863
SSType.Category.BINARY, SSType.Category.LONG_BINARY, SSType.Category.UDT, SSType.Category.GUID,
851-
SSType.Category.TIMESTAMP, SSType.Category.SQL_VARIANT, SSType.Category.VECTOR)),
864+
SSType.Category.TIMESTAMP, SSType.Category.SQL_VARIANT, SSType.Category.VECTOR, SSType.Category.JSON)),
852865

853866
LONG_CHARACTER(JDBCType.Category.LONG_CHARACTER, EnumSet.of(SSType.Category.CHARACTER,
854867
SSType.Category.LONG_CHARACTER, SSType.Category.NCHARACTER, SSType.Category.LONG_NCHARACTER,
@@ -914,7 +927,8 @@ enum UpdaterConversion {
914927
SQL_VARIANT(JDBCType.Category.SQL_VARIANT, EnumSet.of(SSType.Category.SQL_VARIANT)),
915928

916929
VECTOR(JDBCType.Category.VECTOR, EnumSet.of(SSType.Category.CHARACTER, SSType.Category.LONG_CHARACTER,
917-
SSType.Category.VECTOR));
930+
SSType.Category.VECTOR)),
931+
JSON(JDBCType.Category.JSON, EnumSet.of(SSType.Category.JSON));
918932

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

9941008
boolean isTextual() {
9951009
return textualCategories.contains(category);
@@ -1016,6 +1030,7 @@ int asJavaSqlType() {
10161030
return java.sql.Types.CHAR;
10171031
case NVARCHAR:
10181032
case SQLXML:
1033+
case JSON:
10191034
return java.sql.Types.VARCHAR;
10201035
case VECTOR:
10211036
return microsoft.sql.Types.VECTOR;

src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,10 @@ final class TDS {
174174
static final byte TDS_FEATURE_EXT_VECTORSUPPORT = 0x0E;
175175
static final byte VECTORSUPPORT_NOT_SUPPORTED = 0x00;
176176
static final byte MAX_VECTORSUPPORT_VERSION = 0x01;
177+
// JSON support
178+
static final byte TDS_FEATURE_EXT_JSONSUPPORT = 0x0D;
179+
static final byte JSONSUPPORT_NOT_SUPPORTED = 0x00;
180+
static final byte MAX_JSONSUPPORT_VERSION = 0x01;
177181

178182
static final int TDS_TVP = 0xF3;
179183
static final int TVP_ROW = 0x01;
@@ -245,6 +249,9 @@ static final String getTokenName(int tdsTokenType) {
245249
return "TDS_FEATURE_EXT_SESSIONRECOVERY (0x01)";
246250
case TDS_FEATURE_EXT_VECTORSUPPORT:
247251
return "TDS_FEATURE_EXT_VECTORSUPPORT (0x0E)";
252+
case TDS_FEATURE_EXT_JSONSUPPORT:
253+
return "TDS_FEATURE_EXT_JSONSUPPORT (0x0D)";
254+
248255
default:
249256
return "unknown token (0x" + Integer.toHexString(tdsTokenType).toUpperCase() + ")";
250257
}
@@ -4864,6 +4871,26 @@ void writeRPCStringUnicode(String sValue) throws SQLServerException {
48644871
writeRPCStringUnicode(null, sValue, false, null);
48654872
}
48664873

4874+
void writeRPCJson(String sName, String sValue, boolean bOut) throws SQLServerException {
4875+
boolean bValueNull = (sValue == null);
4876+
int nValueLen = bValueNull ? 0 : (2 * sValue.length());
4877+
4878+
writeRPCNameValType(sName, bOut, TDSType.JSON);
4879+
4880+
// PLP encoding is used for JSON values.
4881+
writeVMaxHeader(nValueLen, bValueNull, /* collation = */ null);
4882+
4883+
if (!bValueNull) {
4884+
if (nValueLen > 0) {
4885+
writeInt(nValueLen);
4886+
writeString(sValue);
4887+
}
4888+
4889+
// PLP terminator
4890+
writeInt(0);
4891+
}
4892+
}
4893+
48674894
/**
48684895
* Writes a string value as Unicode for RPC
48694896
*
@@ -5249,6 +5276,7 @@ private void writeInternalTVPRowValues(JDBCType jdbcType, String currentColumnSt
52495276
case LONGVARCHAR:
52505277
case LONGNVARCHAR:
52515278
case SQLXML:
5279+
case JSON:
52525280
isShortValue = (2L * columnPair.getValue().precision) <= DataTypes.SHORT_VARTYPE_MAX_BYTES;
52535281
isNull = (null == currentColumnStringValue);
52545282
dataLength = isNull ? 0 : currentColumnStringValue.length() * 2;
@@ -5493,6 +5521,7 @@ void writeTVPColumnMetaData(TVP value) throws SQLServerException {
54935521
case LONGVARCHAR:
54945522
case LONGNVARCHAR:
54955523
case SQLXML:
5524+
case JSON:
54965525
writeByte(TDSType.NVARCHAR.byteValue());
54975526
isShortValue = (2L * pair.getValue().precision) <= DataTypes.SHORT_VARTYPE_MAX_BYTES;
54985527
// Use PLP encoding on Yukon and later with long values

src/main/java/com/microsoft/sqlserver/jdbc/Parameter.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,9 @@ private void setTypeDefinition(DTV dtv) {
907907
case SQLXML:
908908
param.typeDefinition = SSType.XML.toString();
909909
break;
910-
910+
case JSON:
911+
param.typeDefinition = SSType.JSON.toString();
912+
break;
911913
case TVP:
912914
// definition should contain the TVP name and the keyword READONLY
913915
String schema = param.schemaName;

src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCSVFileRecord.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,10 @@ else if ((null != columnNames) && (columnNames.length >= positionInSource))
581581
columnMetadata.put(positionInSource,
582582
new ColumnMetadata(colName, java.sql.Types.LONGNVARCHAR, precision, scale, dateTimeFormatter));
583583
break;
584+
case microsoft.sql.Types.JSON:
585+
columnMetadata.put(positionInSource,
586+
new ColumnMetadata(colName, microsoft.sql.Types.JSON, precision, scale, dateTimeFormatter));
587+
break;
584588
/*
585589
* Redirecting Float as Double based on data type mapping
586590
* https://msdn.microsoft.com/library/ms378878%28v=sql.110%29.aspx
@@ -642,11 +646,13 @@ public void setEscapeColumnDelimitersCSV(boolean escapeDelimiters) {
642646
this.escapeDelimiters = escapeDelimiters;
643647
}
644648

649+
645650
private static String[] escapeQuotesRFC4180(String[] tokens) throws SQLServerException {
646651
if (null == tokens) {
647652
return tokens;
648653
}
649654
for (int i = 0; i < tokens.length; i++) {
655+
650656
boolean escaped = false;
651657
int j = 0;
652658
StringBuilder sb = new StringBuilder();

src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,8 @@ private void writeColumnMetaDataColumnData(TDSWriter tdsWriter, int idx) throws
838838
collation = connection.getDatabaseCollation();
839839

840840
if ((java.sql.Types.NCHAR == bulkJdbcType) || (java.sql.Types.NVARCHAR == bulkJdbcType)
841-
|| (java.sql.Types.LONGNVARCHAR == bulkJdbcType)) {
841+
|| (java.sql.Types.LONGNVARCHAR == bulkJdbcType)
842+
|| (microsoft.sql.Types.JSON == bulkJdbcType)) {
842843
isStreaming = (DataTypes.SHORT_VARTYPE_MAX_CHARS < bulkPrecision)
843844
|| (DataTypes.SHORT_VARTYPE_MAX_CHARS < destPrecision);
844845
} else {
@@ -895,7 +896,8 @@ else if (((java.sql.Types.CHAR == bulkJdbcType) || (java.sql.Types.VARCHAR == bu
895896
int baseDestPrecision = destCryptoMeta.baseTypeInfo.getPrecision();
896897

897898
if ((java.sql.Types.NCHAR == baseDestJDBCType) || (java.sql.Types.NVARCHAR == baseDestJDBCType)
898-
|| (java.sql.Types.LONGNVARCHAR == baseDestJDBCType))
899+
|| (java.sql.Types.LONGNVARCHAR == baseDestJDBCType)
900+
|| (microsoft.sql.Types.JSON == baseDestJDBCType))
899901
isStreaming = (DataTypes.SHORT_VARTYPE_MAX_CHARS < baseDestPrecision);
900902
else
901903
isStreaming = (DataTypes.SHORT_VARTYPE_MAX_BYTES < baseDestPrecision);
@@ -1055,6 +1057,7 @@ private void writeTypeInfo(TDSWriter tdsWriter, int srcJdbcType, int srcScale, i
10551057

10561058
case java.sql.Types.LONGVARCHAR:
10571059
case java.sql.Types.VARCHAR: // 0xA7
1060+
case microsoft.sql.Types.JSON:
10581061
if (unicodeConversionRequired(srcJdbcType, destSSType)) {
10591062
tdsWriter.writeByte(TDSType.NVARCHAR.byteValue());
10601063
if (isStreaming) {
@@ -1083,7 +1086,6 @@ private void writeTypeInfo(TDSWriter tdsWriter, int srcJdbcType, int srcScale, i
10831086
}
10841087
collation.writeCollation(tdsWriter);
10851088
break;
1086-
10871089
case java.sql.Types.BINARY: // 0xAD
10881090
tdsWriter.writeByte(TDSType.BIGBINARY.byteValue());
10891091
tdsWriter.writeShort((short) (srcPrecision));
@@ -1541,6 +1543,8 @@ private String getDestTypeFromSrcType(int srcColIndx, int destColIndx,
15411543
}
15421544
case microsoft.sql.Types.SQL_VARIANT:
15431545
return SSType.SQL_VARIANT.toString();
1546+
case microsoft.sql.Types.JSON:
1547+
return SSType.JSON.toString();
15441548
default: {
15451549
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_BulkTypeNotSupported"));
15461550
Object[] msgArgs = {JDBCType.of(bulkJdbcType).toString().toLowerCase(Locale.ENGLISH)};
@@ -2197,6 +2201,7 @@ private void writeNullToTdsWriter(TDSWriter tdsWriter, int srcJdbcType,
21972201
case java.sql.Types.LONGNVARCHAR:
21982202
case java.sql.Types.LONGVARBINARY:
21992203
case microsoft.sql.Types.VECTOR:
2204+
case microsoft.sql.Types.JSON:
22002205
if (isStreaming) {
22012206
tdsWriter.writeLong(PLPInputStream.PLP_NULL);
22022207
} else {
@@ -2449,6 +2454,7 @@ else if (null != sourceCryptoMeta) {
24492454
case java.sql.Types.LONGVARCHAR:
24502455
case java.sql.Types.CHAR: // Fixed-length, non-Unicode string data.
24512456
case java.sql.Types.VARCHAR: // Variable-length, non-Unicode string data.
2457+
case microsoft.sql.Types.JSON:
24522458
if (isStreaming) // PLP
24532459
{
24542460
// PLP_BODY rule in TDS
@@ -2587,7 +2593,6 @@ else if (null != sourceCryptoMeta) {
25872593
}
25882594
}
25892595
break;
2590-
25912596
case java.sql.Types.LONGVARBINARY:
25922597
case java.sql.Types.BINARY:
25932598
case java.sql.Types.VARBINARY:
@@ -3115,6 +3120,7 @@ private Object readColumnFromResultSet(int srcColOrdinal, int srcJdbcType, boole
31153120
case java.sql.Types.LONGNVARCHAR:
31163121
case java.sql.Types.NCHAR:
31173122
case java.sql.Types.NVARCHAR:
3123+
case microsoft.sql.Types.JSON:
31183124
// PLP if stream type and both the source and destination are not encrypted
31193125
// This is because AE does not support streaming types.
31203126
// Therefore an encrypted source or destination means the data must not actually be streaming data
@@ -3189,7 +3195,8 @@ private void writeColumn(TDSWriter tdsWriter, int srcColOrdinal, int destColOrdi
31893195
destPrecision = destColumnMetadata.get(destColOrdinal).precision;
31903196

31913197
if ((java.sql.Types.NCHAR == srcJdbcType) || (java.sql.Types.NVARCHAR == srcJdbcType)
3192-
|| (java.sql.Types.LONGNVARCHAR == srcJdbcType)) {
3198+
|| (java.sql.Types.LONGNVARCHAR == srcJdbcType)
3199+
|| (microsoft.sql.Types.JSON == srcJdbcType)) {
31933200
isStreaming = (DataTypes.SHORT_VARTYPE_MAX_CHARS < srcPrecision)
31943201
|| (DataTypes.SHORT_VARTYPE_MAX_CHARS < destPrecision);
31953202
} else {
@@ -3910,6 +3917,7 @@ void setDestinationTableMetadata(SQLServerResultSet rs) {
39103917
private boolean unicodeConversionRequired(int jdbcType, SSType ssType) {
39113918
return ((java.sql.Types.CHAR == jdbcType || java.sql.Types.VARCHAR == jdbcType
39123919
|| java.sql.Types.LONGNVARCHAR == jdbcType)
3913-
&& (SSType.NCHAR == ssType || SSType.NVARCHAR == ssType || SSType.NVARCHARMAX == ssType));
3920+
&& (SSType.NCHAR == ssType || SSType.NVARCHAR == ssType || SSType.NVARCHARMAX == ssType
3921+
|| SSType.JSON == ssType));
39143922
}
39153923
}

0 commit comments

Comments
 (0)