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
61c0b3e2
Commit
61c0b3e2
authored
Dec 31, 2013
by
slene
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix db locked
parent
383a04f4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
3 deletions
+19
-3
db.go
orm/db.go
+10
-0
orm_raw.go
orm/orm_raw.go
+7
-2
orm_test.go
orm/orm_test.go
+2
-1
No files found.
orm/db.go
View file @
61c0b3e2
...
...
@@ -486,6 +486,8 @@ func (d *dbBase) DeleteBatch(q dbQuerier, qs *querySet, mi *modelInfo, cond *Con
rs
=
r
}
defer
rs
.
Close
()
var
ref
interface
{}
args
=
make
([]
interface
{},
0
)
...
...
@@ -640,6 +642,8 @@ func (d *dbBase) ReadBatch(q dbQuerier, qs *querySet, mi *modelInfo, cond *Condi
refs
[
i
]
=
&
ref
}
defer
rs
.
Close
()
slice
:=
ind
var
cnt
int64
...
...
@@ -1150,6 +1154,8 @@ func (d *dbBase) ReadValues(q dbQuerier, qs *querySet, mi *modelInfo, cond *Cond
refs
[
i
]
=
&
ref
}
defer
rs
.
Close
()
var
(
cnt
int64
columns
[]
string
...
...
@@ -1268,6 +1274,8 @@ func (d *dbBase) GetTables(db dbQuerier) (map[string]bool, error) {
return
tables
,
err
}
defer
rows
.
Close
()
for
rows
.
Next
()
{
var
table
string
err
:=
rows
.
Scan
(
&
table
)
...
...
@@ -1290,6 +1298,8 @@ func (d *dbBase) GetColumns(db dbQuerier, table string) (map[string][3]string, e
return
columns
,
err
}
defer
rows
.
Close
()
for
rows
.
Next
()
{
var
(
name
string
...
...
orm/orm_raw.go
View file @
61c0b3e2
...
...
@@ -285,6 +285,8 @@ func (o *rawSet) QueryRow(containers ...interface{}) error {
return
err
}
defer
rows
.
Close
()
if
rows
.
Next
()
{
if
structMode
{
columns
,
err
:=
rows
.
Columns
()
...
...
@@ -408,11 +410,12 @@ func (o *rawSet) QueryRows(containers ...interface{}) (int64, error) {
return
0
,
err
}
nInds
:=
make
([]
reflect
.
Value
,
len
(
sInds
)
)
defer
rows
.
Close
(
)
var
cnt
int64
nInds
:=
make
([]
reflect
.
Value
,
len
(
sInds
))
sInd
:=
sInds
[
0
]
var
cnt
int64
for
rows
.
Next
()
{
if
structMode
{
...
...
@@ -538,6 +541,8 @@ func (o *rawSet) readValues(container interface{}) (int64, error) {
rs
=
r
}
defer
rs
.
Close
()
var
(
refs
[]
interface
{}
cnt
int64
...
...
orm/orm_test.go
View file @
61c0b3e2
...
...
@@ -1392,7 +1392,8 @@ func TestQueryRows(t *testing.T) {
var
ids
[]
int
var
usernames
[]
string
num
,
err
=
dORM
.
Raw
(
"SELECT id, user_name FROM user ORDER BY id asc"
)
.
QueryRows
(
&
ids
,
&
usernames
)
query
=
fmt
.
Sprintf
(
"SELECT %sid%s, %suser_name%s FROM %suser%s ORDER BY %sid%s ASC"
,
Q
,
Q
,
Q
,
Q
,
Q
,
Q
,
Q
,
Q
)
num
,
err
=
dORM
.
Raw
(
query
)
.
QueryRows
(
&
ids
,
&
usernames
)
throwFailNow
(
t
,
err
)
throwFailNow
(
t
,
AssertIs
(
num
,
3
))
throwFailNow
(
t
,
AssertIs
(
len
(
ids
),
3
))
...
...
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