2018-07-02 19:36:09 +08:00
|
|
|
const replaceStrFormIndexArr = require("../utils").replaceStrFormIndexArr;
|
2018-07-05 11:16:30 +08:00
|
|
|
const commentFilter = require('../core/comment');
|
2018-07-02 18:01:01 +08:00
|
|
|
|
2018-07-02 19:36:09 +08:00
|
|
|
/**
|
|
|
|
* 过滤--注释
|
|
|
|
* @param {String} sql
|
|
|
|
*/
|
2018-07-02 18:01:01 +08:00
|
|
|
function filterComments(sql) {
|
2018-07-06 16:22:57 +08:00
|
|
|
return commentFilter.parse(sql).text;
|
2018-07-02 18:01:01 +08:00
|
|
|
}
|
|
|
|
|
2018-07-02 19:36:09 +08:00
|
|
|
/**
|
|
|
|
* 清除注释和前后空格
|
|
|
|
* @param {String} sql
|
|
|
|
*/
|
|
|
|
function cleanSql(sql) {
|
2018-07-05 11:16:30 +08:00
|
|
|
return filterComments(sql);
|
2018-07-02 18:01:01 +08:00
|
|
|
}
|
|
|
|
|
2018-07-02 19:36:09 +08:00
|
|
|
/**
|
|
|
|
* 分割sql
|
|
|
|
* @param {String} sqlText
|
|
|
|
*/
|
|
|
|
function splitSql(sqlText) {
|
2018-07-06 16:22:57 +08:00
|
|
|
return commentFilter.parse(sqlText).lines
|
2018-07-02 19:36:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
exports.filterComments = filterComments;
|
|
|
|
exports.cleanSql = cleanSql;
|
|
|
|
exports.splitSql = splitSql;
|