Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
beego
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
beego
Commits
3ca44071
Commit
3ca44071
authored
Mar 26, 2016
by
miraclesu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
orm: insert specified values for insertMulti
parent
e0a36fb6
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
6 deletions
+21
-6
db.go
orm/db.go
+2
-4
orm_test.go
orm/orm_test.go
+19
-2
No files found.
orm/db.go
View file @
3ca44071
...
...
@@ -386,16 +386,14 @@ func (d *dbBase) InsertMulti(q dbQuerier, mi *modelInfo, sind reflect.Value, bul
// }
if
i
==
1
{
vus
,
err
:=
d
.
collectValues
(
mi
,
ind
,
mi
.
fields
.
dbcols
,
tru
e
,
true
,
&
names
,
tz
)
vus
,
err
:=
d
.
collectValues
(
mi
,
ind
,
mi
.
fields
.
dbcols
,
fals
e
,
true
,
&
names
,
tz
)
if
err
!=
nil
{
return
cnt
,
err
}
values
=
make
([]
interface
{},
bulk
*
len
(
vus
))
nums
+=
copy
(
values
,
vus
)
}
else
{
vus
,
err
:=
d
.
collectValues
(
mi
,
ind
,
mi
.
fields
.
dbcols
,
true
,
true
,
nil
,
tz
)
vus
,
err
:=
d
.
collectValues
(
mi
,
ind
,
mi
.
fields
.
dbcols
,
false
,
true
,
nil
,
tz
)
if
err
!=
nil
{
return
cnt
,
err
}
...
...
orm/orm_test.go
View file @
3ca44071
...
...
@@ -2032,9 +2032,26 @@ func TestInsertAuto(t *testing.T) {
Email
:
"auto@gmail.com"
,
}
s
id
,
err
:=
dORM
.
Insert
(
su
)
n
id
,
err
:=
dORM
.
Insert
(
su
)
throwFail
(
t
,
err
)
throwFail
(
t
,
AssertIs
(
id
,
sid
))
throwFail
(
t
,
AssertIs
(
nid
,
id
))
users
:=
[]
User
{
{
ID
:
int
(
id
+
100
),
UserName
:
"auto_100"
},
{
ID
:
int
(
id
+
110
),
UserName
:
"auto_110"
},
{
ID
:
int
(
id
+
120
),
UserName
:
"auto_120"
},
}
num
,
err
:=
dORM
.
InsertMulti
(
100
,
users
)
throwFail
(
t
,
err
)
throwFail
(
t
,
AssertIs
(
num
,
3
))
u
=
&
User
{
UserName
:
"auto_121"
,
}
nid
,
err
=
dORM
.
Insert
(
u
)
throwFail
(
t
,
err
)
throwFail
(
t
,
AssertIs
(
nid
,
id
+
120
+
1
))
}
func
TestUintPk
(
t
*
testing
.
T
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment