Skip to content

Commit

Permalink
Merge branch 'release/v0.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
dancannon committed Oct 6, 2014
2 parents 175c806 + 6ed3bbf commit e590ff2
Show file tree
Hide file tree
Showing 32 changed files with 1,880 additions and 595 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changelog

## v0.5.0 - 6 Oct 2014

- Added geospatial terms (`Circle`, `Distance`, `Fill`, `Geojson`, `ToGeojson`, `GetIntersecting`, `GetNearest`, `Includes`, `Intersects`, `Line`, `Point`, `Polygon`, `PolygonSub`)
- Added `UUID` term for generating unique IDs
- Added `AtIndex` term, combines `Nth` and `GetField`
- Added the `Geometry` type, see the types package
- Updated the `BatchConf` field in `RunOpts`, now uses the `BatchOpts` type

### Internal Changes
- Fixed encoding performance issues, greatly improves writes/second
- Updated `Next` to zero the destination value every time it is called.

## v0.4.2 - 6 Sept 2014

- Fixed issue causing `Close` to start an infinite loop
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ GoRethink - RethinkDB Driver for Go [![wercker status](https://app.wercker.com/s
[Go](http://golang.org/) driver for [RethinkDB](http://www.rethinkdb.com/) made by [Daniel Cannon](http://github.com/dancannon) and based off of Christopher Hesse's [RethinkGo](https://github.com/christopherhesse/rethinkgo) driver.


Current version: v0.4.1 (RethinkDB v1.14)
Current version: v0.5.0 (RethinkDB v1.15.1)

**Version 0.3 introduced some API changes, for more information check the [change log](CHANGELOG.md)**

Expand Down
File renamed without changes.
83 changes: 72 additions & 11 deletions results_test.go → cursor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type attr struct {
Value interface{}
}

func (s *RethinkSuite) TestRowsLiteral(c *test.C) {
func (s *RethinkSuite) TestCursorLiteral(c *test.C) {
res, err := Expr(5).Run(sess)
c.Assert(err, test.IsNil)

Expand All @@ -27,7 +27,7 @@ func (s *RethinkSuite) TestRowsLiteral(c *test.C) {
c.Assert(response, JsonEquals, 5)
}

func (s *RethinkSuite) TestRowsSlice(c *test.C) {
func (s *RethinkSuite) TestCursorSlice(c *test.C) {
res, err := Expr([]interface{}{1, 2, 3, 4, 5}).Run(sess)
c.Assert(err, test.IsNil)

Expand All @@ -37,7 +37,7 @@ func (s *RethinkSuite) TestRowsSlice(c *test.C) {
c.Assert(response, JsonEquals, []interface{}{1, 2, 3, 4, 5})
}

func (s *RethinkSuite) TestRowsPartiallyNilSlice(c *test.C) {
func (s *RethinkSuite) TestCursorPartiallyNilSlice(c *test.C) {
res, err := Expr(map[string]interface{}{
"item": []interface{}{
map[string]interface{}{"num": 1},
Expand All @@ -57,7 +57,7 @@ func (s *RethinkSuite) TestRowsPartiallyNilSlice(c *test.C) {
})
}

func (s *RethinkSuite) TestRowsMap(c *test.C) {
func (s *RethinkSuite) TestCursorMap(c *test.C) {
res, err := Expr(map[string]interface{}{
"id": 2,
"name": "Object 1",
Expand All @@ -73,7 +73,7 @@ func (s *RethinkSuite) TestRowsMap(c *test.C) {
})
}

func (s *RethinkSuite) TestRowsMapIntoInterface(c *test.C) {
func (s *RethinkSuite) TestCursorMapIntoInterface(c *test.C) {
res, err := Expr(map[string]interface{}{
"id": 2,
"name": "Object 1",
Expand All @@ -89,7 +89,7 @@ func (s *RethinkSuite) TestRowsMapIntoInterface(c *test.C) {
})
}

func (s *RethinkSuite) TestRowsMapNested(c *test.C) {
func (s *RethinkSuite) TestCursorMapNested(c *test.C) {
res, err := Expr(map[string]interface{}{
"id": 2,
"name": "Object 1",
Expand All @@ -113,7 +113,7 @@ func (s *RethinkSuite) TestRowsMapNested(c *test.C) {
})
}

func (s *RethinkSuite) TestRowsStruct(c *test.C) {
func (s *RethinkSuite) TestCursorStruct(c *test.C) {
res, err := Expr(map[string]interface{}{
"id": 2,
"name": "Object 1",
Expand All @@ -137,7 +137,7 @@ func (s *RethinkSuite) TestRowsStruct(c *test.C) {
})
}

func (s *RethinkSuite) TestRowsStructPseudoTypes(c *test.C) {
func (s *RethinkSuite) TestCursorStructPseudoTypes(c *test.C) {
t := time.Now()

res, err := Expr(map[string]interface{}{
Expand All @@ -154,7 +154,7 @@ func (s *RethinkSuite) TestRowsStructPseudoTypes(c *test.C) {
c.Assert(response.B, JsonEquals, []byte("hello"))
}

func (s *RethinkSuite) TestRowsAtomString(c *test.C) {
func (s *RethinkSuite) TestCursorAtomString(c *test.C) {
res, err := Expr("a").Run(sess)
c.Assert(err, test.IsNil)

Expand All @@ -164,7 +164,7 @@ func (s *RethinkSuite) TestRowsAtomString(c *test.C) {
c.Assert(response, test.Equals, "a")
}

func (s *RethinkSuite) TestRowsAtomArray(c *test.C) {
func (s *RethinkSuite) TestCursorAtomArray(c *test.C) {
res, err := Expr([]interface{}{1, 2, 3, 4, 5, 6, 7, 8, 9, 0}).Run(sess)
c.Assert(err, test.IsNil)

Expand Down Expand Up @@ -203,7 +203,7 @@ func (s *RethinkSuite) TestEmptyResults(c *test.C) {
c.Assert(res.IsNil(), test.Equals, true)
}

func (s *RethinkSuite) TestRowsAll(c *test.C) {
func (s *RethinkSuite) TestCursorAll(c *test.C) {
// Ensure table + database exist
DbCreate("test").Exec(sess)
Db("test").TableDrop("Table3").Exec(sess)
Expand Down Expand Up @@ -258,3 +258,64 @@ func (s *RethinkSuite) TestRowsAll(c *test.C) {
},
})
}

func (s *RethinkSuite) TestCursorReuseResult(c *test.C) {
// Test query
query := Expr([]interface{}{
map[string]interface{}{
"A": "a",
},
map[string]interface{}{
"B": 1,
},
map[string]interface{}{
"A": "a",
},
map[string]interface{}{
"B": 1,
},
map[string]interface{}{
"A": "a",
"B": 1,
},
})
res, err := query.Run(sess)
c.Assert(err, test.IsNil)

var i int
var result SimpleT
for res.Next(&result) {
switch i {
case 0:
c.Assert(result, test.DeepEquals, SimpleT{
A: "a",
B: 0,
})
case 1:
c.Assert(result, test.DeepEquals, SimpleT{
A: "",
B: 1,
})
case 2:
c.Assert(result, test.DeepEquals, SimpleT{
A: "a",
B: 0,
})
case 3:
c.Assert(result, test.DeepEquals, SimpleT{
A: "",
B: 1,
})
case 4:
c.Assert(result, test.DeepEquals, SimpleT{
A: "a",
B: 1,
})
default:
c.Fatalf("Unexpected number of results")
}

i++
}
c.Assert(res.Err(), test.IsNil)
}
2 changes: 1 addition & 1 deletion doc.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Go driver for RethinkDB
//
// Current version: v0.4.1 (RethinkDB v1.14)
// Current version: v0.5.0 (RethinkDB v1.15.1)
// For more in depth information on how to use RethinkDB check out the API docs
// at http://rethinkdb.com/api
package gorethink
Loading

0 comments on commit e590ff2

Please sign in to comment.