Skip to content

Commit 330ded1

Browse files
committed
Merge pull request #312 from jtblin/jtblin/311-check-session-on-run
Fix panic error when session is nil or not connected
2 parents 2c130b7 + 9023b69 commit 330ded1

File tree

5 files changed

+27
-8
lines changed

5 files changed

+27
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5-
## Unreleased
5+
## v2.0.1 - 2016-04-14
66

77
### Added
88
- Added `UnionWithOpts` term which allows `Union` to be called with optional arguments (such as `Interleave`)

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,24 @@
88

99
![GoRethink Logo](https://raw.github.com/wiki/dancannon/gorethink/gopher-and-thinker-s.png "Golang Gopher and RethinkDB Thinker")
1010

11-
Current version: v2.0.0 (RethinkDB v2.3)
11+
Current version: v2.0.1 (RethinkDB v2.3)
1212

1313
Please note that this version of the driver only supports versions of RethinkDB using the v0.4 protocol (any versions of the driver older than RethinkDB 2.0 will not work).
1414

1515
If you need any help you can find me on the [RethinkDB slack](http://slack.rethinkdb.com/) in the #gorethink channel.
1616

1717
## Installation
1818

19-
```sh
20-
go get -u github.com/dancannon/gorethink
21-
```
22-
23-
Or (pinned to the v1.x.x tag)
2419
```
2520
go get gopkg.in/dancannon/gorethink.v2
2621
```
2722

23+
(Or v1)
24+
25+
```sh
26+
go get gopkg.in/dancannon/gorethink.v1
27+
```
28+
2829
## Connection
2930

3031
### Basic Connection

doc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Package gorethink implements a Go driver for RethinkDB
22
//
3-
// Current version: v2.0.0 (RethinkDB v2.3)
3+
// Current version: v2.0.1 (RethinkDB v2.3)
44
// For more in depth information on how to use RethinkDB check out the API docs
55
// at http://rethinkdb.com/api
66
package gorethink

query.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,10 @@ func (t Term) Run(s *Session, optArgs ...RunOpts) (*Cursor, error) {
242242
opts = optArgs[0].toMap()
243243
}
244244

245+
if s == nil || !s.IsConnected() {
246+
return nil, ErrConnectionClosed
247+
}
248+
245249
q, err := s.newQuery(t, opts)
246250
if err != nil {
247251
return nil, err

query_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,17 @@ func (s *RethinkSuite) TestQueryRunRawTime(c *test.C) {
6565
c.Assert(response["$reql_type$"], test.NotNil)
6666
c.Assert(response["$reql_type$"], test.Equals, "TIME")
6767
}
68+
69+
func (s *RethinkSuite) TestQueryRunNil(c *test.C) {
70+
res, err := Expr("Test").Run(nil)
71+
c.Assert(res, test.IsNil)
72+
c.Assert(err, test.NotNil)
73+
c.Assert(err, test.Equals, ErrConnectionClosed)
74+
}
75+
76+
func (s *RethinkSuite) TestQueryRunNotConnected(c *test.C) {
77+
res, err := Expr("Test").Run(&Session{})
78+
c.Assert(res, test.IsNil)
79+
c.Assert(err, test.NotNil)
80+
c.Assert(err, test.Equals, ErrConnectionClosed)
81+
}

0 commit comments

Comments
 (0)