From e846e30d3024b5fa2ae7a2a30c522e582d3cd46a Mon Sep 17 00:00:00 2001 From: oldme Date: Sun, 25 Feb 2024 22:44:32 +0800 Subject: [PATCH] up --- .../drivers/mysql/mysql_z_unit_model_test.go | 40 ++++++++++++++++++- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/contrib/drivers/mysql/mysql_z_unit_model_test.go b/contrib/drivers/mysql/mysql_z_unit_model_test.go index 5d01841d062..3bdf98a794f 100644 --- a/contrib/drivers/mysql/mysql_z_unit_model_test.go +++ b/contrib/drivers/mysql/mysql_z_unit_model_test.go @@ -3646,7 +3646,7 @@ func Test_Model_OnDuplicate(t *testing.T) { table := createInitTable() defer dropTable(table) - // string. + // string type 1. gtest.C(t, func(t *gtest.T) { data := g.Map{ "id": 1, @@ -3664,6 +3664,24 @@ func Test_Model_OnDuplicate(t *testing.T) { t.Assert(one["nickname"], "name_1") }) + // string type 2. + gtest.C(t, func(t *gtest.T) { + data := g.Map{ + "id": 1, + "passport": "pp1", + "password": "pw1", + "nickname": "n1", + "create_time": "2016-06-06", + } + _, err := db.Model(table).OnDuplicate("passport", "password").Data(data).Save() + t.AssertNil(err) + one, err := db.Model(table).WherePri(1).One() + t.AssertNil(err) + t.Assert(one["passport"], data["passport"]) + t.Assert(one["password"], data["password"]) + t.Assert(one["nickname"], "name_1") + }) + // slice. gtest.C(t, func(t *gtest.T) { data := g.Map{ @@ -3729,7 +3747,7 @@ func Test_Model_OnDuplicateEx(t *testing.T) { table := createInitTable() defer dropTable(table) - // string. + // string type 1. gtest.C(t, func(t *gtest.T) { data := g.Map{ "id": 1, @@ -3747,6 +3765,24 @@ func Test_Model_OnDuplicateEx(t *testing.T) { t.Assert(one["nickname"], "name_1") }) + // string type 2. + gtest.C(t, func(t *gtest.T) { + data := g.Map{ + "id": 1, + "passport": "pp1", + "password": "pw1", + "nickname": "n1", + "create_time": "2016-06-06", + } + _, err := db.Model(table).OnDuplicateEx("nickname", "create_time").Data(data).Save() + t.AssertNil(err) + one, err := db.Model(table).WherePri(1).One() + t.AssertNil(err) + t.Assert(one["passport"], data["passport"]) + t.Assert(one["password"], data["password"]) + t.Assert(one["nickname"], "name_1") + }) + // slice. gtest.C(t, func(t *gtest.T) { data := g.Map{