From 053f24e7677c01afbb153a5c1c986aee41ea2e3d Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Tue, 20 Dec 2022 16:09:05 +0800 Subject: [PATCH] Update pgsdql --- Src/Asp.Net/PgSqlTest/UnitTest/UInsert3.cs | 45 ++++++++++++++++++- .../SqlBuilder/PostgreSQLUpdateBuilder.cs | 2 +- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/Src/Asp.Net/PgSqlTest/UnitTest/UInsert3.cs b/Src/Asp.Net/PgSqlTest/UnitTest/UInsert3.cs index 1a948545e..70d6f478a 100644 --- a/Src/Asp.Net/PgSqlTest/UnitTest/UInsert3.cs +++ b/Src/Asp.Net/PgSqlTest/UnitTest/UInsert3.cs @@ -22,6 +22,47 @@ namespace OrmTest }).ExecuteCommand(); db.Insertable(new ORDER() { Name = "a" }).ExecuteCommand(); + + db.Updateable(new Order() + { + CustomId = 1, + CreateTime = DateTime.Now, + Id = 1, + Price = 1, + Name = "a" + }).ExecuteCommand(); + + db.Updateable(new List(){ new Order() + { + CustomId = 1, + CreateTime = DateTime.Now, + Id = 1, + Price = 1, + Name = "a" + }, + new Order() + { + CustomId = 1, + CreateTime = DateTime.Now, + Id = 1, + Price = 1, + Name = "a" + } }).ExecuteCommand(); + + + db.Updateable().SetColumns(it => new Order() + { + CustomId = 1, + Price = 1, + Name = "a" + }, true).Where(it => it.Id == 1).ExecuteCommand(); + + db.Updateable().SetColumns(it => new ORDER() + { + CustomId = 1, + Price = 1, + Name = "a" + }, true).Where(it => it.Id == 1).ExecuteCommand(); } public class Order @@ -33,7 +74,7 @@ namespace OrmTest /// public string Name { get; set; } public decimal Price { get; set; } - [SugarColumn(InsertServerTime =true)] + [SugarColumn(InsertServerTime =true,UpdateServerTime =true)] public DateTime CreateTime { get; set; } [SugarColumn(IsNullable = true)] public int CustomId { get; set; } @@ -48,7 +89,7 @@ namespace OrmTest /// public string Name { get; set; } public decimal Price { get; set; } - [SugarColumn(InsertSql = "'2020-1-1'")] + [SugarColumn(InsertSql = "'2020-1-1'",UpdateSql = "'2020-1-1'")] public DateTime CreateTime { get; set; } [SugarColumn(IsNullable = true)] public int CustomId { get; set; } diff --git a/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/SqlBuilder/PostgreSQLUpdateBuilder.cs b/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/SqlBuilder/PostgreSQLUpdateBuilder.cs index f2aea0e1f..9c98baa96 100644 --- a/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/SqlBuilder/PostgreSQLUpdateBuilder.cs +++ b/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/SqlBuilder/PostgreSQLUpdateBuilder.cs @@ -168,7 +168,7 @@ namespace SqlSugar dbType = "varchar"; } } - return string.Format("CAST({0} AS {1})", FormatValue(it.Value,it.DbColumnName,i,it), dbType); + return string.Format("CAST({0} AS {1})", base.GetDbColumn(it,FormatValue(it.Value,it.DbColumnName,i,it)), dbType); })) + ")"); ++i;