public virtual ISqlNode VisitWithCte(SqlWithCteNode n) { var name = Visit(n.Name) as SqlIdentifierNode; var columns = Visit(n.ColumnNames) as SqlListNode <SqlIdentifierNode>; var select = Visit(n.Name); return(n.Update(name, columns, select, n.Recursive)); }
public override ISqlNode VisitWithCte(SqlWithCteNode n) { Current.AddSymbol(n.Name.Name, new SymbolInfo { OriginalName = n.Name.Name, OriginKind = SymbolOriginKind.UserDeclared, ObjectKind = ObjectKind.TableExpression, DefinedAt = n.Location }); return(base.VisitWithCte(n)); }
public ISqlNode VisitWithCte(SqlWithCteNode n) { Visit(n.Name); if (n.ColumnNames != null && n.ColumnNames.Any()) { Append("("); Visit(n.ColumnNames); Append(")"); } Append(" AS ("); IncreaseIndent(); AppendLineAndIndent(); Visit(n.Select); AppendLineAndIndent(); DecreaseIndent(); Append(")"); return(n); }
private SqlWithCteNode ParseCte(ITokenizer t) { // <identifier> ("(" <columnList> ")")? "AS" "(" <QueryExpression> ")" var name = t.Expect(SqlTokenType.Identifier); var cteNode = new SqlWithCteNode { Location = name.Location, Name = new SqlIdentifierNode(name), Recursive = false }; var lookahead = t.Peek(); if (lookahead.IsSymbol("(")) { cteNode.ColumnNames = ParseParenthesis(t, x => ParseList(x, ParseIdentifier)).Expression; } t.Expect(SqlTokenType.Keyword, "AS"); cteNode.Select = ParseParenthesis(t, ParseQueryExpression).Expression; cteNode.DetectRecursion(); return(cteNode); }
private SqlWithCteNode ParseCte(ITokenizer t) { // "RECURSIVE"? <identifier> ("(" <columnList> ")")? "AS" "(" <QueryExpression> ")" bool isRecursive = t.NextIs(SqlTokenType.Keyword, "RECURSIVE", true); var name = t.Expect(SqlTokenType.Identifier); var cteNode = new SqlWithCteNode { Location = name.Location, Name = new SqlIdentifierNode(name), Recursive = isRecursive }; var lookahead = t.Peek(); if (lookahead.IsSymbol("(")) { cteNode.ColumnNames = ParseParenthesis(t, x => ParseList(x, ParseIdentifier)).Expression; } t.Expect(SqlTokenType.Keyword, "AS"); // TODO: The CTE can contain INSERT, UPDATE and DELETE statements as well (usually with the RETURNING clause) cteNode.Select = ParseParenthesis(t, ParseQueryExpression).Expression; return(cteNode); }
public override ISqlNode VisitWithCte(SqlWithCteNode n) { // TODO: Detect recursive CTE and validate correct structure return(base.VisitWithCte(n)); }