Synchronization code

This commit is contained in:
sunkaixuan 2025-03-17 20:02:24 +08:00
parent f1733039d2
commit d9c8bb5ca4
4 changed files with 26 additions and 4 deletions

View File

@ -53,7 +53,7 @@ namespace SqlSugar
}
}
public partial class DmMethod : DefaultDbMethod, IDbMethods
{
{
public override string WeekOfYear(MethodCallExpressionModel mode)
{
var parameterNameA = mode.Args[0].MemberName;

View File

@ -54,7 +54,7 @@ namespace SqlSugar
{
sql = sql.Replace("sys_", "pg_");
}
else if (IsSqlServerModel())
else if (IsSqlServerModel())
{
sql = sql.Replace("sys_", "pg_");
@ -67,6 +67,10 @@ namespace SqlSugar
sql = sql.Replace("pcolumn on pcolumn.table_name = ptables.tablename", "pcolumn on pcolumn.table_name::text = ptables.tablename::text ");
sql = sql.Replace("pkey on pcolumn.table_name = pkey.relname", "pkey on pcolumn.table_name::text = pkey.relname::text ");
}
else if (IsMySql())
{
sql = sql.Replace("pcolumn.udt_name", "pcolumn.data_type");
}
return sql;
}
}
@ -697,6 +701,10 @@ WHERE tgrelid = '" + tableName + "'::regclass");
{
return this.Context.CurrentConnectionConfig?.MoreSettings?.DatabaseModel == DbType.SqlServer;
}
private bool IsMySql()
{
return this.Context.CurrentConnectionConfig?.MoreSettings?.DatabaseModel == DbType.MySql;
}
#endregion
}
}

View File

@ -86,6 +86,10 @@ namespace SqlSugar
{
return FormatDateTimeOffset(it.Value);
}
else if (it.Value is bool&& (IsMySqlModel()|| IsSqlServerModel()))
{
return Convert.ToBoolean(it.Value)?"1":"0";
}
else
{
value = it.Value;
@ -109,7 +113,10 @@ namespace SqlSugar
{
return this.Context?.CurrentConnectionConfig?.MoreSettings?.DatabaseModel == DbType.SqlServer;
}
private bool IsMySqlModel()
{
return this.Context?.CurrentConnectionConfig?.MoreSettings?.DatabaseModel == DbType.MySql;
}
public override string FormatDateTimeOffset(object value)
{
var date = UtilMethods.ConvertFromDateTimeOffset((DateTimeOffset)value);

View File

@ -52,7 +52,14 @@ namespace SqlSugar
{
if (PartitionByValue.HasValue())
{
return base.ToSqlString();
if (this.Context?.CurrentConnectionConfig?.MoreSettings?.DatabaseModel == DbType.SqlServer)
{
return base.ToSqlString();
}
else
{
return base.ToSqlString().Replace(" GetDate() ", " NOW() ");
}
}
base.AppendFilter();
string oldOrderValue = this.OrderByValue;