-
Notifications
You must be signed in to change notification settings - Fork 435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Blackrock: Added QUOTED_IDENTIFIER and CONCAT_NULL_YIELDS_NULL flag in connection #2618
base: main
Are you sure you want to change the base?
Conversation
…in initResettableValues() method to handle it in pooled connection too
src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java
Outdated
Show resolved
Hide resolved
src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java
Outdated
Show resolved
Hide resolved
src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java
Outdated
Show resolved
Hide resolved
… and CONCAT_NULL_YIELDS_NULL
src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there are formatting issues, looks like the formatter wasn't run
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2618 +/- ##
============================================
- Coverage 51.54% 51.53% -0.01%
- Complexity 3996 3997 +1
============================================
Files 147 147
Lines 33694 33756 +62
Branches 5630 5639 +9
============================================
+ Hits 17366 17397 +31
- Misses 13877 13905 +28
- Partials 2451 2454 +3 ☔ View full report in Codecov by Sentry. |
…EFAULTS=ON on LOGIN7 call and CONCAT_NULL_YIELDS_NULL/QUOTED_IDENTIFIER are set ON by default.
…s are not supplied (server default case)
… value for new and pooled connection
@divang please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
ds.setConcatNullYieldsNull("OFF"); | ||
int expectedResultForNewConnection = 0; | ||
// Server default is CONCAT_NULL_YIELDS_NULL = ON | ||
int expectedResultForPooledConnection = 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When we set concat null yields null to OFF, the expected result == 0 for all connections, even pooled connections. If that's not happening, we need to figure out what's not working correctly in the implementation so it can be fixed.
try (Connection con = ds.getConnection(); Statement stmt = con.createStatement()) { | ||
try (ResultSet rs = stmt.executeQuery(sqlSelect)) { | ||
if (rs.next()) { | ||
assertEquals(expectedResultForNewConnection, rs.getInt(1)); | ||
} else { | ||
assertTrue(false, "Expected row of data was not found."); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd extract this out into a helper that takes a Connection object so you don't have to duplicate this code so much.
try (Connection con = pc.getConnection(); Statement statement = con.createStatement()) { | ||
try (ResultSet rs = statement.executeQuery(sqlSelect)) { | ||
if (rs.next()) { | ||
assertEquals(expectedResultForNewConnection, rs.getInt(1)); | ||
} else { | ||
assertTrue(false, "Expected row of data was not found."); | ||
} | ||
} | ||
} | ||
// Repeat getConnection to put the physical connection through a RESETCONNECTION | ||
try (Connection con = pc.getConnection(); Statement statement = con.createStatement()) { | ||
try (ResultSet rs = statement.executeQuery(sqlSelect)) { | ||
if (rs.next()) { | ||
assertEquals(expectedResultForPooledConnection, rs.getInt(1)); | ||
} else { | ||
assertTrue(false, "Expected row of data was not found."); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Indentation for this block needs to be fixed.
* @throws SQLException | ||
*/ | ||
@Test | ||
public void testConcatNullYieldsNull() throws SQLException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
High level: Both of these new tests should also test "ON" for each setting.
Moved the QUOTED_IDENTIFIER and CONCAT_NULL_YIELDS_NULL flag setting in initResettableValues() method to handle the resetting of QUOTED_IDENTIFIER and CONCAT_NULL_YIELDS_NULL flag for both - new and pooled connection.