- 修复 decimal? 可空数字设置 Column Scale 无效的问题(decimal正常);

This commit is contained in:
28810
2020-10-14 17:55:49 +08:00
parent 7153cdf9f6
commit 38d8a3756c
4 changed files with 221 additions and 173 deletions

View File

@ -228,7 +228,7 @@ namespace FreeSql.Internal
col.DbDefaultValue = colattr.InsertValueSql;
col.DbInsertValue = colattr.InsertValueSql;
}
if (colattr.MapType == typeof(string) && colattr.StringLength != 0)
if (colattr.MapType.NullableTypeOrThis() == typeof(string) && colattr.StringLength != 0)
{
int strlen = colattr.StringLength;
var charPatten = @"(CHARACTER|CHAR2|CHAR)\s*(\([^\)]*\))?";
@ -328,8 +328,10 @@ namespace FreeSql.Internal
break;
}
}
if (colattr.MapType == typeof(decimal) && colattr.Precision > 0)
if (colattr.MapType.NullableTypeOrThis() == typeof(decimal) && (colattr.Precision > 0 || colattr.Scale > 0))
{
if (colattr.Precision <= 0) colattr.Precision = 10;
if (colattr.Scale <= 0) colattr.Scale = 0;
var decimalPatten = @"(DECIMAL|NUMERIC|NUMBER)\s*(\([^\)]*\))?";
colattr.DbType = Regex.Replace(colattr.DbType, decimalPatten, $"$1({colattr.Precision},{colattr.Scale})");
}