Synchronization code

This commit is contained in:
sunkaixuan 2025-04-02 22:46:38 +08:00
parent 44a15fdbfa
commit 5a1164e536
3 changed files with 32 additions and 5 deletions

View File

@ -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,

View File

@ -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() + "'";

View File

@ -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() + "'";