public static PDynamicDeclaredColumnNode VisitDynamicColumn(ColumnDef node) { return(TreeHelper.Create <PDynamicDeclaredColumnNode>(n => { n.Name = IdentifierVisitor.Visit(node.ColumnDefName); PTree.RawNode[n] = node; })); }
private static QsiSetColumnExpressionNode VisitDupKeyPair(UpsertStatement.Types.Pair_ColumnName_ParseNode pair) { return(TreeHelper.Create <QsiSetColumnExpressionNode>(n => { n.Target = IdentifierVisitor.Visit(pair.First); n.Value.SetValue(ExpressionVisitor.Visit(pair.Second)); })); }
public static QsiColumnNode VisitColumnParseNode(ColumnParseNode node) { var columnNode = new QsiDeclaredColumnNode { Name = IdentifierVisitor.Visit(node) }; PTree.RawNode[columnNode] = node; return(columnNode); }
public static QsiColumnNode VisitTableWildcardParseNode(TableWildcardParseNode node) { var columnNode = new QsiAllColumnNode(); if (!string.IsNullOrEmpty(node.Name)) { columnNode.Path = new QsiQualifiedIdentifier(IdentifierVisitor.Visit(node)); } PTree.RawNode[columnNode] = node; return(columnNode); }
public static QsiColumnNode VisitAliasedNode(AliasedNode node) { var childNode = node.Node.UnwrapAs <IParseNode>(); bool hasAlias = !string.IsNullOrEmpty(node.Alias); QsiColumnNode columnNode = null; QsiExpressionNode expressionNode = null; switch (childNode.Unwrap()) { case INamedParseNode namedNode: columnNode = VisitNamedParseNode(namedNode); break; case WildcardParseNode wildcardParseNode: columnNode = VisitWildcardParseNode(wildcardParseNode); break; default: expressionNode = ExpressionVisitor.Visit(childNode); break; } if (columnNode != null && !hasAlias) { return(columnNode); } return(TreeHelper.Create <QsiDerivedColumnNode>(n => { if (hasAlias) { n.Alias.SetValue(new QsiAliasNode { Name = IdentifierVisitor.Visit(node) }); } if (columnNode != null) { n.Column.SetValue(columnNode); } if (expressionNode != null) { n.Expression.SetValue(expressionNode); } PTree.RawNode[n] = node; })); }
public static IEnumerable <QsiSequentialColumnNode> CreateSequentialColumns(IEnumerable <ColumnParseNode> columns) { return(columns.Select(c => { var node = new QsiSequentialColumnNode(); node.Alias.SetValue(new QsiAliasNode { Name = IdentifierVisitor.Visit(c)[0] }); PTree.RawNode[node] = c; return node; })); }
public static QsiTableNode VisitDerivedTableNode(DerivedTableNode node) { return(TreeHelper.Create <QsiDerivedTableNode>(n => { n.Columns.SetValue(TreeHelper.CreateAllColumnsDeclaration()); n.Source.SetValue(VisitSelectStatement(node.Select)); if (!string.IsNullOrEmpty(node.Alias)) { n.Alias.SetValue(new QsiAliasNode { Name = IdentifierVisitor.Visit(node) }); } PTree.RawNode[n] = node; })); }
public static QsiTableNode VisitNamedTableNode(NamedTableNode node) { var identifier = IdentifierVisitor.Visit(node.Name); QsiTableAccessNode tableNode; if (node.DynamicColumns.Any()) { tableNode = TreeHelper.Create <PDynamicTableAccessNode>(n => { n.Identifier = identifier; n.DynamicColumns = new QsiColumnsDeclarationNode(); n.DynamicColumns.Columns.AddRange(node.DynamicColumns.Select(VisitDynamicColumn)); }); } else { tableNode = new QsiTableAccessNode { Identifier = identifier }; } if (string.IsNullOrEmpty(node.Alias)) { PTree.RawNode[tableNode] = node; return(tableNode); } return(TreeHelper.Create <QsiDerivedTableNode>(n => { n.Columns.SetValue(TreeHelper.CreateAllColumnsDeclaration()); n.Source.SetValue(tableNode); n.Alias.SetValue(new QsiAliasNode { Name = IdentifierVisitor.Visit(node) }); PTree.RawNode[n] = node; })); }
public static IQsiDefinitionNode VisitCreateViewStatement(CreateTableStatement statement) { var node = new PViewDefinitionNode { Identifier = IdentifierVisitor.Visit(statement.TableName) }; if (statement.ColumnDefs.Any()) { node.DynamicColumns = new QsiColumnsDeclarationNode(); node.DynamicColumns.Columns.AddRange(statement.ColumnDefs.Select(TableVisitor.VisitDynamicColumn)); } QsiTableNode tableNode = TreeHelper.Create <QsiTableReferenceNode>(n => { n.Identifier = IdentifierVisitor.Visit(statement.BaseTableName); PTree.RawNode[n] = statement.BaseTableName; }); if (statement.WhereClause != null) { var derivedTableNode = new QsiDerivedTableNode(); derivedTableNode.Columns.Value = TreeHelper.CreateAllColumnsDeclaration(); derivedTableNode.Where.Value = ExpressionVisitor.VisitWhere(statement.WhereClause); derivedTableNode.Source.Value = tableNode; node.Source.Value = derivedTableNode; } else { node.Source.Value = tableNode; } PTree.RawNode[node] = statement; return(node); }