PgSql Updateable.SetColumn datetime== null bug

This commit is contained in:
SUNKAIXUAN 2021-03-26 21:39:36 +08:00
parent cbabfa5f71
commit 359757a076
2 changed files with 20 additions and 1 deletions

View File

@ -54,8 +54,20 @@ namespace OrmTest
UValidate.Check(sql.Key, @"UPDATE ""diary"" SET UValidate.Check(sql.Key, @"UPDATE ""diary"" SET
""typeid"" = @Const0 WHERE ( ""id"" = @ID1 )", "Updateable"); ""typeid"" = @Const0 WHERE ( ""id"" = @ID1 )", "Updateable");
Db.Updateable<OrderModel>().SetColumns(it => new OrderModel()
{
CreateTime = null
}).Where(it => it.Id == 1).ExecuteCommand();
} }
} }
[SugarTable("order")]
public class OrderModel
{
[SugarColumn(IsPrimaryKey =true)]
public int Id { get; set; }
public DateTime? CreateTime { get; set; }
}
public class UnitSaveDiary public class UnitSaveDiary
{ {
public int ID { get; set; } public int ID { get; set; }

View File

@ -134,7 +134,14 @@ namespace SqlSugar
base.Start(); base.Start();
string parameterName = this.Context.SqlParameterKeyWord + ExpressionConst.Const + this.Context.ParameterIndex; string parameterName = this.Context.SqlParameterKeyWord + ExpressionConst.Const + this.Context.ParameterIndex;
parameter.Context.Result.Append(base.Context.GetEqString(memberName, parameterName)); parameter.Context.Result.Append(base.Context.GetEqString(memberName, parameterName));
this.Context.Parameters.Add(new SugarParameter(parameterName, parameter.CommonTempData)); var addItem = new SugarParameter(parameterName, parameter.CommonTempData);
var dataType = UtilMethods.GetUnderType(item.Type);
if (addItem.Value == null && dataType == UtilConstants.DateType)
{
addItem.DbType = System.Data.DbType.Date;
}
this.Context.Parameters.Add(addItem);
this.Context.ParameterIndex++; this.Context.ParameterIndex++;
} }
else if (item is MemberExpression) else if (item is MemberExpression)