Search in sources :

Example 1 with PGWithClause

use of com.alibaba.druid.sql.dialect.postgresql.ast.PGWithClause in project druid by alibaba.

the class PGSQLStatementParser method parseWith.

public SQLStatement parseWith() {
    PGWithClause with = this.parseWithClause();
    if (lexer.token() == Token.INSERT) {
        PGInsertStatement stmt = this.parseInsert();
        stmt.setWith(with);
        return stmt;
    }
    if (lexer.token() == Token.SELECT) {
        PGSelectStatement stmt = this.parseSelect();
        stmt.setWith(with);
        return stmt;
    }
    if (lexer.token() == Token.DELETE) {
        PGDeleteStatement stmt = this.parseDeleteStatement();
        stmt.setWith(with);
        return stmt;
    }
    throw new ParserException("TODO");
}
Also used : PGSelectStatement(com.alibaba.druid.sql.dialect.postgresql.ast.stmt.PGSelectStatement) PGWithClause(com.alibaba.druid.sql.dialect.postgresql.ast.PGWithClause) PGInsertStatement(com.alibaba.druid.sql.dialect.postgresql.ast.stmt.PGInsertStatement) PGDeleteStatement(com.alibaba.druid.sql.dialect.postgresql.ast.stmt.PGDeleteStatement)

Example 2 with PGWithClause

use of com.alibaba.druid.sql.dialect.postgresql.ast.PGWithClause in project druid by alibaba.

the class PGSQLStatementParser method parseWithClause.

public PGWithClause parseWithClause() {
    lexer.nextToken();
    PGWithClause withClause = new PGWithClause();
    if (lexer.token() == Token.RECURSIVE) {
        lexer.nextToken();
        withClause.setRecursive(true);
    }
    for (; ; ) {
        PGWithQuery withQuery = withQuery();
        withClause.getWithQuery().add(withQuery);
        if (lexer.token() == Token.COMMA) {
            lexer.nextToken();
            continue;
        } else {
            break;
        }
    }
    return withClause;
}
Also used : PGWithClause(com.alibaba.druid.sql.dialect.postgresql.ast.PGWithClause) PGWithQuery(com.alibaba.druid.sql.dialect.postgresql.ast.PGWithQuery)

Example 3 with PGWithClause

use of com.alibaba.druid.sql.dialect.postgresql.ast.PGWithClause in project druid by alibaba.

the class PGASTVisitorAdapterTest method test_adapter.

public void test_adapter() throws Exception {
    PGASTVisitorAdapter adapter = new PGASTVisitorAdapter();
    new WindowClause().accept(adapter);
    new FetchClause().accept(adapter);
    new ForClause().accept(adapter);
    new PGWithQuery().accept(adapter);
    new PGWithClause().accept(adapter);
    new PGDeleteStatement().accept(adapter);
    new PGFunctionTableSource().accept(adapter);
}
Also used : PGWithQuery(com.alibaba.druid.sql.dialect.postgresql.ast.PGWithQuery) PGWithClause(com.alibaba.druid.sql.dialect.postgresql.ast.PGWithClause) PGFunctionTableSource(com.alibaba.druid.sql.dialect.postgresql.ast.stmt.PGFunctionTableSource) PGASTVisitorAdapter(com.alibaba.druid.sql.dialect.postgresql.visitor.PGASTVisitorAdapter) ForClause(com.alibaba.druid.sql.dialect.postgresql.ast.stmt.PGSelectQueryBlock.ForClause) FetchClause(com.alibaba.druid.sql.dialect.postgresql.ast.stmt.PGSelectQueryBlock.FetchClause) WindowClause(com.alibaba.druid.sql.dialect.postgresql.ast.stmt.PGSelectQueryBlock.WindowClause) PGDeleteStatement(com.alibaba.druid.sql.dialect.postgresql.ast.stmt.PGDeleteStatement)

Aggregations

PGWithClause (com.alibaba.druid.sql.dialect.postgresql.ast.PGWithClause)3 PGWithQuery (com.alibaba.druid.sql.dialect.postgresql.ast.PGWithQuery)2 PGDeleteStatement (com.alibaba.druid.sql.dialect.postgresql.ast.stmt.PGDeleteStatement)2 PGFunctionTableSource (com.alibaba.druid.sql.dialect.postgresql.ast.stmt.PGFunctionTableSource)1 PGInsertStatement (com.alibaba.druid.sql.dialect.postgresql.ast.stmt.PGInsertStatement)1 FetchClause (com.alibaba.druid.sql.dialect.postgresql.ast.stmt.PGSelectQueryBlock.FetchClause)1 ForClause (com.alibaba.druid.sql.dialect.postgresql.ast.stmt.PGSelectQueryBlock.ForClause)1 WindowClause (com.alibaba.druid.sql.dialect.postgresql.ast.stmt.PGSelectQueryBlock.WindowClause)1 PGSelectStatement (com.alibaba.druid.sql.dialect.postgresql.ast.stmt.PGSelectStatement)1 PGASTVisitorAdapter (com.alibaba.druid.sql.dialect.postgresql.visitor.PGASTVisitorAdapter)1