Skip to content

Commit

Permalink
#497 - change alias generation
Browse files Browse the repository at this point in the history
  • Loading branch information
grabdoc committed Apr 27, 2024
1 parent d81bb24 commit 8a70503
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/main/java/com/homihq/db2rest/jdbc/JdbcSchemaCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ public DbTable getTable(String schemaName, String tableName) {

DbTable table = this.dbTableMap.get(tableName);

log.info("Table retrieved - {}", table);

if(Objects.isNull(table)) throw new InvalidTableException(tableName);

return table;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static String getAlias(String sqlIdentifier) {
return
sqlIdentifier.length() > LENGTH ?
sqlIdentifier.substring(0, LENGTH) + "_" +random.nextInt(100)
: sqlIdentifier + "_" +random.nextInt(100);
: sqlIdentifier + "_" +random.nextInt(1000);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ public void process(ReadContext readContext) {

String tableName = joinDetail.table();
DbTable table = jdbcSchemaCache.getTable(readContext.getSchemaName(), tableName);


table = table.copyWithAlias(getAlias(tableName));

List<DbColumn> columnList = addColumns(table, joinDetail.fields());
readContext.addColumns(columnList);
addJoin(table, rootTable, joinDetail, readContext);
Expand Down

0 comments on commit 8a70503

Please sign in to comment.