Skip to content

Commit

Permalink
Revert "Implement checkDuplicateColumnName to check duplicate columns"
Browse files Browse the repository at this point in the history
This reverts commit e77a046.
  • Loading branch information
peterbae committed Sep 27, 2017
1 parent e77a046 commit 8f69956
Showing 1 changed file with 2 additions and 25 deletions.
27 changes: 2 additions & 25 deletions src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,17 @@
import java.time.OffsetDateTime;
import java.time.OffsetTime;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.UUID;

public final class SQLServerDataTable {

int rowCount = 0;
int columnCount = 0;
Map<Integer, SQLServerDataColumn> columnMetadata = null;
Set<String> columnList = null;
Map<Integer, Object[]> rows = null;

private String tvpName = null;
Expand All @@ -40,7 +37,6 @@ public final class SQLServerDataTable {
// Name used in CREATE TYPE
public SQLServerDataTable() throws SQLServerException {
columnMetadata = new LinkedHashMap<>();
columnList = new HashSet<>();
rows = new HashMap<>();
}

Expand Down Expand Up @@ -79,7 +75,7 @@ public synchronized Iterator<Entry<Integer, Object[]>> getIterator() {
public synchronized void addColumnMetadata(String columnName,
int sqlType) throws SQLServerException {
// column names must be unique
checkDuplicateColumnName(columnName);
Util.checkDuplicateColumnName(columnName, columnMetadata);
columnMetadata.put(columnCount++, new SQLServerDataColumn(columnName, sqlType));
}

Expand All @@ -93,29 +89,10 @@ public synchronized void addColumnMetadata(String columnName,
*/
public synchronized void addColumnMetadata(SQLServerDataColumn column) throws SQLServerException {
// column names must be unique
checkDuplicateColumnName(column.columnName);
Util.checkDuplicateColumnName(column.columnName, columnMetadata);
columnMetadata.put(columnCount++, column);
}

/**
* Checks if duplicate columns exists, in O(n) time.
*
* @param columnName
* the name of the column
* @throws SQLServerException
* when a duplicate column exists
*/
private void checkDuplicateColumnName(String columnName) throws SQLServerException {
if (null != columnList) {
//columnList.add will return false if the same column name already exists
if (!columnList.add(columnName)) {
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_TVPDuplicateColumnName"));
Object[] msgArgs = {columnName};
throw new SQLServerException(null, form.format(msgArgs), null, 0, false);
}
}
}

/**
* Adds one row of data to the data table.
*
Expand Down

0 comments on commit 8f69956

Please sign in to comment.