Skip to content

Commit fd06364

Browse files
committed
Added Union as root term
1 parent 93814e2 commit fd06364

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
77
- Added race detector to CI
88
- Replaced `UseOutdated` with `ReadMode`
99
- Added `EmergencyRepair` and `NonVotingReplicaTags` to `ReconfigureOpts`
10+
- Added `Union` as a root term
1011

1112
## Deprecated
1213
- Deprecated `UseOutdated` optional argument

query_transformation.go

+5
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,11 @@ func (t Term) IsEmpty(args ...interface{}) Term {
151151
return constructMethodTerm(t, "IsEmpty", p.Term_IS_EMPTY, args, map[string]interface{}{})
152152
}
153153

154+
// Union concatenates two sequences.
155+
func Union(args ...interface{}) Term {
156+
return constructRootTerm("Union", p.Term_UNION, args, map[string]interface{}{})
157+
}
158+
154159
// Union concatenates two sequences.
155160
func (t Term) Union(args ...interface{}) Term {
156161
return constructMethodTerm(t, "Union", p.Term_UNION, args, map[string]interface{}{})

query_transformation_test.go

+13
Original file line numberDiff line numberDiff line change
@@ -426,3 +426,16 @@ func (s *RethinkSuite) TestTransformationUnion(c *test.C) {
426426
c.Assert(err, test.IsNil)
427427
c.Assert(response, jsonEquals, []interface{}{1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9})
428428
}
429+
430+
func (s *RethinkSuite) TestTransformationUnionRoot(c *test.C) {
431+
query := Union(arr, arr)
432+
433+
var response []interface{}
434+
res, err := query.Run(session)
435+
c.Assert(err, test.IsNil)
436+
437+
err = res.All(&response)
438+
439+
c.Assert(err, test.IsNil)
440+
c.Assert(response, jsonEquals, []interface{}{1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9})
441+
}

0 commit comments

Comments
 (0)