Esempio n. 1
0
 public override void WriteColumnChanges(ColumnModifications col)
 {
     Builder.AppendFormat("alter table {0} alter column {1} ", SqlServerProvider.EscapeIdentifier(col.TableName),
                          SqlServerProvider.EscapeIdentifier(col.Current.Name));
     _writer.Write(col);
     Builder.AppendLine(";");
 }
Esempio n. 2
0
        public void WriteColumnsChanges(TableSchema table)
        {
            var mods = table.ModifiedColumns.ChangedColumns;

            if (mods.Count == 0)
            {
                return;
            }
            FillRealTableSchema(table);
            var writer = new SqlServerCompactColumnWriter(Builder);

            foreach (var col in mods.Where(c => c.DefaultDropped))
            {
                Builder.AppendFormat("alter table {0} alter column {1} drop default;\n", table.Name, col.Name);
            }

            foreach (var col in mods.Where(d => !d.IsDropped))
            {
                Builder.AppendFormat("alter table [{0}] alter column {1} ", table.Name,
                                     SqlServerProvider.EscapeIdentifier(col.Current.Name));
                writer.Write(col);
                Builder.AppendLine(";");
            }

            foreach (var cl in mods.Where(c => !string.IsNullOrEmpty(c.DefaultValue)))
            {
                Builder.AppendFormat("alter table {0} alter column {1} set default '{2}';\n", table.Name, cl.Name,
                                     cl.DefaultValue);
            }
        }
Esempio n. 3
0
 public WhereCriteriaTests()
 {
     _sb  = new StringBuilder();
     _pm  = new ParametersManager();
     _fRm = new Mock <IDbProviderExpressionHelper>();
     _fRm.Setup(d => d.EscapeName(It.IsAny <string>())).Returns((string v) => SqlServerProvider.EscapeIdentifier(v));
     _fRm.Setup(d => d.FormatBoolean(It.IsAny <bool>())).Returns((bool v) => v == true?"1":"0");
     _w = new ExpressionWriter(_sb, _fRm.Object, _pm);
 }
Esempio n. 4
0
 public override void WriteDropDefault(ColumnModifications col)
 {
     if (!col.Current.DefaultConstraintName.IsNullOrEmpty())
     {
         Builder.AppendFormat("alter table {0} drop constraint {1};\n",
                              SqlServerProvider.EscapeIdentifier(col.TableName),
                              col.Current.DefaultConstraintName);
     }
 }
Esempio n. 5
0
 public override string EscapeName(string s)
 {
     return(SqlServerProvider.EscapeIdentifier(s));
 }
Esempio n. 6
0
 protected override string Escape(string name)
 {
     return(SqlServerProvider.EscapeIdentifier(name));
 }
Esempio n. 7
0
 protected override void WriteTableName()
 {
     Builder.Append(SqlServerProvider.EscapeIdentifier(Table.Name));
 }
Esempio n. 8
0
 protected override string FormatName(string s)
 {
     return(SqlServerProvider.EscapeIdentifier(s));
 }
Esempio n. 9
0
 public override void WriteSetDefault(ColumnModifications col)
 {
     Builder.AppendFormat("alter table {0} add constraint {1} default ('{2}') for {3};\n",
                          SqlServerProvider.EscapeIdentifier(col.TableName),
                          string.Format("DF_{0}_{1}", col.TableName, col.Name), col.DefaultValue, col.Name);
 }
Esempio n. 10
0
 public override void provider_escape_name()
 {
     Assert.Equal("[dbo.table]", SqlServerProvider.EscapeIdentifier("dbo.table"));
 }
Esempio n. 11
0
 protected override void WriteOnTable()
 {
     Builder.AppendFormat(" on {0}", SqlServerProvider.EscapeIdentifier(Item.TableName));
 }
Esempio n. 12
0
 protected override void WriteColumn(IndexColumn column)
 {
     Builder.Append(SqlServerProvider.EscapeIdentifier(column.Name));
 }
Esempio n. 13
0
 protected override void WriteIndexName()
 {
     Builder.Append(SqlServerProvider.EscapeIdentifier(Index.Name));
 }
Esempio n. 14
0
 public void anything_with_dot_will_be_escaped_as_schema_table()
 {
     Assert.Equal("[dbo].[mytable]", SqlServerProvider.EscapeIdentifier("dbo.mytable"));
 }
Esempio n. 15
0
 public void common_escaping()
 {
     Assert.Equal("[mytable]", SqlServerProvider.EscapeIdentifier("mytable"));
     Assert.Equal("[my table]", SqlServerProvider.EscapeIdentifier("my table"));
 }
Esempio n. 16
0
 public void already_escaped_id_are_not_escaped()
 {
     Assert.Equal("dbo.[my.table]", SqlServerProvider.EscapeIdentifier("dbo.[my.table]"));
     Assert.Equal("dbo.\"my.table\"", SqlServerProvider.EscapeIdentifier("dbo.\"my.table\""));
 }