use of com.varsql.core.pattern.convert.SQLCommentRemoveConverter in project varsql by varsqlinfo.
the class VarsqlFormatterUtil method formatResponseResult.
public static ResponseResult formatResponseResult(String sql, DBType dbType, FORMAT_TYPE format_type) {
ResponseResult result = new ResponseResult();
String resultSql = "";
sql = new SQLCommentRemoveConverter().convert(sql, dbType);
if (format_type.equals(FORMAT_TYPE.VARSQL)) {
resultSql = new VarsqlFormatterImpl().execute(sql);
// resultSql = SqlFormatter.format(sql);
} else {
try {
resultSql = com.varsql.core.sql.util.SQLParserUtils.getParserString(sql, dbType);
} catch (Exception e) {
resultSql = new VarsqlFormatterImpl().execute(sql);
result.setMessage(e.getMessage());
}
}
// resultSql = Native2Ascii.asciiToNative(resultSql);
result.setItemOne(resultSql + BlankConstants.NEW_LINE);
return result;
}
use of com.varsql.core.pattern.convert.SQLCommentRemoveConverter in project varsql by varsqlinfo.
the class VarsqlFormatterUtilTest method test.
@Test
void test() {
String ugly_sql_code = getResourceContent("/query/formatTestQuery.txt");
String str = new SQLCommentRemoveConverter().convert(ugly_sql_code, DBType.ORACLE);
String result = VarsqlFormatterUtil.formatResponseResult(str, DBType.OTHER, FORMAT_TYPE.VARSQL).getItem();
System.out.println(result);
}
Aggregations