diff --git a/backend/src/main/java/io/dataease/provider/datasource/JdbcProvider.java b/backend/src/main/java/io/dataease/provider/datasource/JdbcProvider.java index 6f00e03989..df26854263 100644 --- a/backend/src/main/java/io/dataease/provider/datasource/JdbcProvider.java +++ b/backend/src/main/java/io/dataease/provider/datasource/JdbcProvider.java @@ -95,22 +95,30 @@ public class JdbcProvider extends DefaultJdbcProvider { while (resultSet.next()) { String tableName = resultSet.getString("TABLE_NAME"); String database; - if (datasourceRequest.getDatasource().getType().equalsIgnoreCase(DatasourceTypes.ck.name()) || datasourceRequest.getDatasource().getType().equalsIgnoreCase(DatasourceTypes.impala.name())) { + if (datasourceRequest.getDatasource().getType().equalsIgnoreCase(DatasourceTypes.pg.name()) ||datasourceRequest.getDatasource().getType().equalsIgnoreCase(DatasourceTypes.ck.name()) || datasourceRequest.getDatasource().getType().equalsIgnoreCase(DatasourceTypes.impala.name())) { database = resultSet.getString("TABLE_SCHEM"); } else { database = resultSet.getString("TABLE_CAT"); } - if (database != null) { - if (tableName.equals(datasourceRequest.getTable()) && database.equalsIgnoreCase(getDatabase(datasourceRequest))) { - TableField tableField = getTableFiled(resultSet, datasourceRequest); - list.add(tableField); - } - } else { - if (tableName.equals(datasourceRequest.getTable())) { - TableField tableField = getTableFiled(resultSet, datasourceRequest); - list.add(tableField); - } - } + if(datasourceRequest.getDatasource().getType().equalsIgnoreCase(DatasourceTypes.pg.name())){ + if (tableName.equals(datasourceRequest.getTable()) && database.equalsIgnoreCase(getDsSchema(datasourceRequest))) { + TableField tableField = getTableFiled(resultSet, datasourceRequest); + list.add(tableField); + } + }else { + if (database != null) { + if (tableName.equals(datasourceRequest.getTable()) && database.equalsIgnoreCase(getDatabase(datasourceRequest))) { + TableField tableField = getTableFiled(resultSet, datasourceRequest); + list.add(tableField); + } + } else { + if (tableName.equals(datasourceRequest.getTable())) { + TableField tableField = getTableFiled(resultSet, datasourceRequest); + list.add(tableField); + } + } + } + } resultSet.close(); } catch (SQLException e) { @@ -191,6 +199,11 @@ public class JdbcProvider extends DefaultJdbcProvider { } } + private String getDsSchema(DatasourceRequest datasourceRequest) { + JdbcConfiguration jdbcConfiguration = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), JdbcConfiguration.class); + return jdbcConfiguration.getSchema(); + } + @Override public List fetchResultField(DatasourceRequest datasourceRequest) throws Exception { JdbcConfiguration jdbcConfiguration = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), JdbcConfiguration.class);