mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improved postgresql support, fix #3588
This commit is contained in:
@@ -282,10 +282,25 @@ public class PGExprParser extends SQLExprParser {
|
||||
|
||||
return primaryRest(extract);
|
||||
} else if (FnvHash.Constants.POINT == hash) {
|
||||
SQLExpr value = this.primary();
|
||||
PGPointExpr point = new PGPointExpr();
|
||||
point.setValue(value);
|
||||
return primaryRest(point);
|
||||
switch (lexer.token()) {
|
||||
case DOT:
|
||||
case EQ:
|
||||
case LTGT:
|
||||
case GT:
|
||||
case GTEQ:
|
||||
case LT:
|
||||
case LTEQ:
|
||||
case SUB:
|
||||
case PLUS:
|
||||
case SUBGT:
|
||||
lexer.nextToken();
|
||||
return primaryRest(identifierExpr);
|
||||
default:
|
||||
SQLExpr value = this.primary();
|
||||
PGPointExpr point = new PGPointExpr();
|
||||
point.setValue(value);
|
||||
return primaryRest(point);
|
||||
}
|
||||
} else if (FnvHash.Constants.BOX == hash) {
|
||||
SQLExpr value = this.primary();
|
||||
PGBoxExpr box = new PGBoxExpr();
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.alibaba.druid.bvt.sql.postgresql.select;
|
||||
|
||||
import com.alibaba.druid.sql.SQLUtils;
|
||||
import com.alibaba.druid.sql.ast.SQLStatement;
|
||||
import com.alibaba.druid.util.JdbcConstants;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PGSelectTest86
|
||||
extends TestCase {
|
||||
public void test_0() throws Exception {
|
||||
String sql = "select * from xxx_point point inner join xxx_cc cc on point.id = cc.point_id";
|
||||
|
||||
final List<SQLStatement> statements = SQLUtils.parseStatements(sql, JdbcConstants.POSTGRESQL);
|
||||
assertEquals(1, statements.size());
|
||||
final SQLStatement stmt = statements.get(0);
|
||||
|
||||
assertEquals("SELECT *\n" +
|
||||
"FROM xxx_point point\n" +
|
||||
"\tINNER JOIN xxx_cc cc ON POINT id = cc.point_id"
|
||||
, stmt.toString());
|
||||
|
||||
assertEquals("select *\n" +
|
||||
"from xxx_point point\n" +
|
||||
"\tinner join xxx_cc cc on point id = cc.point_id", stmt.toLowerCaseString());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user