-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
209 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// Copyright 2019 gf Author(https://github.com/gogf/gf). All Rights Reserved. | ||
// | ||
// This Source Code Form is subject to the terms of the MIT License. | ||
// If a copy of the MIT was not distributed with this file, | ||
// You can obtain one at https://github.com/gogf/gf. | ||
|
||
package dm_test | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
"github.com/gogf/gf/v2/os/gtime" | ||
"github.com/gogf/gf/v2/test/gtest" | ||
"github.com/gogf/gf/v2/text/gstr" | ||
) | ||
|
||
func Test_Issue2594(t *testing.T) { | ||
table := "HANDLE_INFO" | ||
array := gstr.SplitAndTrim(gtest.DataContent(`issue`, `2594`, `sql.sql`), ";") | ||
for _, v := range array { | ||
if _, err := db.Exec(ctx, v); err != nil { | ||
gtest.Error(err) | ||
} | ||
} | ||
defer dropTable(table) | ||
|
||
type HandleValueMysql struct { | ||
Index int64 `orm:"index"` | ||
Type string `orm:"type"` | ||
Data []byte `orm:"data"` | ||
} | ||
type HandleInfoMysql struct { | ||
Id int `orm:"id,primary" json:"id"` | ||
SubPrefix string `orm:"sub_prefix"` | ||
Prefix string `orm:"prefix"` | ||
HandleName string `orm:"handle_name"` | ||
CreateTime time.Time `orm:"create_time"` | ||
UpdateTime time.Time `orm:"update_time"` | ||
Value []HandleValueMysql `orm:"value"` | ||
} | ||
|
||
gtest.C(t, func(t *gtest.T) { | ||
var h1 = HandleInfoMysql{ | ||
SubPrefix: "p_", | ||
Prefix: "m_", | ||
HandleName: "name", | ||
CreateTime: gtime.Now().FormatTo("Y-m-d H:i:s").Time, | ||
UpdateTime: gtime.Now().FormatTo("Y-m-d H:i:s").Time, | ||
Value: []HandleValueMysql{ | ||
{ | ||
Index: 10, | ||
Type: "t1", | ||
Data: []byte("abc"), | ||
}, | ||
{ | ||
Index: 20, | ||
Type: "t2", | ||
Data: []byte("def"), | ||
}, | ||
}, | ||
} | ||
_, err := db.Model(table).OmitEmptyData().Insert(h1) | ||
t.AssertNil(err) | ||
|
||
var h2 HandleInfoMysql | ||
err = db.Model(table).Scan(&h2) | ||
t.AssertNil(err) | ||
|
||
h1.Id = 1 | ||
t.Assert(h1, h2) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
CREATE TABLE HANDLE_INFO ( | ||
ID INT IDENTITY (1, 1) NOT NULL, | ||
SUB_PREFIX VARCHAR(128), | ||
PREFIX VARCHAR(256), | ||
HANDLE_NAME VARCHAR(1024) NOT NULL, | ||
CREATE_TIME TIMESTAMP, | ||
UPDATE_TIME TIMESTAMP, | ||
VALUE BLOB , | ||
NOT CLUSTER PRIMARY KEY (ID) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.