Skip to content

Commit

Permalink
Reverted defaultFlagSet method. It is not required. Server set ANSI_D…
Browse files Browse the repository at this point in the history
…EFAULTS=ON on LOGIN7 call and CONCAT_NULL_YIELDS_NULL/QUOTED_IDENTIFIER are set ON by default.
  • Loading branch information
Divang Sharma committed Mar 3, 2025
1 parent bb41fb6 commit bfad8d7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,6 @@ public String toString() {
/** flag indicating whether prelogin TLS handshake is required */
private boolean isTDS8 = false;

/** flag to indicating whether QUOTED_IDENTIFIER is ON/OFF */
private OnOffOption isQuotedIdentifierOn = OnOffOption.NOT_SET;

/** flag to indicating whether CONCAT_NULL_YIELDS_NULL is ON/OFF */
private OnOffOption isConcatNullYieldsNullOn = OnOffOption.NOT_SET;

/** encrypted truststore password */
byte[] encryptedTrustStorePassword = null;

Expand Down Expand Up @@ -1819,20 +1813,6 @@ final void setMaxFieldSize(int limit) throws SQLServerException {
}
}

private void setCustomFlags() {
try{
if (!isQuotedIdentifierOn.equals(OnOffOption.NOT_SET)) {
connectionCommand("SET QUOTED_IDENTIFIER " + isQuotedIdentifierOn, "quotedIdentifier");
}

if (!isConcatNullYieldsNullOn.equals(OnOffOption.NOT_SET)) {
connectionCommand("SET CONCAT_NULL_YIELDS_NULL " + isConcatNullYieldsNullOn, "concatNullYieldsNull");
}
} catch(SQLServerException e) {
loggerExternal.log(Level.WARNING, "Error setting QUOTED_IDENTIFIER and CONCAT_NULL_YIELDS_NULL properties", e);
}
}

/**
* This function is used both to init the values on creation of connection and resetting the values after the
* connection is released to the pool for reuse.
Expand All @@ -1848,7 +1828,6 @@ final void initResettableValues() {
sqlWarnings = null;
sCatalog = originalCatalog;
databaseMetaData = null;
setCustomFlags();
}

/** Limit for the maximum number of rows returned from queries on this connection */
Expand Down Expand Up @@ -3556,9 +3535,9 @@ else if (0 == requestedPacketSize)
activeConnectionProperties.setProperty(quotedIdentifierProperty, quotedIdentifierValue);
}

isQuotedIdentifierOn = OnOffOption.valueOfString(quotedIdentifierValue);
if (!isQuotedIdentifierOn.equals(OnOffOption.NOT_SET)) {
connectionCommand("SET QUOTED_IDENTIFIER " + isQuotedIdentifierOn, "quotedIdentifier");
String quotedIdentifierOption = OnOffOption.valueOfString(quotedIdentifierValue).toString();
if (quotedIdentifierOption.compareToIgnoreCase(OnOffOption.OFF.toString()) == 0) {
connectionCommand("SET QUOTED_IDENTIFIER OFF", "quotedIdentifier");

Check warning on line 3540 in src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java#L3540

Added line #L3540 was not covered by tests
}

// check CONCAT_NULL_YIELDS_NULL property
Expand All @@ -3568,9 +3547,10 @@ else if (0 == requestedPacketSize)
concatNullYieldsNullValue = SQLServerDriverStringProperty.CONCAT_NULL_YIELDS_NULL.getDefaultValue();
activeConnectionProperties.setProperty(concatNullYieldsNullProperty, concatNullYieldsNullValue);
}
isConcatNullYieldsNullOn = OnOffOption.valueOfString(concatNullYieldsNullValue);
if (!isConcatNullYieldsNullOn.equals(OnOffOption.NOT_SET)) {
connectionCommand("SET CONCAT_NULL_YIELDS_NULL " + isConcatNullYieldsNullOn, "concatNullYieldsNull");

String concatNullYieldsOption = OnOffOption.valueOfString(concatNullYieldsNullValue).toString();
if (concatNullYieldsOption.compareToIgnoreCase(OnOffOption.OFF.toString()) == 0) {
connectionCommand("SET CONCAT_NULL_YIELDS_NULL OFF", "concatNullYields");

Check warning on line 3553 in src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java#L3553

Added line #L3553 was not covered by tests
}

// Socket timeout is bounded by loginTimeout during the login phase.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -613,8 +613,8 @@ enum SQLServerDriverStringProperty {
ACCESS_TOKEN_CALLBACK_CLASS("accessTokenCallbackClass", ""),
RETRY_EXEC("retryExec", ""),
RETRY_CONN("retryConn", ""),
QUOTED_IDENTIFIER("quotedIdentifier", OnOffOption.NOT_SET.toString()),
CONCAT_NULL_YIELDS_NULL("concatNullYieldsNull", OnOffOption.NOT_SET.toString());
QUOTED_IDENTIFIER("quotedIdentifier", OnOffOption.ON.toString()),
CONCAT_NULL_YIELDS_NULL("concatNullYieldsNull", OnOffOption.ON.toString());

private final String name;
private final String defaultValue;
Expand Down Expand Up @@ -732,8 +732,7 @@ public String toString() {

enum OnOffOption {
ON("ON"),
OFF("OFF"),
NOT_SET("NOT_SET");
OFF("OFF");

private final String option;

Expand All @@ -753,8 +752,6 @@ static OnOffOption valueOfString(String value) throws SQLServerException {
option = OnOffOption.ON;
} else if (value.toLowerCase(Locale.US).equalsIgnoreCase(OnOffOption.OFF.toString())) {
option = OnOffOption.OFF;

Check warning on line 754 in src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDriver.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDriver.java#L754

Added line #L754 was not covered by tests
} else if (value.toLowerCase(Locale.US).equalsIgnoreCase(OnOffOption.NOT_SET.toString())) {
option = OnOffOption.NOT_SET;
} else {
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_InvalidConnectionSetting"));
Object[] msgArgs = {"OnOffOption", value};
Expand Down

0 comments on commit bfad8d7

Please sign in to comment.