18 using System.Collections.Generic;
23 namespace Deveel.Data.Sql.Parser {
25 public string TableName {
get;
private set; }
27 public IEnumerable<IAlterActionNode> Actions {
get;
private set; }
33 TableName = ((ObjectNameNode) node).Name;
35 CreateTable = (CreateTableNode) node;
36 }
else if (node.
NodeName ==
"alter_actions") {
40 return base.OnChildNode(node);
44 if (CreateTable != null) {
45 var statements =
new List<IStatement>();
48 foreach (var statement
in statements) {
50 ((CreateTableStatement) statement).IfNotExists =
true;
53 foreach (var statement
in statements) {
56 }
else if (Actions != null) {
57 foreach (var action
in Actions) {
64 ICollection<IStatement> statements) {
66 var column = ((AddColumnNode) action).Column;
67 var constraints =
new List<SqlTableConstraint>();
68 var columnInfo = column.BuildColumn(typeResolver, tableName.
FullName, constraints);
72 foreach (var constraint
in constraints) {
76 var constraint = ((AddConstraintNode) action).Constraint;
78 var constraintInfo = constraint.BuildConstraint();
81 var columnName = ((DropColumnNode) action).ColumnName;
84 var constraintName = ((DropConstraintNode) action).ConstraintName;
87 var actionNode = ((SetDefaultNode) action);
88 var columnName = actionNode.ColumnName;
92 var columnName = ((DropDefaultNode) action).ColumnName;
95 var column = ((AlterColumnNode) action).Column;
96 var constraints =
new List<SqlTableConstraint>();
97 var columnInfo = column.BuildColumn(typeResolver, tableName.
FullName, constraints);
104 foreach (var constraint
in constraints) {
static ObjectName Parse(string s)
Parses the given string into a ObjectName object.
Defines the contract for nodes in an AST model for a SQL grammar analysis and parsing.
The statement object used to create a table in a database.
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)
Describes the name of an object within a database.
static void BuildAction(ITypeResolver typeResolver, ObjectName tableName, IAlterActionNode action, ICollection< IStatement > statements)
ICollection< IStatement > Statements
override void BuildStatement(StatementBuilder builder)
override ISqlNode OnChildNode(ISqlNode node)
During the initialization of the node from the parser, this method is called for every child node add...
ITypeResolver TypeResolver
string FullName
Gets the full reference name formatted.