添加postgresql的begin,commit,set命令解析

添加PGStatement的测试代码,修复PGStatement解析bug;修复pg无法识别table别名问题

将PG的关键字移入TOKEN中

start transaction的visit优化
This commit is contained in:
Terry Zhu
2017-05-17 16:39:44 +08:00
parent ed57e419c4
commit b531cb8c24
19 changed files with 603 additions and 63 deletions
@@ -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());
}
}