mirror of
https://github.com/CodePhiliaX/Chat2DB.git
synced 2025-08-02 13:34:07 +08:00
Merge pull request #1223 from openai0229/fix-mysql-view-ddl-query
fix-mysql-view-ddl-query
This commit is contained in:
@ -214,21 +214,18 @@ public class MysqlMetaData extends DefaultMetaService implements MetaData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String VIEW_DDL_SQL="show create view %s";
|
||||||
private static String VIEW_SQL
|
|
||||||
= "SELECT TABLE_SCHEMA AS DatabaseName, TABLE_NAME AS ViewName, VIEW_DEFINITION AS definition, CHECK_OPTION, "
|
|
||||||
+ "IS_UPDATABLE FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_SCHEMA = '%s' AND TABLE_NAME = '%s';";
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Table view(Connection connection, String databaseName, String schemaName, String viewName) {
|
public Table view(Connection connection, String databaseName, String schemaName, String viewName) {
|
||||||
String sql = String.format(VIEW_SQL, databaseName, viewName);
|
String sql = String.format(VIEW_DDL_SQL, viewName);
|
||||||
return SQLExecutor.getInstance().execute(connection, sql, resultSet -> {
|
return SQLExecutor.getInstance().execute(connection, sql, resultSet -> {
|
||||||
Table table = new Table();
|
Table table = new Table();
|
||||||
table.setDatabaseName(databaseName);
|
table.setDatabaseName(databaseName);
|
||||||
table.setSchemaName(schemaName);
|
table.setSchemaName(schemaName);
|
||||||
table.setName(viewName);
|
table.setName(viewName);
|
||||||
if (resultSet.next()) {
|
if (resultSet.next()) {
|
||||||
table.setDdl(resultSet.getString("definition"));
|
table.setDdl(resultSet.getString("Create View"));
|
||||||
}
|
}
|
||||||
return table;
|
return table;
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user