Skip to content

Commit

Permalink
Merge pull request deegree#1644 from lat-lon/fix/tableNameWithSchemaI…
Browse files Browse the repository at this point in the history
…nIndex

Added schema to table name to create the index
  • Loading branch information
copierrj authored Apr 10, 2024
2 parents 176063e + 2640cb4 commit 6abc0e8
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,24 +126,31 @@ private List<StringBuffer> getGeometryCreate(GeometryMapping mapping, DBField db
List<StringBuffer> ddls = new ArrayList<StringBuffer>();
StringBuffer sql = new StringBuffer();
String schema = table.getSchema() == null ? "" : table.getSchema();
String tableName = table.getTable();
String column = dbField.getColumn();
String srid = mapping.getSrid();
// TODO
String geometryType = "GEOMETRY";
int dim = 2;
sql.append("SELECT ADDGEOMETRYCOLUMN('" + schema.toLowerCase() + "', '" + table.getTable().toLowerCase() + "','"
sql.append("SELECT ADDGEOMETRYCOLUMN('" + schema.toLowerCase() + "', '" + tableName.toLowerCase() + "','"
+ column + "','" + srid + "','" + geometryType + "', " + dim + ")");
ddls.add(sql);

StringBuffer indexSql = new StringBuffer("CREATE INDEX ");
String idxName = createIdxName(table.getTable(), column);
String idxName = createIdxName(tableName, column);
indexSql.append(idxName);
indexSql.append(" ON ").append(table.getTable().toLowerCase());
indexSql.append(" ON ").append(createQualifiedTableName(schema, tableName).toLowerCase());
indexSql.append(" USING GIST (").append(column).append(" ); ");
ddls.add(indexSql);
return ddls;
}

public String createQualifiedTableName(String schema, String table) {
if (schema == null)
return table;
return schema + "." + table;
}

@Override
protected void primitiveMappingSnippet(StringBuffer sql, PrimitiveMapping mapping) {
MappingExpression me = mapping.getMapping();
Expand Down

0 comments on commit 6abc0e8

Please sign in to comment.