void IDBTraits.ModifyColumn(Func <DbCommand> commandCreator, ColumnDescription description)
 {
     using (DbCommand command = commandCreator()) {
         command.CommandText = _SQLQueryManager.ModifyColumnPostgresStyle(description);
         ExecuteNonQuery(command);
     }
 }
Beispiel #2
0
 /// <summary>
 /// It seems that this feature is not mentioned in any SQL standart and is only implemented in Oracle and MySQL.
 /// However, it is similar to other SQL language structures, so it should be implemented in SQLQueryManager, not OracleDBTraits
 /// </summary>
 private string _ModifyColumnDefinitionOracleStyle(ColumnDescription description)
 {
     return(string.Format(
                "modify ({0})",
                _ColumnDefinition(description, ColumnSpecific.None, Specific.OracleNullExtension)
                ));
 }
Beispiel #3
0
 /// <summary>
 /// SQL-92, page 284
 /// </summary>
 private string _AddColumnDefinition(ColumnDescription description)
 {
     return(string.Format(
                "add {0}",
                _ColumnDefinition(description, ColumnSpecific.None, Specific.None)
                ));
 }
Beispiel #4
0
 void IDBTraits.CreateColumn(Func <DbCommand> commandCreator, ColumnDescription description)
 {
     using (DbCommand command = commandCreator())
     {
         command.CommandText = _SQLQueryManager.CreateColumn(description);
         command.ExecuteNonQuery();
     }
 }
Beispiel #5
0
 void IDBTraits.ModifyColumn(Func <DbCommand> commandCreator, ColumnDescription description)
 {
     using (DbCommand command = commandCreator())
     {
         command.CommandText = _SQLQueryManager.ModifyColumnOracleStyle(description);
         Console.WriteLine();
         Console.WriteLine(command.CommandText);
         command.ExecuteNonQuery();
     }
 }
Beispiel #6
0
 /// <summary>
 /// SQL-92, page 262<br/>
 /// Note that setting oracleNullExtension to true will make the query non-compliant
 /// </summary>
 private string _ColumnDefinition(ColumnDescription description, ColumnSpecific columnSpecific, Specific specific)
 {
     return(string.Format(
                "{0} {1} {2} {3} {4}",
                nameEscaper(description.column.columnName),                                                      //column name
                description.options.type,                                                                        //data type | domain name
                (description.options.defaultValue != null) ? "DEFAULT " + description.options.defaultValue : "", //NOTE possible SQL injection here! //default clause
                String.Join(
                    " ",
                    Enumerable.Empty <string>()
                    .ConcatScalar(description.options.isNotNull ? "NOT NULL" : ((specific & Specific.OracleNullExtension) == Specific.OracleNullExtension ? "NULL" : null))
                    .ConcatScalar((columnSpecific & ColumnSpecific.PrimaryKey) == ColumnSpecific.PrimaryKey ? "PRIMARY KEY" : null)
                    .ToArray()
                    ),      //column constraint definition
                ""          //collate clause
                ));
 }
 public TableDescription(string table, ColumnDescription primaryKey, IEnumerable <ColumnDescription> columns)
     : this(table, primaryKey, columns.ToArray())
 {
 }
 public TableDescription(string table, ColumnDescription primaryKey, params ColumnDescription[] columns)
 {
     this.table      = table;
     this.primaryKey = primaryKey;
     this.columns    = columns;
 }
Beispiel #9
0
 public string ModifyColumnPostgresStyle(ColumnDescription description)
 {
     return(_AlterTableStatement(description.column.tableName, _ModifyColumnDefinitionPostgresStyle(description)));
 }
Beispiel #10
0
 public string CreateColumn(ColumnDescription description)
 {
     return(_AlterTableStatement(description.column.tableName, _AddColumnDefinition(description)));
 }
Beispiel #11
0
 private string _ModifyColumnDefinitionPostgresStyle(ColumnDescription description)
 {
     throw new NotImplementedException();
 }
Beispiel #12
0
 public void ModifyColumn(ColumnDescription description)
 {
     this.traits.ModifyColumn(this.CreateTextCommand, description);
 }