|
@@ -26,11 +26,11 @@ public abstract class JsqlParserSupport {
|
|
|
|
|
|
public String parserSingle(String sql, Object obj) {
|
|
public String parserSingle(String sql, Object obj) {
|
|
if (logger.isDebugEnabled()) {
|
|
if (logger.isDebugEnabled()) {
|
|
- logger.debug("Original SQL: " + sql);
|
|
|
|
|
|
+ logger.debug("original SQL: " + sql);
|
|
}
|
|
}
|
|
try {
|
|
try {
|
|
Statement statement = CCJSqlParserUtil.parse(sql);
|
|
Statement statement = CCJSqlParserUtil.parse(sql);
|
|
- return processParser(statement, 0, obj);
|
|
|
|
|
|
+ return processParser(statement, 0, sql, obj);
|
|
} catch (JSQLParserException e) {
|
|
} catch (JSQLParserException e) {
|
|
throw ExceptionUtils.mpe("Failed to process, Error SQL: %s", e, sql);
|
|
throw ExceptionUtils.mpe("Failed to process, Error SQL: %s", e, sql);
|
|
}
|
|
}
|
|
@@ -38,7 +38,7 @@ public abstract class JsqlParserSupport {
|
|
|
|
|
|
public String parserMulti(String sql, Object obj) {
|
|
public String parserMulti(String sql, Object obj) {
|
|
if (logger.isDebugEnabled()) {
|
|
if (logger.isDebugEnabled()) {
|
|
- logger.debug("Original SQL: " + sql);
|
|
|
|
|
|
+ logger.debug("original SQL: " + sql);
|
|
}
|
|
}
|
|
try {
|
|
try {
|
|
// fixed github pull/295
|
|
// fixed github pull/295
|
|
@@ -49,7 +49,7 @@ public abstract class JsqlParserSupport {
|
|
if (i > 0) {
|
|
if (i > 0) {
|
|
sb.append(StringPool.SEMICOLON);
|
|
sb.append(StringPool.SEMICOLON);
|
|
}
|
|
}
|
|
- sb.append(processParser(statement, i, obj));
|
|
|
|
|
|
+ sb.append(processParser(statement, i, sql, obj));
|
|
i++;
|
|
i++;
|
|
}
|
|
}
|
|
return sb.toString();
|
|
return sb.toString();
|
|
@@ -64,19 +64,22 @@ public abstract class JsqlParserSupport {
|
|
* @param statement JsqlParser Statement
|
|
* @param statement JsqlParser Statement
|
|
* @return sql
|
|
* @return sql
|
|
*/
|
|
*/
|
|
- protected String processParser(Statement statement, int index, Object obj) {
|
|
|
|
|
|
+ protected String processParser(Statement statement, int index, String sql, Object obj) {
|
|
|
|
+ if (logger.isDebugEnabled()) {
|
|
|
|
+ logger.debug("SQL to parse, SQL: " + sql);
|
|
|
|
+ }
|
|
if (statement instanceof Insert) {
|
|
if (statement instanceof Insert) {
|
|
- this.processInsert((Insert) statement, index, obj);
|
|
|
|
|
|
+ this.processInsert((Insert) statement, index, sql, obj);
|
|
} else if (statement instanceof Select) {
|
|
} else if (statement instanceof Select) {
|
|
- this.processSelect((Select) statement, index, obj);
|
|
|
|
|
|
+ this.processSelect((Select) statement, index, sql, obj);
|
|
} else if (statement instanceof Update) {
|
|
} else if (statement instanceof Update) {
|
|
- this.processUpdate((Update) statement, index, obj);
|
|
|
|
|
|
+ this.processUpdate((Update) statement, index, sql, obj);
|
|
} else if (statement instanceof Delete) {
|
|
} else if (statement instanceof Delete) {
|
|
- this.processDelete((Delete) statement, index, obj);
|
|
|
|
|
|
+ this.processDelete((Delete) statement, index, sql, obj);
|
|
}
|
|
}
|
|
- final String sql = statement.toString();
|
|
|
|
|
|
+ sql = statement.toString();
|
|
if (logger.isDebugEnabled()) {
|
|
if (logger.isDebugEnabled()) {
|
|
- logger.debug("parser sql: " + sql);
|
|
|
|
|
|
+ logger.debug("parse the finished SQL: " + sql);
|
|
}
|
|
}
|
|
return sql;
|
|
return sql;
|
|
}
|
|
}
|
|
@@ -84,28 +87,28 @@ public abstract class JsqlParserSupport {
|
|
/**
|
|
/**
|
|
* 新增
|
|
* 新增
|
|
*/
|
|
*/
|
|
- protected void processInsert(Insert insert, int index, Object obj) {
|
|
|
|
|
|
+ protected void processInsert(Insert insert, int index, String sql, Object obj) {
|
|
throw new UnsupportedOperationException();
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 删除
|
|
* 删除
|
|
*/
|
|
*/
|
|
- protected void processDelete(Delete delete, int index, Object obj) {
|
|
|
|
|
|
+ protected void processDelete(Delete delete, int index, String sql, Object obj) {
|
|
throw new UnsupportedOperationException();
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 更新
|
|
* 更新
|
|
*/
|
|
*/
|
|
- protected void processUpdate(Update update, int index, Object obj) {
|
|
|
|
|
|
+ protected void processUpdate(Update update, int index, String sql, Object obj) {
|
|
throw new UnsupportedOperationException();
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 查询
|
|
* 查询
|
|
*/
|
|
*/
|
|
- protected void processSelect(Select select, int index, Object obj) {
|
|
|
|
|
|
+ protected void processSelect(Select select, int index, String sql, Object obj) {
|
|
throw new UnsupportedOperationException();
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
}
|
|
}
|
|
}
|