Skip to content

Commit

Permalink
Order results from getColumns (#1348)
Browse files Browse the repository at this point in the history
  • Loading branch information
lilgreenbird authored Jun 11, 2020
1 parent 1637fed commit c2f48fb
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ enum CallableHandles {
SP_STORED_PROCEDURES("{call sp_stored_procedures(?, ?, ?) }", "{call sp_stored_procedures(?, ?, ?) }"),
SP_TABLE_PRIVILEGES("{call sp_table_privileges(?,?,?) }", "{call sp_table_privileges(?,?,?) }"),
SP_PKEYS("{ call sp_pkeys (?, ?, ?)}", "{ call sp_pkeys (?, ?, ?)}");

// stored procs before Katmai ie SS10
private final String preKatProc;
// procs on or after katmai
Expand Down Expand Up @@ -637,7 +638,7 @@ public java.sql.ResultSet getColumns(String catalog, String schema, String table
+ "CASE SS_IS_COMPUTED WHEN 0 THEN 'NO' WHEN 1 THEN 'YES' WHEN '' THEN '' END AS IS_GENERATEDCOLUMN, "
+ "SS_IS_SPARSE, SS_IS_COLUMN_SET, SS_UDT_CATALOG_NAME, SS_UDT_SCHEMA_NAME, SS_UDT_ASSEMBLY_TYPE_NAME,"
+ "SS_XML_SCHEMACOLLECTION_CATALOG_NAME, SS_XML_SCHEMACOLLECTION_SCHEMA_NAME, SS_XML_SCHEMACOLLECTION_NAME "
+ "FROM @mssqljdbc_temp_sp_columns_result;";
+ "FROM @mssqljdbc_temp_sp_columns_result ORDER BY TABLE_CAT, TABLE_SCHEM, TABLE_NAME, ORDINAL_POSITION;";
SQLServerResultSet rs = null;
PreparedStatement pstmt = (SQLServerPreparedStatement) this.connection.prepareStatement(spColumnsSql);
pstmt.closeOnCompletion();
Expand Down Expand Up @@ -746,7 +747,10 @@ public java.sql.ResultSet getColumns(String catalog, String schema, String table

if (0 == azureDwSelectBuilder.length()) {
azureDwSelectBuilder.append(generateAzureDWEmptyRS(getColumnsDWColumns));
} else {
azureDwSelectBuilder.append(" ORDER BY TABLE_CAT, TABLE_SCHEM, TABLE_NAME, ORDINAL_POSITION ");
}

resultPstmt = (SQLServerPreparedStatement) this.connection
.prepareStatement(azureDwSelectBuilder.toString());
userRs = (SQLServerResultSet) resultPstmt.executeQuery();
Expand Down Expand Up @@ -1040,7 +1044,8 @@ private ResultSet executeSPFkeys(String[] procParams) throws SQLException, SQLTi
"END as UPDATE_RULE, " + "CASE s.delete_referential_action " + "WHEN 1 THEN 0 " + "WHEN 0 THEN 3 "
+ "WHEN 2 THEN 2 " + "WHEN 3 THEN 4 " + "END as DELETE_RULE, " + "t.FK_NAME, " + "t.PK_NAME, "
+ "t.DEFERRABILITY " + "FROM " + tempTableName + " t "
+ "LEFT JOIN sys.foreign_keys s ON t.FK_NAME = s.name COLLATE database_default AND schema_id(t.FKTABLE_OWNER) = s.schema_id";
+ "LEFT JOIN sys.foreign_keys s ON t.FK_NAME = s.name COLLATE database_default AND schema_id(t.FKTABLE_OWNER) = s.schema_id "
+ "ORDER BY PKTABLE_CAT, PKTABLE_SCHEM, PKTABLE_NAME, KEY_SEQ";
SQLServerCallableStatement cstmt = (SQLServerCallableStatement) connection.prepareCall(sql);
cstmt.closeOnCompletion();
for (int i = 0; i < 6; i++) {
Expand Down

0 comments on commit c2f48fb

Please sign in to comment.