schambers/fluentmigrator — Issue #222: Alter default values on SqlServer to a string generates an exception
Author: tommarien
Created: 2012-01-03 20:16:21+00:00
State: open

Alter.Column("Label").OnTable("SomeTable").AsAnsiString(40).WithDefaultValue("");
As this generates syntax error on sql, this generates following sql ALTER TABLE [dbo].[SomeTable] WITH NOCHECK ADD CONSTRAINT [' + @default + '] DEFAULT('') FOR [Label]'
Unclosed string

* Change in public override string Generate(AlterDefaultConstraintExpression expression): Quoter.QuoteValue(..) to Quoter.QuoteValue(...).Replace(Quoter.ValueQuote, Quoter.EscapeValueQuote) only if value is not null

* Remove Exec for the ALTER TABLE ADD CONSTRAINT and directly execute it : i prefer this option, but here we need to reconvention the default constraints name