From b248b0f4e1cf7a114d09cd39d3eba02d5a2f594b Mon Sep 17 00:00:00 2001 From: Philip O'Toole Date: Mon, 30 May 2016 15:56:35 -0700 Subject: [PATCH 1/2] Trivial formatting changes --- db/db.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/db.go b/db/db.go index 0add05cb..9e6721ef 100644 --- a/db/db.go +++ b/db/db.go @@ -270,13 +270,13 @@ func (db *DB) Query(queries []string, tx, xTime bool) ([]*Rows, error) { dest := make([]driver.Value, len(rows.Columns)) for { err := rs.Next(dest) - if err != nil { if err != io.EOF { rows.Error = err.Error() } break } + values := make([]interface{}, len(rows.Columns)) // Text values come over (from sqlite-go) as []byte instead of strings // for some reason, so we have explicitly convert (but only when type From b77130aa2c89236079a44d87909a15948808605c Mon Sep 17 00:00:00 2001 From: Philip O'Toole Date: Mon, 30 May 2016 16:04:52 -0700 Subject: [PATCH 2/2] CLI now handles no rows correctly --- CHANGELOG.md | 1 + cmd/rqlite/query.go | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5da8cc5b..7f5395f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ - [PR #149](https://github.com/rqlite/rqlite/pull/149): Support configurable Raft snapshot thresholds. - [PR #148](https://github.com/rqlite/rqlite/pull/148): Support pprof information over HTTP. - [PR #154](https://github.com/rqlite/rqlite/pull/154): CLI now redirects to leader if necessary. +- [PR #155](https://github.com/rqlite/rqlite/pull/155): CLI now handles "no rows" correctly. ## 3.2.1 (May 22nd 2016) - [PR #143](https://github.com/rqlite/rqlite/pull/143): Use DELETE as HTTP method to remove nodes. diff --git a/cmd/rqlite/query.go b/cmd/rqlite/query.go index 831fd2ef..5ea6210d 100644 --- a/cmd/rqlite/query.go +++ b/cmd/rqlite/query.go @@ -34,6 +34,11 @@ func (r *Rows) Get(i, j int) string { } return r.Columns[j] } + + if r.Values == nil { + return "NULL" + } + if i-1 >= len(r.Values) { return "NULL" } @@ -47,7 +52,7 @@ func (r *Rows) validate() error { if r.Error != "" { return fmt.Errorf(r.Error) } - if r.Columns == nil || r.Types == nil || r.Values == nil { + if r.Columns == nil || r.Types == nil { return fmt.Errorf("unexpected result") } return nil