Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sql parser for PostgreSQL 一些问题 #1391

Closed
spance opened this issue Aug 27, 2016 · 2 comments
Closed

Sql parser for PostgreSQL 一些问题 #1391

spance opened this issue Aug 27, 2016 · 2 comments
Labels
Milestone

Comments

@spance
Copy link

spance commented Aug 27, 2016

version 1.0.26-SNAPSHOT

目前的sql parser在处理一些pg特有语法时抛出异常 com.alibaba.druid.sql.parser.ParserException: syntax error...

public class PGSelectTest30 extends PGTest {

    String[] pgSQLs = new String[]{
            /**
             * Chapter 12. Full Text Search
             * tsvector @@ tsquery
             * tsquery @@ tsvector
             * text @@ tsquery
             * text @@ text
            */
            "SELECT 'a fat cat sat on a mat'::tsvector @@ 'cat & rat'::tsquery",
            /**
             * 9.7. Pattern Matching: ilike
            */
            "select * from dual where name ilike '%mi%'",
            /**
             * 9.7.2. SIMILAR TO Regular Expressions
            */
            "select 'abc' SIMILAR TO '%(b|d)%'",
            /**
             * 9.7.3. POSIX Regular Expressions
            */
            "select 'thomas' ~ '.*thomas.*'",
            "select 'thomas' ~* '.*Thomas.*'",
            "select 'thomas' !~ '.*Thomas.*'",
            "select 'thomas' !~* '.*vadim.*'",
            /**
             * 9.9. Date/Time Functions and Operators
            */
            "select date '2001-09-28' + integer '7'",
            /**
             * array operators
             *
            */
            "select '{1,2,3}'::int[] && '{1,2,3}'::int[]",
            "select '{1,2,3}'::int[] @> '{1,2,3}'::int[]",
            "select '{1,2,3}'::int[] @< '{1,2,3}'::int[]",
            /**
             * others
             * polygon '((0,0),(1,1))' ~= polygon '((1,1),(0,0))'
             * circle '((0,0),1)' <-> circle '((5,0),1)'
             * ltree <@ ltree
             * ltree ~ lquery
             * ltree ? lquery[]
             * ltree[] ?@> ltree
             * .....
            */
    };

    public void test_0() throws Exception {
        for (String sql : pgSQLs) {
            PGSQLStatementParser parser = new PGSQLStatementParser(sql);
            List<SQLStatement> statementList = parser.parseStatementList();
            SQLStatement stmt = statementList.get(0);
            Assert.assertNotNull(stmt);
        }
    }
}
@wenshao wenshao added the Bug label Sep 16, 2016
@wenshao
Copy link
Member

wenshao commented Sep 17, 2016

PG的语法有点诡异哈

@wenshao
Copy link
Member

wenshao commented Sep 19, 2016

已经全部支持,谢谢反馈

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants