public override string Generate(RenameColumnExpression expression)
        {
            // may need to add definition to end. blerg
            //return String.Format("ALTER TABLE `{0}` CHANGE COLUMN {1} {2}", expression.TableName, expression.OldName, expression.NewName);

            // NOTE: The above does not work, as the CHANGE COLUMN syntax in Mysql requires the column definition to be re-specified,
            // even if it has not changed; so marking this as not working for now
            return compatabilityMode.HandleCompatabilty("Renaming of columns is not supporteed for MySql");
        }
        public void ReverseSetsTableNameOldNameAndNewNameOnGeneratedExpression()
        {
            var expression = new RenameColumnExpression { TableName = "Bacon", OldName = "BaconId", NewName = "ChunkyBaconId" };
            var reverse = expression.Reverse() as RenameColumnExpression;

            reverse.TableName.ShouldBe("Bacon");
            reverse.OldName.ShouldBe("ChunkyBaconId");
            reverse.NewName.ShouldBe("BaconId");
        }
Esempio n. 3
0
 public override string Generate(RenameColumnExpression expression)
 {
     // may need to add definition to end. blerg
     return FormatExpression("ALTER TABLE {0} CHANGE COLUMN {1} {2}", expression.TableName, expression.OldName, expression.NewName);
 }
 public override string Generate(RenameColumnExpression expression)
 {
     return string.Format("sp_rename '{0}", base.Generate(expression));
 }
 public void ReverseReturnsRenameColumnExpression()
 {
     var expression = new RenameColumnExpression { TableName = "Bacon", OldName = "BaconId", NewName = "ChunkyBaconId" };
     var reverse = expression.Reverse();
     reverse.ShouldBeOfType<RenameColumnExpression>();
 }
 public override string Generate(RenameColumnExpression expression)
 {
     return String.Format("ALTER TABLE {0} RENAME COLUMN {1} TO {2}", expression.TableName, expression.OldName, expression.NewName);
 }
 public override string Generate(RenameColumnExpression expression)
 {
     truncator.Truncate(expression);
     return base.Generate(expression);
 }
Esempio n. 8
0
 public virtual void Process(RenameColumnExpression expression)
 {
     Process(Generator.Generate(expression));
 }
 public override string Generate(RenameColumnExpression expression)
 {
     return string.Format("ALTER TABLE {0}.{1} RENAME COLUMN {2} TO {3}", Quoter.QuoteSchemaName(expression.SchemaName), Quoter.QuoteTableName(expression.TableName), Quoter.QuoteColumnName(expression.OldName), Quoter.QuoteColumnName(expression.NewName));
 }
 public void ToStringIsDescriptive()
 {
     var expression = new RenameColumnExpression { TableName = "Bacon", OldName = "BaconId", NewName = "ChunkyBaconId" };
     expression.ToString().ShouldBe("RenameColumn Bacon BaconId to ChunkyBaconId");
 }
        public void CanRenameColumn()
        {
            var expression = new RenameColumnExpression();
            expression.TableName = "Table1";
            expression.OldName = "Column1";
            expression.NewName = "Column2";

            string sql = generator.Generate(expression);
            sql.ShouldBe("ALTER TABLE \"public\".\"Table1\" RENAME COLUMN \"Column1\" TO \"Column2\"");
        }
Esempio n. 12
0
 public override string Generate(RenameColumnExpression expression)
 {
     throw new NotImplementedException("Sqlite does not support renaming of columns in a safe way");
 }
Esempio n. 13
0
 public override string Generate(RenameColumnExpression expression)
 {
     return compatabilityMode.HandleCompatabilty("Sqlite does not support renaming of columns");
 }
 public override string Generate(RenameColumnExpression expression)
 {
     throw new DatabaseOperationNotSupportedException();
 }
 public override string Generate(RenameColumnExpression expression)
 {
     return FormatExpression("sp_rename '[{0}].[{1}]', [{2}]", expression.TableName, expression.OldName, expression.NewName);
 }
Esempio n. 16
0
        public override string Generate(RenameColumnExpression expression)
        {
            // may need to add definition to end. blerg
            //return String.Format("ALTER TABLE `{0}` CHANGE COLUMN {1} {2}", expression.TableName, expression.OldName, expression.NewName);

            // NOTE: The above does not work, as the CHANGE COLUMN syntax in Mysql requires the column definition to be re-specified,
            // even if it has not changed; so marking this as not working for now
            throw new NotImplementedException();
        }
 public IRenameColumnTableSyntax Column(string oldName)
 {
     var expression = new RenameColumnExpression { OldName = oldName };
     _context.Expressions.Add(expression);
     return new RenameColumnExpressionBuilder(expression);
 }
 public override string Generate(RenameColumnExpression expression)
 {
     return String.Format("sp_rename '{0}[{1}].[{2}]', '{3}'", FormatSchema(expression.SchemaName, false), FormatSqlEscape(expression.TableName), FormatSqlEscape(expression.OldName), FormatSqlEscape(expression.NewName));
 }
Esempio n. 19
0
 public abstract string Generate(RenameColumnExpression expression);
 public override string Generate(RenameColumnExpression expression)
 {
     return string.Format("sp_rename '{0}.{1}", Quoter.QuoteSchemaName(expression.SchemaName), base.Generate(expression));
 }
 public void Truncate(RenameColumnExpression expression)
 {
     expression.OldName = Truncate(expression.OldName);
     expression.NewName = Truncate(expression.NewName);
     expression.TableName = Truncate(expression.TableName);
 }
Esempio n. 22
0
 public override string Generate(RenameColumnExpression expression)
 {
     return compatabilityMode.HandleCompatabilty("Renaming of columns is not supporteed for MySql");
 }
 public override string Generate(RenameColumnExpression expression)
 {
     return String.Format(RenameColumn, Quoter.QuoteTableName(expression.TableName), Quoter.QuoteColumnName(Quoter.QuoteCommand(expression.OldName)), Quoter.QuoteCommand(expression.NewName));
 }
        public void CanRenameColumn()
        {
            var expression = new RenameColumnExpression();
            expression.TableName = "Table1";
            expression.OldName = "Column1";
            expression.NewName = "Column2";

            var sql = generator.Generate(expression);
            sql.ShouldBe("sp_rename '[Table1].[Column1]', [Column2]");
        }
Esempio n. 25
0
 public override string Generate(RenameColumnExpression expression)
 {
     throw new System.NotImplementedException();
 }
 public void ErrorIsReturnedWhenNewNameIsEmptyString()
 {
     var expression = new RenameColumnExpression { NewName = String.Empty };
     var errors = ValidationHelper.CollectErrors(expression);
     errors.ShouldContain(ErrorMessages.NewColumnNameCannotBeNullOrEmpty);
 }
 public override string Generate(RenameColumnExpression expression)
 {
     return String.Format(RenameColumn, expression.TableName, expression.OldName, expression.NewName);
 }
 public void ErrorIsReturnedWhenOldNameIsNull()
 {
     var expression = new RenameColumnExpression { OldName = null };
     var errors = ValidationHelper.CollectErrors(expression);
     errors.ShouldContain(ErrorMessages.OldColumnNameCannotBeNullOrEmpty);
 }
Esempio n. 29
0
        public void CanRenameColumn()
        {
            var expression = new RenameColumnExpression();
            expression.TableName = "Table1";
            expression.OldName = "Column1";
            expression.NewName = "Column2";

            var sql = generator.Generate(expression);
            // MySql does not appear to have a way to change column without re-specifying the existing column definition
            sql.ShouldBe("ALTER TABLE `Table1` CHANGE COLUMN `Column1` `Column2` EXISTING_DEFINITION_HERE");
        }
 public override string Generate(RenameColumnExpression expression)
 {
     return FormatExpression("sp_rename '{0}[{1}].[{2}]', [{3}]", FormatSchema(expression.SchemaName, false), expression.TableName, expression.OldName, expression.NewName);
 }