Skip to content

Commit 7c78a8f

Browse files
committedAug 16, 2017
fix: rows lazy init
1 parent 487c727 commit 7c78a8f

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed
 

‎rows.go

-3
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ type rows struct {
2525
}
2626

2727
func (rows *rows) Columns() []string {
28-
if len(rows.columns) == 0 {
29-
rows.receiveData()
30-
}
3128
return rows.columns
3229
}
3330

‎stmt.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,15 @@ func (stmt *stmt) queryContext(ctx context.Context, args []driver.NamedValue) (d
7272
return nil, err
7373
}
7474

75-
return &rows{
75+
rows := rows{
7676
ch: stmt.ch,
77-
}, nil
77+
}
78+
for len(rows.columns) == 0 {
79+
if err := rows.receiveData(); err != nil {
80+
return nil, err
81+
}
82+
}
83+
return &rows, nil
7884
}
7985

8086
func (stmt *stmt) Close() error {

0 commit comments

Comments
 (0)
Please sign in to comment.