DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
Public Member Functions | Protected Member Functions | Properties | List of all members
Deveel.Data.Sql.Parser.TableColumnNode Class Reference
Inheritance diagram for Deveel.Data.Sql.Parser.TableColumnNode:
Deveel.Data.Sql.Parser.SqlNode Deveel.Data.Sql.Parser.ITableElementNode Deveel.Data.Sql.Parser.ISqlNode Deveel.Data.Sql.Parser.ISqlNode

Public Member Functions

SqlTableColumn BuildColumn (ITypeResolver typeResolver, string tableName, IList< SqlTableConstraint > constraints)
 
- Public Member Functions inherited from Deveel.Data.Sql.Parser.SqlNode
 SqlNode ()
 

Protected Member Functions

override void OnNodeInit ()
 After the initialization of the node from the parser, this method is invoked to let the specific initialization to occur. More...
 
- Protected Member Functions inherited from Deveel.Data.Sql.Parser.SqlNode
virtual ISqlNode OnChildNode (ISqlNode node)
 During the initialization of the node from the parser, this method is called for every child node added to ChildNodes More...
 

Properties

IdentifierNode ColumnName [get, private set]
 
DataTypeNode DataType [get, private set]
 
IEnumerable< ColumnConstraintNodeConstraints [get, private set]
 
IExpressionNode Default [get, private set]
 
bool IsIdentity [get, private set]
 
- Properties inherited from Deveel.Data.Sql.Parser.SqlNode
ISqlNode Parent [get, private set]
 Gets the parent of the current node. More...
 
string NodeName [get, private set]
 Gets the name of the node, as expressed in the SQL grammar. More...
 
IEnumerable< ISqlNodeChildNodes [get, private set]
 Gets an immutable list of nodes, children of the current node. More...
 
IEnumerable< TokenTokens [get, private set]
 Gets an immutable list of Token that represent the source of this node. More...
 
string ISqlNode. NodeName [get]
 
ISqlNode ISqlNode. Parent [get]
 
IEnumerable< ISqlNode > ISqlNode. ChildNodes [get]
 
IEnumerable< Token > ISqlNode. Tokens [get]
 
- Properties inherited from Deveel.Data.Sql.Parser.ISqlNode
string NodeName [get]
 Gets the name of the node analyzed from the parser. More...
 
ISqlNode Parent [get]
 Gets a reference to the parent ISqlNode, if any. More...
 
IEnumerable< ISqlNodeChildNodes [get]
 Gets a read-only enumeration of the children nodes, if any. More...
 
IEnumerable< TokenTokens [get]
 Gets an enumeration of the tokens composing the this node. More...
 

Detailed Description

Definition at line 26 of file TableColumnNode.cs.

Member Function Documentation

SqlTableColumn Deveel.Data.Sql.Parser.TableColumnNode.BuildColumn ( ITypeResolver  typeResolver,
string  tableName,
IList< SqlTableConstraint constraints 
)
inline

Definition at line 46 of file TableColumnNode.cs.

46  {
47  var dataType = DataTypeBuilder.Build(typeResolver, DataType);
48 
49  var columnInfo = new SqlTableColumn(ColumnName.Text, dataType);
50 
51  if (Default != null)
52  columnInfo.DefaultExpression = ExpressionBuilder.Build(Default);
53 
54  if (IsIdentity) {
55  columnInfo.DefaultExpression = SqlExpression.FunctionCall("UNIQUEKEY",
56  new[] { SqlExpression.Constant(tableName) });
57  columnInfo.IsIdentity = true;
58  }
59 
60  foreach (var constraint in Constraints) {
61  if (String.Equals(ConstraintTypeNames.Check, constraint.ConstraintType, StringComparison.OrdinalIgnoreCase)) {
62  var exp = ExpressionBuilder.Build(constraint.CheckExpression);
63  constraints.Add(SqlTableConstraint.Check(null, exp));
64  } else if (String.Equals(ConstraintTypeNames.ForeignKey, constraint.ConstraintType, StringComparison.OrdinalIgnoreCase)) {
65  var fTable = constraint.ReferencedTable.Name;
66  var fColumn = constraint.ReferencedColumn.Text;
67  var onDelete = ForeignKeyAction.NoAction;
68  var onUpdate = ForeignKeyAction.NoAction;
69 
70  if (!String.IsNullOrEmpty(constraint.OnDeleteAction))
71  onDelete = StatementBuilder.GetForeignKeyAction(constraint.OnDeleteAction);
72  if (!String.IsNullOrEmpty(constraint.OnUpdateAction))
73  onUpdate = StatementBuilder.GetForeignKeyAction(constraint.OnUpdateAction);
74 
75  constraints.Add(SqlTableConstraint.ForeignKey(null, new[]{ColumnName.Text}, fTable, new[]{fColumn}, onDelete, onUpdate));
76  } else if (String.Equals(ConstraintTypeNames.PrimaryKey, constraint.ConstraintType, StringComparison.OrdinalIgnoreCase)) {
77  constraints.Add(SqlTableConstraint.PrimaryKey(null, new[]{ColumnName.Text}));
78  } else if (String.Equals(ConstraintTypeNames.UniqueKey, constraint.ConstraintType, StringComparison.OrdinalIgnoreCase)) {
79  constraints.Add(SqlTableConstraint.UniqueKey(null, new[]{ColumnName.Text}));
80  } else if (String.Equals(ConstraintTypeNames.NotNull, constraint.ConstraintType, StringComparison.OrdinalIgnoreCase)) {
81  columnInfo.IsNotNull = true;
82  } else if (String.Equals(ConstraintTypeNames.Null, constraint.ConstraintType, StringComparison.OrdinalIgnoreCase)) {
83  columnInfo.IsNotNull = false;
84  }
85  }
86 
87  return columnInfo;
88  }
A long string in the system.
static SqlTableConstraint PrimaryKey(string constraintName, string[] columns)
ForeignKeyAction
Enumerates the foreign key referential trigger actions.
static SqlTableConstraint UniqueKey(string constraintName, string[] columns)
static SqlBinaryExpression Add(SqlExpression left, SqlExpression right)
string Text
Gets the textual content of the identifier.
IEnumerable< ColumnConstraintNode > Constraints
static SqlTableConstraint Check(string constraintName, SqlExpression expression)
Defines the base class for instances that represent SQL expression tree nodes.
static SqlConstantExpression Constant(object value)
static SqlFunctionCallExpression FunctionCall(ObjectName functionName)
static SqlTableConstraint ForeignKey(string constraintName, string[] columns, string refTable, string[] refcolumns, ForeignKeyAction onDelete, ForeignKeyAction onUpdate)
override void Deveel.Data.Sql.Parser.TableColumnNode.OnNodeInit ( )
inlineprotectedvirtual

After the initialization of the node from the parser, this method is invoked to let the specific initialization to occur.

Reimplemented from Deveel.Data.Sql.Parser.SqlNode.

Definition at line 37 of file TableColumnNode.cs.

37  {
38  ColumnName = this.FindNode<IdentifierNode>();
39  DataType = this.FindNode<DataTypeNode>();
40  Default = this.FindNode<IExpressionNode>();
41  IsIdentity = this.HasOptionalNode("column_identity_opt");
42 
43  Constraints = this.FindNodes<ColumnConstraintNode>();
44  }
IEnumerable< ColumnConstraintNode > Constraints

Property Documentation

IdentifierNode Deveel.Data.Sql.Parser.TableColumnNode.ColumnName
getprivate set

Definition at line 27 of file TableColumnNode.cs.

IEnumerable<ColumnConstraintNode> Deveel.Data.Sql.Parser.TableColumnNode.Constraints
getprivate set

Definition at line 31 of file TableColumnNode.cs.

DataTypeNode Deveel.Data.Sql.Parser.TableColumnNode.DataType
getprivate set

Definition at line 29 of file TableColumnNode.cs.

IExpressionNode Deveel.Data.Sql.Parser.TableColumnNode.Default
getprivate set

Definition at line 33 of file TableColumnNode.cs.

bool Deveel.Data.Sql.Parser.TableColumnNode.IsIdentity
getprivate set

Definition at line 35 of file TableColumnNode.cs.


The documentation for this class was generated from the following file: