Skip to content

Commit

Permalink
Merge pull request #151 from v-suhame/bulkCopy_AE
Browse files Browse the repository at this point in the history
Bulk copy with AE
  • Loading branch information
xiangyushawn authored Feb 17, 2017
2 parents ca59185 + 0418394 commit e99f326
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java
Original file line number Diff line number Diff line change
Expand Up @@ -799,11 +799,15 @@ private void writeColumnMetaDataColumnData(TDSWriter tdsWriter,
isStreaming = (DataTypes.SHORT_VARTYPE_MAX_BYTES < bulkPrecision) || (DataTypes.SHORT_VARTYPE_MAX_BYTES < destPrecision);
}

CryptoMetadata destCryptoMeta = destColumnMetadata.get(destColumnIndex).cryptoMeta;

/*
* if source is encrypted and destination is unenecrypted use destination sql type to send since there is no way of finding if source is
* encrypted without accessing the resultset, send destination type if source resultset set is of type SQLServer and encryption is enabled
* if source is encrypted and destination is unenecrypted, use destination's sql type to send since there is no way of finding if source is
* encrypted without accessing the resultset.
*
* Send destination type if source resultset set is of type SQLServer, encryption is enabled and destination column is not encrypted
*/
if ((sourceResultSet instanceof SQLServerResultSet) && (connection.isColumnEncryptionSettingEnabled())) {
if ((sourceResultSet instanceof SQLServerResultSet) && (connection.isColumnEncryptionSettingEnabled()) && (null != destCryptoMeta)) {
bulkJdbcType = destColumnMetadata.get(destColumnIndex).jdbcType;
bulkPrecision = destPrecision;
bulkScale = destColumnMetadata.get(destColumnIndex).scale;
Expand Down Expand Up @@ -839,8 +843,7 @@ else if (((java.sql.Types.CHAR == bulkJdbcType) || (java.sql.Types.VARCHAR == bu
writeTypeInfo(tdsWriter, bulkJdbcType, bulkScale, bulkPrecision, destSSType, collation, isStreaming, srcNullable, false);
}

CryptoMetadata destCryptoMeta = null;
if ((null != (destCryptoMeta = destColumnMetadata.get(destColumnIndex).cryptoMeta))) {
if (null != destCryptoMeta) {
int baseDestJDBCType = destCryptoMeta.baseTypeInfo.getSSType().getJDBCType().asJavaSqlType();
int baseDestPrecision = destCryptoMeta.baseTypeInfo.getPrecision();

Expand Down Expand Up @@ -1268,8 +1271,13 @@ private String getDestTypeFromSrcType(int srcColIndx,
}
bulkPrecision = validateSourcePrecision(srcPrecision, bulkJdbcType, destPrecision);

// if encrypted source and unencrypted destination combination
if ((sourceResultSet instanceof SQLServerResultSet) && (connection.isColumnEncryptionSettingEnabled())) {
/*
* if source is encrypted and destination is unenecrypted, use destination's sql type to send since there is no way of finding if source is
* encrypted without accessing the resultset.
*
* Send destination type if source resultset set is of type SQLServer, encryption is enabled and destination column is not encrypted
*/
if ((sourceResultSet instanceof SQLServerResultSet) && (connection.isColumnEncryptionSettingEnabled()) && (null != destCryptoMeta)) {
bulkJdbcType = destColumnMetadata.get(destColIndx).jdbcType;
bulkPrecision = destPrecision;
bulkScale = destColumnMetadata.get(destColIndx).scale;
Expand Down

0 comments on commit e99f326

Please sign in to comment.