Skip to content

Commit

Permalink
Fix premature end of parse
Browse files Browse the repository at this point in the history
 Fixes #6
  • Loading branch information
vbatoufflet committed Dec 17, 2017
1 parent 1f1d3ec commit f61f0a0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions query.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
"time"
)

const bufferSize = 1024

// Query is a binding query instance.
type Query struct {
table string
Expand Down Expand Up @@ -154,7 +156,7 @@ func (q *Query) Exec() (*Response, error) {
buf := bytes.NewBuffer(nil)

for {
data = make([]byte, 1024)
data = make([]byte, bufferSize)

n, err := conn.Read(data)
if err == io.EOF {
Expand All @@ -167,7 +169,7 @@ func (q *Query) Exec() (*Response, error) {

// New line signals the end of content. This check helps
// if the connection is not forcibly closed
if data[n-1] == byte('\n') {
if n != bufferSize && data[n-1] == byte('\n') {
break
}
}
Expand Down

0 comments on commit f61f0a0

Please sign in to comment.