mirror of
https://gitee.com/dromara/dbswitch.git
synced 2025-10-15 06:10:23 +00:00
修正issue:IAFCGH
This commit is contained in:
@@ -18,8 +18,8 @@ import com.gitee.dbswitch.schema.ColumnDescription;
|
||||
import com.gitee.dbswitch.schema.ColumnMetaData;
|
||||
import com.gitee.dbswitch.schema.IndexDescription;
|
||||
import com.gitee.dbswitch.schema.IndexFieldMeta;
|
||||
import com.gitee.dbswitch.schema.TableDescription;
|
||||
import com.gitee.dbswitch.schema.SourceProperties;
|
||||
import com.gitee.dbswitch.schema.TableDescription;
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.ResultSetMetaData;
|
||||
@@ -48,6 +48,8 @@ public abstract class AbstractMetadataProvider
|
||||
extends AbstractCommonProvider
|
||||
implements MetadataProvider {
|
||||
|
||||
protected static final String[] TABLE_TYPES = new String[]{"TABLE", "VIEW", "PARTITIONED TABLE"};
|
||||
|
||||
protected String catalogName = null;
|
||||
|
||||
protected AbstractMetadataProvider(ProductFactoryProvider factoryProvider) {
|
||||
@@ -75,9 +77,8 @@ public abstract class AbstractMetadataProvider
|
||||
public List<TableDescription> queryTableList(Connection connection, String schemaName) {
|
||||
List<TableDescription> ret = new ArrayList<>();
|
||||
Set<String> uniqueSet = new LinkedHashSet<>();
|
||||
String[] types = new String[]{"TABLE", "VIEW"};
|
||||
try (ResultSet tables = connection.getMetaData()
|
||||
.getTables(catalogName, schemaName, "%", types)) {
|
||||
.getTables(catalogName, schemaName, "%", TABLE_TYPES)) {
|
||||
while (tables.next()) {
|
||||
String tableName = tables.getString("TABLE_NAME");
|
||||
if (uniqueSet.contains(tableName)) {
|
||||
@@ -103,7 +104,7 @@ public abstract class AbstractMetadataProvider
|
||||
public TableDescription queryTableMeta(Connection connection, String schemaName,
|
||||
String tableName) {
|
||||
try (ResultSet tables = connection.getMetaData()
|
||||
.getTables(catalogName, schemaName, tableName, new String[]{"TABLE", "VIEW"})) {
|
||||
.getTables(catalogName, schemaName, tableName, TABLE_TYPES)) {
|
||||
if (tables.next()) {
|
||||
TableDescription td = new TableDescription();
|
||||
td.setSchemaName(schemaName);
|
||||
|
@@ -52,6 +52,9 @@ public class TableDescription {
|
||||
}
|
||||
|
||||
public void setTableType(String tableType) {
|
||||
if ("PARTITIONED TABLE".equals(tableType)) {
|
||||
tableType = "TABLE";
|
||||
}
|
||||
this.tableType = ProductTableEnum.valueOf(tableType.toUpperCase());
|
||||
}
|
||||
|
||||
|
@@ -79,7 +79,8 @@ public class PostgresMetadataQueryProvider extends AbstractMetadataProvider {
|
||||
}
|
||||
|
||||
// 低版本的PostgreSQL的表的DDL获取方法
|
||||
return PostgresUtils.getTableDDL(this, connection, schemaName, tableName);
|
||||
String ddlSql = PostgresUtils.getTableDDL(this, connection, schemaName, tableName);
|
||||
return DDLFormatterUtils.format(ddlSql);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user