Merge pull request #3479 from dataease/pr@dev@dataset

fix(数据源): mysql8 获取表字段为空
This commit is contained in:
王嘉豪 2022-10-27 13:40:08 +08:00 committed by GitHub
commit 7cc0fa5823
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -90,8 +90,10 @@ public class JdbcProvider extends DefaultJdbcProvider {
DatabaseMetaData databaseMetaData = connection.getMetaData(); DatabaseMetaData databaseMetaData = connection.getMetaData();
String tableNamePattern = datasourceRequest.getTable(); String tableNamePattern = datasourceRequest.getTable();
if(datasourceRequest.getDatasource().getType().equalsIgnoreCase(DatasourceTypes.mysql.name())){ if(datasourceRequest.getDatasource().getType().equalsIgnoreCase(DatasourceTypes.mysql.name())){
if(databaseMetaData.getDriverMajorVersion() < 8){
tableNamePattern = String.format(MySQLConstants.KEYWORD_TABLE, tableNamePattern); tableNamePattern = String.format(MySQLConstants.KEYWORD_TABLE, tableNamePattern);
} }
}
ResultSet resultSet = databaseMetaData.getColumns(null, "%", tableNamePattern, "%"); ResultSet resultSet = databaseMetaData.getColumns(null, "%", tableNamePattern, "%");
while (resultSet.next()) { while (resultSet.next()) {
String tableName = resultSet.getString("TABLE_NAME"); String tableName = resultSet.getString("TABLE_NAME");