DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
Classes | Public Member Functions | Properties | Private Member Functions | List of all members
Deveel.Data.Sql.Statements.CreateTableStatement Class Reference

The statement object used to create a table in a database. More...

Inheritance diagram for Deveel.Data.Sql.Statements.CreateTableStatement:
Deveel.Data.Sql.Statements.SqlStatement Deveel.Data.Sql.Statements.IPreparableStatement Deveel.Data.Sql.Statements.IStatement Deveel.Data.Serialization.ISerializable Deveel.Data.Sql.Statements.IStatement Deveel.Data.Sql.IExecutable Deveel.Data.Sql.IExecutable

Classes

class  Prepared
 
class  TableColumnChecker
 

Public Member Functions

 CreateTableStatement (string tableName, IEnumerable< SqlTableColumn > columns)
 
- Public Member Functions inherited from Deveel.Data.Sql.Statements.SqlStatement
ITable Execute (IRequest context)
 Prepares and evaluates this statement into a tabular result. More...
 

Properties

string TableName [get, private set]
 
IList< SqlTableColumnColumns [get, private set]
 
bool IfNotExists [get, set]
 
bool Temporary [get, set]
 
- Properties inherited from Deveel.Data.Sql.Statements.SqlStatement
SqlQuery SourceQuery [get, set]
 Gets the SqlQuery that is the origin of this statement. More...
 
bool IsFromQuery [get, private set]
 Gets a boolean value indicating if this object was formed from the parsing of a SqlQuery or if it was manually created. More...
 
- Properties inherited from Deveel.Data.Sql.Statements.IStatement
SqlQuery SourceQuery [get]
 

Private Member Functions

IStatement IPreparableStatement. Prepare (IRequest context)
 
TableInfo CreateTableInfo (IRequest context)
 
ColumnInfo CreateColumnInfo (string tableName, SqlTableColumn column, TableColumnChecker columnChecker)
 

Additional Inherited Members

- Static Public Member Functions inherited from Deveel.Data.Sql.Statements.SqlStatement
static IEnumerable< SqlStatementParse (string sqlSource)
 Parses a given string into one of more statements. More...
 
static IEnumerable< SqlStatementParse (IContext context, string sqlSource)
 Parses a given string into one of more statements. More...
 
static IEnumerable< SqlStatementParse (IContext context, SqlQuery query)
 
- Protected Member Functions inherited from Deveel.Data.Sql.Statements.SqlStatement
 SqlStatement ()
 
 SqlStatement (ObjectData data)
 
virtual void ExecuteStatement (ExecutionContext context)
 
virtual void GetData (SerializeData data)
 
- Package Functions inherited from Deveel.Data.Sql.Statements.SqlStatement
void SetSource (SqlQuery query)
 

Detailed Description

The statement object used to create a table in a database.

Definition at line 29 of file CreateTableStatement.cs.

Constructor & Destructor Documentation

Deveel.Data.Sql.Statements.CreateTableStatement.CreateTableStatement ( string  tableName,
IEnumerable< SqlTableColumn columns 
)
inline

Parameters
tableName
columns

Definition at line 35 of file CreateTableStatement.cs.

35  {
36  TableName = tableName;
37  Columns = new List<SqlTableColumn>();
38  if (columns != null) {
39  foreach (var column in columns) {
40  Columns.Add(column);
41  }
42  }
43  }

Member Function Documentation

ColumnInfo Deveel.Data.Sql.Statements.CreateTableStatement.CreateColumnInfo ( string  tableName,
SqlTableColumn  column,
TableColumnChecker  columnChecker 
)
inlineprivate

Definition at line 80 of file CreateTableStatement.cs.

80  {
81  var expression = column.DefaultExpression;
82 
83  if (column.IsIdentity && expression != null)
84  throw new InvalidOperationException(String.Format("Identity column '{0}' cannot define a DEFAULT expression.", column.ColumnName));
85 
86  if (expression != null)
87  expression = columnChecker.CheckExpression(expression);
88 
89 
90  var columnName = columnChecker.StripTableName(tableName, column.ColumnName);
91 
92  return new ColumnInfo(columnName, column.ColumnType) {
93  DefaultExpression = expression,
94  IsNotNull = column.IsNotNull
95  };
96  }
Defines the metadata properties of a column within a table of a database.
Definition: ColumnInfo.cs:36
A long string in the system.
bool IsNotNull
Gets or sets a boolean value indicating if the column values are constrained to be ony NOT NULL...
Definition: ColumnInfo.cs:144
TableInfo Deveel.Data.Sql.Statements.CreateTableStatement.CreateTableInfo ( IRequest  context)
inlineprivate

Definition at line 59 of file CreateTableStatement.cs.

59  {
60  var tableName = context.Query.ResolveTableName(TableName);
61 
62  var idColumnCount = Columns.Count(x => x.IsIdentity);
63  if (idColumnCount > 1)
64  throw new InvalidOperationException("More than one IDENTITY column specified.");
65 
66  bool ignoreCase = context.Query.IgnoreIdentifiersCase();
67  var columnChecker = new TableColumnChecker(Columns, ignoreCase);
68 
69 
70  var tableInfo = new TableInfo(tableName);
71 
72  foreach (var column in Columns) {
73  var columnInfo = CreateColumnInfo(tableName.Name, column, columnChecker);
74  tableInfo.AddColumn(columnInfo);
75  }
76 
77  return tableInfo;
78  }
ColumnInfo CreateColumnInfo(string tableName, SqlTableColumn column, TableColumnChecker columnChecker)
Defines the metadata properties of a table existing within a database.
Definition: TableInfo.cs:41
IStatement IPreparableStatement. Deveel.Data.Sql.Statements.CreateTableStatement.Prepare ( IRequest  context)
inlineprivate

Implements Deveel.Data.Sql.Statements.IPreparableStatement.

Definition at line 53 of file CreateTableStatement.cs.

53  {
54  var tableInfo = CreateTableInfo(context);
55 
56  return new Prepared(tableInfo, IfNotExists, Temporary);
57  }

Property Documentation

IList<SqlTableColumn> Deveel.Data.Sql.Statements.CreateTableStatement.Columns
getprivate set

Definition at line 47 of file CreateTableStatement.cs.

bool Deveel.Data.Sql.Statements.CreateTableStatement.IfNotExists
getset

Definition at line 49 of file CreateTableStatement.cs.

string Deveel.Data.Sql.Statements.CreateTableStatement.TableName
getprivate set

Definition at line 45 of file CreateTableStatement.cs.

bool Deveel.Data.Sql.Statements.CreateTableStatement.Temporary
getset

Definition at line 51 of file CreateTableStatement.cs.


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