diff --git a/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/DbMaintenance/PostgreSQLDbMaintenance.cs b/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/DbMaintenance/PostgreSQLDbMaintenance.cs index 77cd2a828..4b57a7f27 100644 --- a/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/DbMaintenance/PostgreSQLDbMaintenance.cs +++ b/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/DbMaintenance/PostgreSQLDbMaintenance.cs @@ -385,7 +385,16 @@ WHERE tgrelid = '"+tableName+"'::regclass"); } var oldDatabaseName = this.Context.Ado.Connection.Database; var connection = this.Context.CurrentConnectionConfig.ConnectionString; - connection = connection.Replace(oldDatabaseName, "postgres"); + if (Regex.Matches(connection, oldDatabaseName).Count > 1) + { + var builder = new Npgsql.NpgsqlConnectionStringBuilder(connection); + builder.Database = "postgres"; + connection = builder.ConnectionString; + } + else + { + connection = connection.Replace(oldDatabaseName, "postgres"); + } var newDb = new SqlSugarClient(new ConnectionConfig() { DbType = this.Context.CurrentConnectionConfig.DbType, diff --git a/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/SqlBuilder/PostgreSQLInsertBuilder.cs b/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/SqlBuilder/PostgreSQLInsertBuilder.cs index 6d2d7742c..0ae84067d 100644 --- a/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/SqlBuilder/PostgreSQLInsertBuilder.cs +++ b/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/SqlBuilder/PostgreSQLInsertBuilder.cs @@ -1,4 +1,5 @@ using System; +using System.Globalization; using System.Linq; using System.Text; @@ -93,6 +94,10 @@ namespace SqlSugar { return FormatDateTimeOffset(it.Value); } + else if (it.Value is decimal v) + { + return v.ToString(CultureInfo.InvariantCulture); + } else if (it.IsArray&&it.Value!=null) { return FormatValue(it.Value,it.PropertyName,i,it); @@ -172,6 +177,10 @@ namespace SqlSugar { return "'" + value.ToString().ToSqlFilter() + "'"; } + else if (value is decimal v) + { + return v.ToString(CultureInfo.InvariantCulture); + } else { return "'" + value.ToString() + "'"; @@ -229,6 +238,10 @@ namespace SqlSugar { return N + "'" + Convert.ToDouble(value).ToString() + "'"; } + else if (value is decimal v) + { + return v.ToString(CultureInfo.InvariantCulture); + } else { return N + "'" + value.ToString() + "'"; diff --git a/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/SqlBuilder/PostgreSQLUpdateBuilder.cs b/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/SqlBuilder/PostgreSQLUpdateBuilder.cs index 64225d199..b29572e07 100644 --- a/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/SqlBuilder/PostgreSQLUpdateBuilder.cs +++ b/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/SqlBuilder/PostgreSQLUpdateBuilder.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.Linq; using System.Text; @@ -43,15 +44,15 @@ namespace SqlSugar else { var type =UtilMethods.GetUnderType(value.GetType()); - if (type == UtilConstants.ByteArrayType||type == UtilConstants.DateType||columnInfo.IsArray||columnInfo.IsJson) + if (type == UtilConstants.ByteArrayType || type == UtilConstants.DateType || columnInfo.IsArray || columnInfo.IsJson) { - var parameterName = this.Builder.SqlParameterKeyWord + name +"_"+ i; + var parameterName = this.Builder.SqlParameterKeyWord + name + "_" + i; var paramter = new SugarParameter(parameterName, value); - if (columnInfo.IsJson) + if (columnInfo.IsJson) { paramter.IsJson = true; } - if (columnInfo.IsArray) + if (columnInfo.IsArray) { paramter.IsArray = true; } @@ -86,6 +87,10 @@ namespace SqlSugar { return "'" + value.ToString().ToSqlFilter() + "'"; } + else if (value is decimal v) + { + return v.ToString(CultureInfo.InvariantCulture); + } else { return "'" + value.ToString() + "'";