(improvement)(headless) Compatible with semicolon after SQL when creating model by sql #1654 (#1673)

* (improvement)(headless) Compatible with semicolon after SQL when creating model by sql #1654

* (improvement)(headless) Compatible with semicolon after SQL when creating model by sql

---------

Co-authored-by: lxwcodemonkey
This commit is contained in:
LXW
2024-09-14 14:30:23 +08:00
committed by GitHub
parent 4e1b2e3dfe
commit 19f9e15521

View File

@@ -186,6 +186,9 @@ public class DatabaseServiceImpl extends ServiceImpl<DatabaseDOMapper, DatabaseD
@Override
public List<DBColumn> getColumns(Long id, String sql) throws SQLException {
if (sql.endsWith(";")) {
sql = sql.substring(0, sql.length() - 1);
}
String wrapSql = String.format("select * from (%s) a limit 1", sql);
DatabaseResp databaseResp = getDatabase(id);
SemanticQueryResp semanticQueryResp = executeSql(wrapSql, databaseResp);