Skip to content

Commit

Permalink
Ran formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeffery-Wasty committed Mar 5, 2025
1 parent 197ca95 commit 81c8682
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 39 deletions.
21 changes: 10 additions & 11 deletions src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
import java.math.BigDecimal;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.sql.Connection;
import java.sql.Date;
import java.sql.ResultSet;
Expand Down Expand Up @@ -1765,16 +1763,16 @@ private void getDestinationMetadata() throws SQLServerException {
}

if (loggerExternal.isLoggable(Level.FINER)) {
loggerExternal.finer(this.toString() + " Acquiring existing destination column metadata " +
"from cache for bulk copy");
loggerExternal.finer(this.toString() + " Acquiring existing destination column metadata "
+ "from cache for bulk copy");
}

} else {
setDestinationColumnMetadata(escapedDestinationTableName);

if (loggerExternal.isLoggable(Level.FINER)) {
loggerExternal.finer(this.toString() + " cacheBulkCopyMetadata=false - Querying server " +
"for destination column metadata");
loggerExternal.finer(this.toString() + " cacheBulkCopyMetadata=false - Querying server "
+ "for destination column metadata");
}
}
}
Expand Down Expand Up @@ -2129,7 +2127,8 @@ private void writeNullToTdsWriter(TDSWriter tdsWriter, int srcJdbcType,

private void writeColumnToTdsWriter(TDSWriter tdsWriter, int bulkPrecision, int bulkScale, int bulkJdbcType,
boolean bulkNullable, // should it be destNullable instead?
int srcColOrdinal, int destColOrdinal, boolean isStreaming, Object colValue, Calendar cal) throws SQLServerException {
int srcColOrdinal, int destColOrdinal, boolean isStreaming, Object colValue,
Calendar cal) throws SQLServerException {
SSType destSSType = destColumnMetadata.get(destColOrdinal).ssType;

bulkPrecision = validateSourcePrecision(bulkPrecision, bulkJdbcType,
Expand Down Expand Up @@ -3046,8 +3045,8 @@ private Object readColumnFromResultSet(int srcColOrdinal, int srcJdbcType, boole
/**
* Reads the given column from the result set current row and writes the data to tdsWriter.
*/
private void writeColumn(TDSWriter tdsWriter, int srcColOrdinal, int destColOrdinal,
Object colValue, Calendar cal) throws SQLServerException {
private void writeColumn(TDSWriter tdsWriter, int srcColOrdinal, int destColOrdinal, Object colValue,
Calendar cal) throws SQLServerException {
String destName = destColumnMetadata.get(destColOrdinal).columnName;
int srcPrecision, srcScale, destPrecision, srcJdbcType;
SSType destSSType = null;
Expand Down Expand Up @@ -3699,8 +3698,8 @@ private boolean writeBatchData(TDSWriter tdsWriter, TDSCommand command,
// Loop for each destination column. The mappings is a many to one mapping
// where multiple source columns can be mapped to one destination column.
for (ColumnMapping columnMapping : columnMappings) {
writeColumn(tdsWriter, columnMapping.sourceColumnOrdinal, columnMapping.destinationColumnOrdinal, null,
null // cell
writeColumn(tdsWriter, columnMapping.sourceColumnOrdinal, columnMapping.destinationColumnOrdinal,
null, null // cell
// value is
// retrieved
// inside
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
package com.microsoft.sqlserver.jdbc.bulkCopy;

import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

Expand All @@ -14,7 +13,6 @@
import java.io.FileReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.StackOverflowError;
import java.net.URL;
import java.sql.Connection;
import java.sql.ResultSet;
Expand Down Expand Up @@ -265,7 +263,7 @@ public void testEscapeColumnDelimitersCSVNoNewLineAtEnd() throws Exception {
}
}
}

/**
* test simple csv file for bulkcopy, for GitHub issue 1391 Tests to ensure that the set returned by
* getColumnOrdinals doesn't have to be ordered
Expand Down Expand Up @@ -459,19 +457,13 @@ public void testBulkCopyWithComputedColumnAsLastColumn() {
String tableName = AbstractSQLGenerator.escapeIdentifier(RandomUtil.getIdentifier("BulkEscape"));
String fileName = filePath + computeColumnCsvFile;

try (Connection con = getConnection();
Statement stmt = con.createStatement();
try (Connection con = getConnection(); Statement stmt = con.createStatement();
SQLServerBulkCopy bulkCopy = new SQLServerBulkCopy(con);
SQLServerBulkCSVFileRecord fileRecord = new SQLServerBulkCSVFileRecord(fileName, encoding, ",",
true)) {

String createTableSQL = "CREATE TABLE " + tableName + " (" +
"[NAME] varchar(50) NOT NULL," +
"[AGE] int NULL," +
"[CAL_COL] numeric(17, 2) NULL," +
"[ORIGINAL] varchar(50) NOT NULL," +
"[COMPUTED_COL] AS (right([NAME], 8)) PERSISTED" +
")";
SQLServerBulkCSVFileRecord fileRecord = new SQLServerBulkCSVFileRecord(fileName, encoding, ",", true)) {

String createTableSQL = "CREATE TABLE " + tableName + " (" + "[NAME] varchar(50) NOT NULL,"
+ "[AGE] int NULL," + "[CAL_COL] numeric(17, 2) NULL," + "[ORIGINAL] varchar(50) NOT NULL,"
+ "[COMPUTED_COL] AS (right([NAME], 8)) PERSISTED" + ")";
stmt.executeUpdate(createTableSQL);

fileRecord.addColumnMetadata(1, "NAME", java.sql.Types.VARCHAR, 50, 0);
Expand Down Expand Up @@ -515,20 +507,13 @@ public void testBulkCopyWithComputedColumnNotAsLastColumn() {
String tableName = AbstractSQLGenerator.escapeIdentifier(RandomUtil.getIdentifier("BulkEscape"));
String fileName = filePath + computeColumnCsvFile;

try (Connection con = getConnection();
Statement stmt = con.createStatement();
try (Connection con = getConnection(); Statement stmt = con.createStatement();
SQLServerBulkCopy bulkCopy = new SQLServerBulkCopy(con);
SQLServerBulkCSVFileRecord fileRecord = new SQLServerBulkCSVFileRecord(fileName, encoding, ",",
true)) {

String createTableSQL = "CREATE TABLE " + tableName + " (" +
"[NAME] varchar(50) NOT NULL," +
"[AGE] int NULL," +
"[CAL_COL] numeric(17, 2) NULL," +
"[ORIGINAL] varchar(50) NOT NULL," +
"[COMPUTED_COL] AS (right([NAME], 8)) PERSISTED," +
"[LAST_COL] varchar(50) NULL" +
")";
SQLServerBulkCSVFileRecord fileRecord = new SQLServerBulkCSVFileRecord(fileName, encoding, ",", true)) {

String createTableSQL = "CREATE TABLE " + tableName + " (" + "[NAME] varchar(50) NOT NULL,"
+ "[AGE] int NULL," + "[CAL_COL] numeric(17, 2) NULL," + "[ORIGINAL] varchar(50) NOT NULL,"
+ "[COMPUTED_COL] AS (right([NAME], 8)) PERSISTED," + "[LAST_COL] varchar(50) NULL" + ")";
stmt.executeUpdate(createTableSQL);

fileRecord.addColumnMetadata(1, "NAME", java.sql.Types.VARCHAR, 50, 0);
Expand Down

0 comments on commit 81c8682

Please sign in to comment.