Skip to content

Commit

Permalink
SNOW-1050447: Cleanup schemas in testGetProcedureColumnsWildcards (#1641
Browse files Browse the repository at this point in the history
)
  • Loading branch information
sfc-gh-dprzybysz authored Feb 16, 2024
1 parent 99ce7d4 commit 1a993a8
Showing 1 changed file with 23 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -389,27 +389,36 @@ public void testGetFunctionSqlInjectionProtection() throws Throwable {
* @throws SQLException
*/
@Test
public void testGetProcedureColumnsWildcards() throws SQLException {
public void testGetProcedureColumnsWildcards() throws Exception {
try (Connection con = getConnection();
Statement statement = con.createStatement()) {
String database = con.getCatalog();
String schemaPrefix =
TestUtil.GENERATED_SCHEMA_PREFIX + SnowflakeUtil.randomAlphaNumeric(5).toUpperCase();
String schema1 = schemaPrefix + "SCH1";
String schema2 = schemaPrefix + "SCH2";
// Create 2 schemas, each with the same stored procedure declared in them
statement.execute("create or replace schema " + schema1);
statement.execute(TEST_PROC);
statement.execute("create or replace schema " + schema2);
statement.execute(TEST_PROC);
DatabaseMetaData metaData = con.getMetaData();
try (ResultSet rs =
metaData.getProcedureColumns(database, schemaPrefix + "SCH_", "TESTPROC", "PARAM1")) {
// Assert 4 rows returned for the param PARAM1 that's present in each of the 2 identical
// stored procs in different schemas. A result row is returned for each procedure, making
// the total rowcount 4
assertEquals(4, getSizeOfResultSet(rs));
}
TestUtil.withSchema(
statement,
schema1,
() -> {
statement.execute(TEST_PROC);
TestUtil.withSchema(
statement,
schema2,
() -> {
statement.execute(TEST_PROC);
// Create 2 schemas, each with the same stored procedure declared in them
DatabaseMetaData metaData = con.getMetaData();
try (ResultSet rs =
metaData.getProcedureColumns(
database, schemaPrefix + "SCH_", "TESTPROC", "PARAM1")) {
// Assert 4 rows returned for the param PARAM1 that's present in each of the 2
// identical stored procs in different schemas. A result row is returned for
// each procedure, making the total rowcount 4
assertEquals(4, getSizeOfResultSet(rs));
}
});
});
}
}

Expand Down

0 comments on commit 1a993a8

Please sign in to comment.