Search in sources :

Example 1 with PGFunctionTableSource

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

the class PGSelectParser method parseTableSourceRest.

protected SQLTableSource parseTableSourceRest(SQLTableSource tableSource) {
    if (lexer.token() == Token.AS && tableSource instanceof SQLExprTableSource) {
        lexer.nextToken();
        String alias = null;
        if (lexer.token() == Token.IDENTIFIER) {
            alias = lexer.stringVal();
            lexer.nextToken();
        }
        if (lexer.token() == Token.LPAREN) {
            SQLExprTableSource exprTableSource = (SQLExprTableSource) tableSource;
            PGFunctionTableSource functionTableSource = new PGFunctionTableSource(exprTableSource.getExpr());
            if (alias != null) {
                functionTableSource.setAlias(alias);
            }
            lexer.nextToken();
            parserParameters(functionTableSource.getParameters());
            accept(Token.RPAREN);
            return super.parseTableSourceRest(functionTableSource);
        }
    }
    return super.parseTableSourceRest(tableSource);
}
Also used : PGFunctionTableSource(com.alibaba.druid.sql.dialect.postgresql.ast.stmt.PGFunctionTableSource) SQLExprTableSource(com.alibaba.druid.sql.ast.statement.SQLExprTableSource)

Example 2 with PGFunctionTableSource

use of com.alibaba.druid.sql.dialect.postgresql.ast.stmt.PGFunctionTableSource 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

PGFunctionTableSource (com.alibaba.druid.sql.dialect.postgresql.ast.stmt.PGFunctionTableSource)2 SQLExprTableSource (com.alibaba.druid.sql.ast.statement.SQLExprTableSource)1 PGWithClause (com.alibaba.druid.sql.dialect.postgresql.ast.PGWithClause)1 PGWithQuery (com.alibaba.druid.sql.dialect.postgresql.ast.PGWithQuery)1 PGDeleteStatement (com.alibaba.druid.sql.dialect.postgresql.ast.stmt.PGDeleteStatement)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 PGASTVisitorAdapter (com.alibaba.druid.sql.dialect.postgresql.visitor.PGASTVisitorAdapter)1