mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
添加postgresql的begin,commit,set命令解析
添加PGStatement的测试代码,修复PGStatement解析bug;修复pg无法识别table别名问题 将PG的关键字移入TOKEN中 start transaction的visit优化
This commit is contained in:
@@ -17,10 +17,12 @@ package com.alibaba.druid.sql;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.druid.sql.dialect.postgresql.parser.PGSQLStatementParser;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLStatement;
|
||||
import com.alibaba.druid.sql.dialect.postgresql.visitor.PGOutputVisitor;
|
||||
import org.junit.Assert;
|
||||
|
||||
public class PGTest extends TestCase {
|
||||
protected String output(List<SQLStatement> stmtList) {
|
||||
@@ -42,4 +44,18 @@ public class PGTest extends TestCase {
|
||||
}
|
||||
System.out.println(text);
|
||||
}
|
||||
|
||||
protected void testParseSql(String sql, String expectedSql, String expectedPattern, Class<?> type) {
|
||||
PGSQLStatementParser parser = new PGSQLStatementParser(sql);
|
||||
List<SQLStatement> statementList = parser.parseStatementList();
|
||||
SQLStatement statement = statementList.get(0);
|
||||
|
||||
Assert.assertEquals(1, statementList.size());
|
||||
Assert.assertTrue(type.isAssignableFrom(statement.getClass()));
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
PGOutputVisitor visitor = new PGOutputVisitor(sb);
|
||||
statement.accept(visitor);
|
||||
Assert.assertEquals(expectedSql, sb.toString());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user