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

Public Member Functions

SqlTableConstraint BuildConstraint ()
 
- Public Member Functions inherited from Deveel.Data.Sql.Parser.SqlNode
 SqlNode ()
 

Protected Member Functions

override 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...
 
- Protected Member Functions inherited from Deveel.Data.Sql.Parser.SqlNode
virtual void OnNodeInit ()
 After the initialization of the node from the parser, this method is invoked to let the specific initialization to occur. More...
 

Package Functions

 TableConstraintNode ()
 

Properties

string ConstraintName [get, private set]
 
string ConstraintType [get, private set]
 
IEnumerable< string > Columns [get]
 
IExpressionNode CheckExpression [get, private set]
 
ObjectNameNode ReferencedTableName [get, private set]
 
IEnumerable< string > ReferencedColumns [get]
 
string OnUpdateAction [get, private set]
 
string OnDeleteAction [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...
 

Private Member Functions

void ReadConstraintDefinition (ISqlNode node)
 
void ReadConstraintName (IEnumerable< ISqlNode > nodes)
 
void ReadColumnList (IEnumerable< ISqlNode > nodes)
 

Private Attributes

bool notSeen
 
readonly IList< string > columns
 
readonly IList< string > refColumns
 

Detailed Description

Definition at line 25 of file TableConstraintNode.cs.

Constructor & Destructor Documentation

Deveel.Data.Sql.Parser.TableConstraintNode.TableConstraintNode ( )
inlinepackage

Definition at line 30 of file TableConstraintNode.cs.

30  {
31  columns = new List<string>();
32  refColumns = new List<string>();
33  }

Member Function Documentation

SqlTableConstraint Deveel.Data.Sql.Parser.TableConstraintNode.BuildConstraint ( )
inline

Definition at line 112 of file TableConstraintNode.cs.

112  {
113  if (String.Equals(ConstraintTypeNames.Check, ConstraintType, StringComparison.OrdinalIgnoreCase)) {
114  var exp = ExpressionBuilder.Build(CheckExpression);
115  return new SqlTableConstraint(ConstraintName, Tables.ConstraintType.Check, Columns.ToArray()) {
116  CheckExpression = exp
117  };
118  }
119  if (String.Equals(ConstraintTypeNames.PrimaryKey, ConstraintType, StringComparison.OrdinalIgnoreCase))
121  if (String.Equals(ConstraintTypeNames.UniqueKey, ConstraintType, StringComparison.OrdinalIgnoreCase))
123  if (String.Equals(ConstraintTypeNames.ForeignKey, ConstraintType, StringComparison.OrdinalIgnoreCase)) {
124  var fTable = ReferencedTableName.Name;
125  var fColumns = ReferencedColumns;
126  var onDelete = ForeignKeyAction.NoAction;
127  var onUpdate = ForeignKeyAction.NoAction;
128 
129  if (!String.IsNullOrEmpty(OnDeleteAction))
130  onDelete = StatementBuilder.GetForeignKeyAction(OnDeleteAction);
131  if (!String.IsNullOrEmpty(OnUpdateAction))
132  onUpdate = StatementBuilder.GetForeignKeyAction(OnUpdateAction);
133 
134  var fkey = SqlTableConstraint.ForeignKey(ConstraintName, Columns.ToArray(), fTable,
135  fColumns.ToArray(), onDelete, onUpdate);
136 
137  return fkey;
138  }
139 
140  throw new NotSupportedException();
141  }
A long string in the system.
static SqlTableConstraint PrimaryKey(string constraintName, string[] columns)
ForeignKeyAction
Enumerates the foreign key referential trigger actions.
ConstraintType
An enumeration of all the supported kinds of constraints within a table or a schema.
static SqlTableConstraint UniqueKey(string constraintName, string[] columns)
string Name
The full object name as composed from the input SQL string analyzed.
static SqlTableConstraint ForeignKey(string constraintName, string[] columns, string refTable, string[] refcolumns, ForeignKeyAction onDelete, ForeignKeyAction onUpdate)
override ISqlNode Deveel.Data.Sql.Parser.TableConstraintNode.OnChildNode ( ISqlNode  node)
inlineprotectedvirtual

During the initialization of the node from the parser, this method is called for every child node added to ChildNodes

Parameters
nodeThe node being added to the list of children.
Returns
Returns a normalized version of the child node, or the node itself.

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

Definition at line 55 of file TableConstraintNode.cs.

55  {
56  if (node.NodeName == "table_constraint_name_opt") {
57  ReadConstraintName(node.ChildNodes);
58  } else if (node.NodeName == "def_table_constraint") {
60  }
61 
62  return base.OnChildNode(node);
63  }
void ReadConstraintName(IEnumerable< ISqlNode > nodes)
void Deveel.Data.Sql.Parser.TableConstraintNode.ReadColumnList ( IEnumerable< ISqlNode nodes)
inlineprivate

Definition at line 102 of file TableConstraintNode.cs.

102  {
103  foreach (var node in nodes) {
104  if (node is IdentifierNode) {
105  columns.Add(((IdentifierNode) node).Text);
106  } else {
107  ReadColumnList(node.ChildNodes);
108  }
109  }
110  }
void ReadColumnList(IEnumerable< ISqlNode > nodes)
void Deveel.Data.Sql.Parser.TableConstraintNode.ReadConstraintDefinition ( ISqlNode  node)
inlineprivate

Definition at line 65 of file TableConstraintNode.cs.

65  {
66  foreach (var childNode in node.ChildNodes) {
67  if (childNode is SqlKeyNode) {
68  var keyNode = (SqlKeyNode) childNode;
69  if (String.Equals(keyNode.Text, "NULL", StringComparison.OrdinalIgnoreCase)) {
70  if (notSeen) {
71  ConstraintType = "NOT NULL";
72  } else {
73  ConstraintType = "NULL";
74  }
75  } else if (String.Equals(keyNode.Text, "NOT", StringComparison.OrdinalIgnoreCase)) {
76  notSeen = true;
77  } else if (String.Equals(keyNode.Text, "REFERENCES", StringComparison.OrdinalIgnoreCase)) {
78  ConstraintType = ConstraintTypeNames.ForeignKey;
79  } else if (String.Equals(keyNode.Text, "CHECK", StringComparison.OrdinalIgnoreCase)) {
80  ConstraintType = ConstraintTypeNames.Check;
81  } else if (String.Equals(keyNode.Text, "PRIMARY", StringComparison.OrdinalIgnoreCase)) {
82  ConstraintType = ConstraintTypeNames.PrimaryKey;
83  } else if (String.Equals(keyNode.Text, "UNIQUE", StringComparison.OrdinalIgnoreCase)) {
84  ConstraintType = ConstraintTypeNames.UniqueKey;
85  }
86  } else if (childNode.NodeName == "column_list") {
87  ReadColumnList(childNode.ChildNodes);
88  }
89  }
90  }
A long string in the system.
ConstraintType
An enumeration of all the supported kinds of constraints within a table or a schema.
void ReadColumnList(IEnumerable< ISqlNode > nodes)
void Deveel.Data.Sql.Parser.TableConstraintNode.ReadConstraintName ( IEnumerable< ISqlNode nodes)
inlineprivate

Definition at line 92 of file TableConstraintNode.cs.

92  {
93  foreach (var node in nodes) {
94  if (node is IdentifierNode) {
95  ConstraintName = ((IdentifierNode) node).Text;
96  } else {
97  ReadConstraintName(node.ChildNodes);
98  }
99  }
100  }
void ReadConstraintName(IEnumerable< ISqlNode > nodes)

Member Data Documentation

readonly IList<string> Deveel.Data.Sql.Parser.TableConstraintNode.columns
private

Definition at line 27 of file TableConstraintNode.cs.

bool Deveel.Data.Sql.Parser.TableConstraintNode.notSeen
private

Definition at line 26 of file TableConstraintNode.cs.

readonly IList<string> Deveel.Data.Sql.Parser.TableConstraintNode.refColumns
private

Definition at line 28 of file TableConstraintNode.cs.

Property Documentation

IExpressionNode Deveel.Data.Sql.Parser.TableConstraintNode.CheckExpression
getprivate set

Definition at line 43 of file TableConstraintNode.cs.

IEnumerable<string> Deveel.Data.Sql.Parser.TableConstraintNode.Columns
get

Definition at line 39 of file TableConstraintNode.cs.

string Deveel.Data.Sql.Parser.TableConstraintNode.ConstraintName
getprivate set

Definition at line 35 of file TableConstraintNode.cs.

string Deveel.Data.Sql.Parser.TableConstraintNode.ConstraintType
getprivate set

Definition at line 37 of file TableConstraintNode.cs.

string Deveel.Data.Sql.Parser.TableConstraintNode.OnDeleteAction
getprivate set

Definition at line 53 of file TableConstraintNode.cs.

string Deveel.Data.Sql.Parser.TableConstraintNode.OnUpdateAction
getprivate set

Definition at line 51 of file TableConstraintNode.cs.

IEnumerable<string> Deveel.Data.Sql.Parser.TableConstraintNode.ReferencedColumns
get

Definition at line 47 of file TableConstraintNode.cs.

ObjectNameNode Deveel.Data.Sql.Parser.TableConstraintNode.ReferencedTableName
getprivate set

Definition at line 45 of file TableConstraintNode.cs.


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