Skip to content

Commit

Permalink
Merge branch 'hotfix/v1.1.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
dancannon committed Sep 6, 2015
2 parents c52349e + d2ede07 commit 27c275d
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ before_script:
- rethinkdb --port-offset 2 --directory rethinkdb_data2 --join localhost:29016 > /dev/null 2>&1 &
- rethinkdb --port-offset 3 --directory rethinkdb_data3 --join localhost:29016 > /dev/null 2>&1 &

script: go test -tags='cluster' -race -check.vv -v ./...
script: go test -tags='cluster' -short -race -check.vv -v ./...
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## v1.1.3
### Fixed
- Fixed pointers not to be properly decoded
- Fixed queries always timing out when Timeout ConnectOpt is set.

## v1.1.2
### Fixed
- Fixed issue when encoding some maps
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

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

Current version: v1.1.1 (RethinkDB v2.1)
Current version: v1.1.3 (RethinkDB v2.1)

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).

Expand Down
4 changes: 2 additions & 2 deletions connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func (c *Connection) sendQuery(q Query) error {
}

// Set timeout
if c.opts.Timeout == 0 {
if c.opts.WriteTimeout == 0 {
c.conn.SetWriteDeadline(time.Time{})
} else {
c.conn.SetWriteDeadline(time.Now().Add(c.opts.WriteTimeout))
Expand All @@ -189,7 +189,7 @@ func (c *Connection) nextToken() int64 {
// could be read then an error is returned.
func (c *Connection) readResponse() (*Response, error) {
// Set timeout
if c.opts.Timeout == 0 {
if c.opts.ReadTimeout == 0 {
c.conn.SetReadDeadline(time.Time{})
} else {
c.conn.SetReadDeadline(time.Now().Add(c.opts.ReadTimeout))
Expand Down
2 changes: 1 addition & 1 deletion doc.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Package gorethink implements a Go driver for RethinkDB
//
// Current version: v1.1.1 (RethinkDB v2.1)
// Current version: v1.1.3 (RethinkDB v2.1)
// For more in depth information on how to use RethinkDB check out the API docs
// at http://rethinkdb.com/api
package gorethink
10 changes: 5 additions & 5 deletions encoding/decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ func Decode(dst interface{}, src interface{}) (err error) {

// decode decodes the source value into the destination value
func decode(dv, sv reflect.Value) {
if dv.IsValid() {
dv = indirect(dv, false)
dv.Set(reflect.Zero(dv.Type()))
}

valueDecoder(dv, sv)(dv, sv)
}

Expand All @@ -69,11 +74,6 @@ func valueDecoder(dv, sv reflect.Value) decoderFunc {
return invalidValueDecoder
}

if dv.IsValid() {
dv = indirect(dv, false)
dv.Set(reflect.Zero(dv.Type()))
}

return typeDecoder(dv.Type(), sv.Type())
}

Expand Down
20 changes: 20 additions & 0 deletions encoding/decoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ type S13 struct {
S8
}

type PointerBasic struct {
X int
Y *int
}

type Pointer struct {
PPoint *Point
Point Point
Expand All @@ -142,6 +147,11 @@ type Ambig struct {
Second int `gorethink:"Hello"`
}

// Decode test helper vars
var (
sampleInt = 2
)

var decodeTests = []decodeTest{
// basic types
{in: true, ptr: new(bool), out: true},
Expand Down Expand Up @@ -253,6 +263,16 @@ var decodeTests = []decodeTest{
ptr: new(Pointer),
out: Pointer{PPoint: nil, Point: Point{Z: 2}},
},
{
in: map[string]interface{}{"x": 2},
ptr: new(PointerBasic),
out: PointerBasic{X: 2, Y: nil},
},
{
in: map[string]interface{}{"x": 2, "y": 2},
ptr: new(PointerBasic),
out: PointerBasic{X: 2, Y: &sampleInt},
},
}

func TestDecode(t *testing.T) {
Expand Down
4 changes: 3 additions & 1 deletion encoding/decoder_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,9 @@ func interfaceDecoder(dv, sv reflect.Value) {
}

func interfaceAsTypeDecoder(dv, sv reflect.Value) {
decode(dv, sv.Elem())
if !sv.IsNil() {
decode(dv, sv.Elem())
}
}

type ptrDecoder struct {
Expand Down

0 comments on commit 27c275d

Please # to comment.