jdbc up
This commit is contained in:
parent
3cecd33e19
commit
50b7639b73
|
@ -79,6 +79,7 @@ public abstract class AbstractSqlStatementParser implements SqlStatementParser {
|
||||||
return jdbcStatement;
|
return jdbcStatement;
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
log.error("#76 sql parse error, cause=" + e + ", sql=" + sql + ", this=" + this, e);
|
log.error("#76 sql parse error, cause=" + e + ", sql=" + sql + ", this=" + this, e);
|
||||||
|
|
||||||
throw new SQLException("#77 sql parse error, cause=" + e + ", sql=" + sql + ", this=" + this, e);
|
throw new SQLException("#77 sql parse error, cause=" + e + ", sql=" + sql + ", this=" + this, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -376,6 +376,9 @@ public class JSqlParserMongoStatementParser extends AbstractJSqlParserMongoState
|
||||||
}
|
}
|
||||||
|
|
||||||
private JdbcStatement findStatement(String sql, Select select, PlainSelect plainSelect) {
|
private JdbcStatement findStatement(String sql, Select select, PlainSelect plainSelect) {
|
||||||
|
Table fromTable = MongoJSqlParserUtil.getFromTable(select);
|
||||||
|
String collectionName = MongoJSqlParserUtil.getTableName(fromTable);
|
||||||
|
|
||||||
Map<String, Object> statementDocument = new HashMap<String, Object>();
|
Map<String, Object> statementDocument = new HashMap<String, Object>();
|
||||||
|
|
||||||
Map<String, Object> where = this.whereDocument(plainSelect.getWhere());
|
Map<String, Object> where = this.whereDocument(plainSelect.getWhere());
|
||||||
|
@ -388,8 +391,6 @@ public class JSqlParserMongoStatementParser extends AbstractJSqlParserMongoState
|
||||||
MongoFindStatement findStatement = new MongoFindStatement();
|
MongoFindStatement findStatement = new MongoFindStatement();
|
||||||
findStatement.setStatementJson(statementJson);
|
findStatement.setStatementJson(statementJson);
|
||||||
|
|
||||||
Table fromTable = MongoJSqlParserUtil.getFromTable(select);
|
|
||||||
String collectionName = MongoJSqlParserUtil.getTableName(fromTable);
|
|
||||||
findStatement.setCollectionName(collectionName);
|
findStatement.setCollectionName(collectionName);
|
||||||
|
|
||||||
String[] selectColumnNames = MongoJSqlParserUtil.getSelectColumnNames(select);
|
String[] selectColumnNames = MongoJSqlParserUtil.getSelectColumnNames(select);
|
||||||
|
|
|
@ -54,6 +54,10 @@ public class MongoJSqlParserUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static String getTableName(Table table) {
|
protected static String getTableName(Table table) {
|
||||||
|
if (null == table) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
String tableName = table.getName();
|
String tableName = table.getName();
|
||||||
int len = tableName.length();
|
int len = tableName.length();
|
||||||
if (tableName.charAt(0) == '`' && tableName.charAt(len - 1) == '`') {
|
if (tableName.charAt(0) == '`' && tableName.charAt(len - 1) == '`') {
|
||||||
|
@ -205,6 +209,10 @@ public class MongoJSqlParserUtil {
|
||||||
if (selectBody instanceof PlainSelect) {
|
if (selectBody instanceof PlainSelect) {
|
||||||
PlainSelect plainSelect = (PlainSelect) selectBody;
|
PlainSelect plainSelect = (PlainSelect) selectBody;
|
||||||
FromItem fromItem = plainSelect.getFromItem();
|
FromItem fromItem = plainSelect.getFromItem();
|
||||||
|
if (null == fromItem) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if (fromItem instanceof Table) {
|
if (fromItem instanceof Table) {
|
||||||
return (Table) fromItem;
|
return (Table) fromItem;
|
||||||
}
|
}
|
||||||
|
@ -215,7 +223,7 @@ public class MongoJSqlParserUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new BudoJdbcDriverNotSupportedException("#185 statement=" + statement + ", type=" + statement);
|
throw new BudoJdbcDriverNotSupportedException("#185 statement=" + statement + ", type=" + statement.getClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static boolean isFindStatement(PlainSelect plainSelect) {
|
protected static boolean isFindStatement(PlainSelect plainSelect) {
|
||||||
|
|
Loading…
Reference in New Issue