private static QsiExpressionNode VisitNamedParseNode(INamedParseNode node) { return(TreeHelper.Create <QsiColumnExpressionNode>(n => { n.Column.SetValue(TableVisitor.VisitNamedParseNode(node)); })); }
public static QsiActionNode VisitUpsertStatement(UpsertStatement node) { var insertAction = new PUpsertActionNode { Hints = node.Hint?.Hints }; if (TableVisitor.VisitNamedTableNode(node.Table) is QsiTableAccessNode tableAccessNode) { insertAction.Target.SetValue(tableAccessNode); } else { throw new QsiException(QsiError.Syntax); } if (node.Columns.Any()) { insertAction.Columns = node.Columns .Select(IdentifierVisitor.Visit) .ToArray(); } if (node.Values.Any()) { var row = new QsiRowValueExpressionNode(); row.ColumnValues.AddRange(node.Values.Select(ExpressionVisitor.Visit)); insertAction.Values.Add(row); } else if (node.Select != null) { insertAction.ValueTable.SetValue(TableVisitor.VisitSelectStatement(node.Select)); } if (node.OnDupKeyIgnore) { insertAction.ConflictBehavior = QsiDataConflictBehavior.Ignore; } else if (node.OnDupKeyPairs.Any()) { var conflictAction = new QsiDataConflictActionNode(); conflictAction.SetValues.AddRange(node.OnDupKeyPairs.Select(VisitDupKeyPair)); insertAction.ConflictBehavior = QsiDataConflictBehavior.Update; insertAction.ConflictAction.SetValue(conflictAction); } PTree.RawNode[insertAction] = node; return(insertAction); }
public static QsiActionNode VisitDeleteStatement(DeleteStatement node) { var table = TableVisitor.VisitTableNode(node.Table); if (node.Where != null || node.OrderBy.Any() || node.Limit != null) { var derivedTable = new QsiDerivedTableNode(); derivedTable.Columns.SetValue(TreeHelper.CreateAllColumnsDeclaration()); derivedTable.Source.SetValue(table); if (node.Where != null) { derivedTable.Where.SetValue(ExpressionVisitor.VisitWhere(node.Where)); } if (node.OrderBy.Any()) { derivedTable.Order.SetValue(ExpressionVisitor.VisitOrderBy(node.OrderBy)); } if (node.Limit != null) { derivedTable.Limit.SetValue(ExpressionVisitor.VisitLimitOffset(node.Limit, null)); } table = derivedTable; } var deleteAction = new PDeleteActionNode { Hints = node.Hint?.Hints }; deleteAction.Target.SetValue(table); PTree.RawNode[deleteAction] = node; return(deleteAction); }