mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
druid 1.2.0, improved sql parser.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1999-2018 Alibaba Group Holding Ltd.
|
||||
* Copyright 1999-2017 Alibaba Group Holding Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,12 +15,13 @@
|
||||
*/
|
||||
package com.alibaba.druid.sql;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser;
|
||||
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlOutputVisitor;
|
||||
import junit.framework.TestCase;
|
||||
import org.junit.Assert;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MysqlTest extends TestCase {
|
||||
protected String output(List<SQLStatement> stmtList) {
|
||||
@@ -33,13 +34,29 @@ public class MysqlTest extends TestCase {
|
||||
|
||||
return out.toString();
|
||||
}
|
||||
|
||||
protected void print(List<SQLStatement> stmtList) {
|
||||
String text = output(stmtList);
|
||||
String outputProperty = System.getProperty("druid.output");
|
||||
if ("false".equals(outputProperty)) {
|
||||
return;
|
||||
}
|
||||
System.out.println(text);
|
||||
}
|
||||
|
||||
protected void print(List<SQLStatement> stmtList) {
|
||||
String text = output(stmtList);
|
||||
String outputProperty = System.getProperty("druid.output");
|
||||
if ("false".equals(outputProperty)) {
|
||||
return;
|
||||
}
|
||||
System.out.println(text);
|
||||
}
|
||||
|
||||
|
||||
protected void parseTrue(String sql, String except) {
|
||||
SQLStatement statement = SQLUtils.parseSingleMysqlStatement(sql);
|
||||
Assert.assertEquals(except, SQLUtils.toMySqlString(statement));
|
||||
}
|
||||
|
||||
protected SQLStatement parse(String sql) {
|
||||
return SQLUtils.parseSingleMysqlStatement(sql);
|
||||
}
|
||||
|
||||
protected List<SQLStatement> parseList(String sql) {
|
||||
MySqlStatementParser parser = new MySqlStatementParser(sql);
|
||||
return parser.parseStatementList();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user