18 using System.Collections.Generic;
20 using System.Linq.Expressions;
25 namespace Deveel.Data.Sql.Parser {
29 public bool ReplaceIfExists {
get;
private set; }
31 public IEnumerable<string> ColumnNames {
get;
private set; }
36 if (node.
NodeName ==
"column_list_opt") {
38 }
else if (node.
NodeName ==
"or_replace_opt") {
40 ReplaceIfExists =
true;
42 ViewName = (ObjectNameNode) node;
44 QueryExpression = (SqlQueryExpressionNode) node;
47 return base.OnChildNode(node);
51 var columnListNode = node.
ChildNodes.FirstOrDefault();
52 if (columnListNode == null)
55 var columnNames = (columnListNode.ChildNodes.Where(childNode => childNode.NodeName.Equals(
"column_name"))
56 .Select(childNode => childNode.ChildNodes.FirstOrDefault())
57 .Where(columnName => columnName != null && columnName is
IdentifierNode)
58 .Select(columnName => ((IdentifierNode) columnName).Text)).ToList();
60 ColumnNames = columnNames.AsEnumerable();
This is a simple identifier within a SQL grammar.
Defines the contract for nodes in an AST model for a SQL grammar analysis and parsing.
Represents a composed name for an object within the system.
string NodeName
Gets the name of the node analyzed from the parser.
static SqlExpression Build(IExpressionNode node)
void GetColumnList(ISqlNode node)
override void BuildStatement(StatementBuilder builder)
ICollection< IStatement > Statements
The root node of an expression used to select a set of items from a set of sources defined...
IEnumerable< ISqlNode > ChildNodes
Gets a read-only enumeration of the children nodes, if any.
override ISqlNode OnChildNode(ISqlNode node)
During the initialization of the node from the parser, this method is called for every child node add...