Fixes issue with migrations running with a Decimal column:
The logic would produce incorrect syntax. Fixed the default string column for sql server, made them all consistent. Moved ctor logic for shared sql syntax providers to the base class. Created formatted Decimal column definitions so that a custom precision/scale works. Set the migration to use the default precision/scale values. Removes the pattern validators because they don't do anything... due to the fix-number directive which has it's own issues but we won't solve those now.
This commit is contained in:
@@ -32,6 +32,13 @@ namespace Umbraco.Core.Persistence.SqlSyntax
|
||||
FormatPrimaryKey,
|
||||
FormatIdentity
|
||||
};
|
||||
|
||||
//defaults for all providers
|
||||
StringLengthColumnDefinitionFormat = StringLengthUnicodeColumnDefinitionFormat;
|
||||
StringColumnDefinition = string.Format(StringLengthColumnDefinitionFormat, DefaultStringLength);
|
||||
DecimalColumnDefinition = string.Format(DecimalColumnDefinitionFormat, DefaultDecimalPrecision, DefaultDecimalScale);
|
||||
|
||||
InitColumnTypeMap();
|
||||
}
|
||||
|
||||
public string GetWildcardPlaceholder()
|
||||
@@ -41,9 +48,12 @@ namespace Umbraco.Core.Persistence.SqlSyntax
|
||||
|
||||
public string StringLengthNonUnicodeColumnDefinitionFormat = "VARCHAR({0})";
|
||||
public string StringLengthUnicodeColumnDefinitionFormat = "NVARCHAR({0})";
|
||||
public string DecimalColumnDefinitionFormat = "DECIMAL({0},{1})";
|
||||
|
||||
public string DefaultValueFormat = "DEFAULT ({0})";
|
||||
public int DefaultStringLength = 255;
|
||||
public int DefaultDecimalPrecision = 20;
|
||||
public int DefaultDecimalScale = 9;
|
||||
|
||||
//Set by Constructor
|
||||
public string StringColumnDefinition;
|
||||
@@ -55,7 +65,7 @@ namespace Umbraco.Core.Persistence.SqlSyntax
|
||||
public string GuidColumnDefinition = "GUID";
|
||||
public string BoolColumnDefinition = "BOOL";
|
||||
public string RealColumnDefinition = "DOUBLE";
|
||||
public string DecimalColumnDefinition = "DECIMAL";
|
||||
public string DecimalColumnDefinition;
|
||||
public string BlobColumnDefinition = "BLOB";
|
||||
public string DateTimeColumnDefinition = "DATETIME";
|
||||
public string TimeColumnDefinition = "DATETIME";
|
||||
@@ -431,6 +441,13 @@ namespace Umbraco.Core.Persistence.SqlSyntax
|
||||
return string.Format(StringLengthColumnDefinitionFormat, valueOrDefault);
|
||||
}
|
||||
|
||||
if (type == typeof(decimal))
|
||||
{
|
||||
var precision = column.Size != default(int) ? column.Size : DefaultDecimalPrecision;
|
||||
var scale = column.Precision != default(int) ? column.Precision : DefaultDecimalScale;
|
||||
return string.Format(DecimalColumnDefinitionFormat, precision, scale);
|
||||
}
|
||||
|
||||
string definition = DbTypeMap.ColumnTypeMap.First(x => x.Key == type).Value;
|
||||
string dbTypeDefinition = column.Size != default(int)
|
||||
? string.Format("{0}({1})", definition, column.Size)
|
||||
|
||||
Reference in New Issue
Block a user