Skip to content

Commit edc7a6a

Browse files
committed
Merge branch 'develop'
2 parents ef48c04 + 176ace9 commit edc7a6a

29 files changed

+79
-56
lines changed

CHANGELOG.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,19 @@
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+
## v1.4.1 - 2016-04-02
6+
7+
### Fixed
8+
9+
- Fixed panic when closing a connection at the same time as using a changefeed.
10+
- Update imports to correctly use gopkg.in
11+
- Fixed race condition when using anonymous functions
12+
- Fixed IsConflictErr and IsTypeErr panicking when passed nil errors
13+
- RunWrite no longer misformats errors with formatting directives in them
14+
515
## v1.4.0 - 2016-03-15
616

7-
## Added
17+
### Added
818
- Added the ability to reference subdocuments when inserting new documents, for more information see the documentation in the readme.
919
- Added the `SetTags` function which allows GoRethink to override which tags are used when working with structs. For example to support the `json` add the following call `SetTags("gorethink", "json")`.
1020
- Added helper functions for checking the error type of a write query, this is useful when calling `RunWrite`.
@@ -14,7 +24,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
1424
- Added the `NextResponse` function to `Cursor` which will return the next raw JSON response in the result set.
1525
- Added ability to set the keep alive period by setting the `KeepAlivePeriod` field in `ConnectOpts`.
1626

17-
## Fixed
27+
### Fixed
1828
- Fixed an issue that could prevent bad connections from being removed from the connection pool.
1929
- Fixed certain connection errors not being returned as `RqlConnectionError` when calling `Run`, `Exec` or `RunWrite`.
2030
- Fixed potential dead lock in connection code caused when building the query.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
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: v1.4.0 (RethinkDB v2.2)
11+
Current version: v1.4.1 (RethinkDB v2.2)
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

checkers_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66

77
test "gopkg.in/check.v1"
88

9-
"github.com/dancannon/gorethink/types"
9+
"gopkg.in/dancannon/gorethink.v1/types"
1010
)
1111

1212
type jsonChecker struct {

connection.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"sync/atomic"
1010
"time"
1111

12-
p "github.com/dancannon/gorethink/ql2"
12+
p "gopkg.in/dancannon/gorethink.v1/ql2"
1313
)
1414

1515
const (
@@ -41,6 +41,7 @@ type Connection struct {
4141
token int64
4242
cursors map[int64]*Cursor
4343
bad bool
44+
closed bool
4445
}
4546

4647
// NewConnection creates a new connection to the database server
@@ -82,14 +83,15 @@ func (c *Connection) Close() error {
8283
c.mu.Lock()
8384
defer c.mu.Unlock()
8485

85-
if c.Conn != nil {
86-
c.Conn.Close()
87-
c.Conn = nil
88-
}
86+
var err error
8987

90-
c.cursors = nil
88+
if !c.closed {
89+
err = c.Conn.Close()
90+
c.closed = true
91+
c.cursors = make(map[int64]*Cursor)
92+
}
9193

92-
return nil
94+
return err
9395
}
9496

9597
// Query sends a Query to the database, returning both the raw Response and a

connection_helper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"io"
88
"strings"
99

10-
p "github.com/dancannon/gorethink/ql2"
10+
p "gopkg.in/dancannon/gorethink.v1/ql2"
1111
)
1212

1313
// Write 'data' to conn

cursor.go

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import (
77
"reflect"
88
"sync"
99

10-
"github.com/dancannon/gorethink/encoding"
11-
p "github.com/dancannon/gorethink/ql2"
10+
"gopkg.in/dancannon/gorethink.v1/encoding"
11+
p "gopkg.in/dancannon/gorethink.v1/ql2"
1212
)
1313

1414
var (
@@ -190,9 +190,7 @@ func (c *Cursor) nextLocked(dest interface{}) (bool, error) {
190190
}
191191

192192
if len(c.buffer) == 0 && len(c.responses) == 0 && !c.finished {
193-
c.mu.Unlock()
194193
err := c.fetchMore()
195-
c.mu.Lock()
196194
if err != nil {
197195
return false, err
198196
}
@@ -291,9 +289,7 @@ func (c *Cursor) nextResponseLocked() ([]byte, bool, error) {
291289
}
292290

293291
if len(c.responses) == 0 && !c.finished {
294-
c.mu.Unlock()
295292
err := c.fetchMore()
296-
c.mu.Lock()
297293
if err != nil {
298294
return nil, false, err
299295
}
@@ -467,13 +463,11 @@ func (c *Cursor) IsNil() bool {
467463
func (c *Cursor) fetchMore() error {
468464
var err error
469465

470-
c.mu.Lock()
471466
fetching := c.fetching
472467
closed := c.closed
473468

474469
if !fetching {
475470
c.fetching = true
476-
c.mu.Unlock()
477471

478472
if closed {
479473
return errCursorClosed
@@ -484,9 +478,9 @@ func (c *Cursor) fetchMore() error {
484478
Token: c.token,
485479
}
486480

487-
_, _, err = c.conn.Query(q)
488-
} else {
489481
c.mu.Unlock()
482+
_, _, err = c.conn.Query(q)
483+
c.mu.Lock()
490484
}
491485

492486
return err

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: v1.4.0 (RethinkDB v2.2)
3+
// Current version: v1.4.1 (RethinkDB v2.2)
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

errors.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"fmt"
88
"strings"
99

10-
p "github.com/dancannon/gorethink/ql2"
10+
p "gopkg.in/dancannon/gorethink.v1/ql2"
1111
)
1212

1313
var (
@@ -164,11 +164,19 @@ func createRuntimeError(errorType p.Response_ErrorType, response *Response, term
164164
// IsConflictErr returns true if the error is non-nil and the query failed
165165
// due to a duplicate primary key.
166166
func IsConflictErr(err error) bool {
167+
if err == nil {
168+
return false
169+
}
170+
167171
return strings.HasPrefix(err.Error(), "Duplicate primary key")
168172
}
169173

170174
// IsTypeErr returns true if the error is non-nil and the query failed due
171175
// to a type error.
172176
func IsTypeErr(err error) bool {
177+
if err == nil {
178+
return false
179+
}
180+
173181
return strings.HasPrefix(err.Error(), "Expected type")
174182
}

gorethink.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55

66
"github.com/Sirupsen/logrus"
77

8-
"github.com/dancannon/gorethink/encoding"
8+
"gopkg.in/dancannon/gorethink.v1/encoding"
99
)
1010

1111
var (

node.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ package gorethink
33
import (
44
"sync"
55

6-
p "github.com/dancannon/gorethink/ql2"
76
"github.com/hailocab/go-hostpool"
7+
p "gopkg.in/dancannon/gorethink.v1/ql2"
88
)
99

1010
// Node represents a database server in the cluster

0 commit comments

Comments
 (0)