mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-14 22:25:19 +00:00
(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:
@@ -186,6 +186,9 @@ public class DatabaseServiceImpl extends ServiceImpl<DatabaseDOMapper, DatabaseD
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DBColumn> getColumns(Long id, String sql) throws SQLException {
|
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);
|
String wrapSql = String.format("select * from (%s) a limit 1", sql);
|
||||||
DatabaseResp databaseResp = getDatabase(id);
|
DatabaseResp databaseResp = getDatabase(id);
|
||||||
SemanticQueryResp semanticQueryResp = executeSql(wrapSql, databaseResp);
|
SemanticQueryResp semanticQueryResp = executeSql(wrapSql, databaseResp);
|
||||||
|
|||||||
Reference in New Issue
Block a user