diff --git a/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/CodeFirst/PostgreSQLCodeFirst.cs b/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/CodeFirst/PostgreSQLCodeFirst.cs index bd89f5f85..caec5a8c3 100644 --- a/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/CodeFirst/PostgreSQLCodeFirst.cs +++ b/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/CodeFirst/PostgreSQLCodeFirst.cs @@ -37,6 +37,11 @@ namespace SqlSugar ColumnDescription = item.ColumnDescription, Length = item.Length }; + if (propertyType == UtilConstants.DecType) + { + result.Scale = item.DecimalDigits; + result.DecimalDigits = item.DecimalDigits; + } GetDbType(item, propertyType, result); if (result.DataType.Equals("varchar", StringComparison.CurrentCultureIgnoreCase) && result.Length == 0) { diff --git a/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/DbMaintenance/PostgreSQLDbMaintenance.cs b/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/DbMaintenance/PostgreSQLDbMaintenance.cs index ad9b46b47..e8e94bb9d 100644 --- a/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/DbMaintenance/PostgreSQLDbMaintenance.cs +++ b/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/DbMaintenance/PostgreSQLDbMaintenance.cs @@ -360,6 +360,10 @@ namespace SqlSugar dataType = "varchar"; } string dataSize = item.Length > 0 ? string.Format("({0})", item.Length) : null; + if (item.DecimalDigits > 0&&item.Length>0 && dataType == "numeric") + { + dataSize = $"({item.Length},{item.DecimalDigits})"; + } string nullType = item.IsNullable ? this.CreateTableNull : CreateTableNotNull; string primaryKey = null; string addItem = string.Format(this.CreateTableColumn, this.SqlBuilder.GetTranslationColumnName(columnName.ToLower()), dataType, dataSize, nullType, primaryKey, "");