Skip to content

Commit de8b535

Browse files
committed
Updated UUID term for 2.2
1 parent e0e6456 commit de8b535

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

query_control.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,9 @@ func (t Term) Info(args ...interface{}) Term {
296296
return constructMethodTerm(t, "Info", p.Term_INFO, args, map[string]interface{}{})
297297
}
298298

299-
// UUID returns a UUID (universally unique identifier), a string that can be used as a unique ID.
299+
// Return a UUID (universally unique identifier), a string that can be used as a
300+
// unique ID. If a string is passed to uuid as an argument, the UUID will be
301+
// deterministic, derived from the string’s SHA-1 hash.
300302
func UUID(args ...interface{}) Term {
301-
return constructRootTerm("UUID", p.Term_UUID, []interface{}{}, map[string]interface{}{})
303+
return constructRootTerm("UUID", p.Term_UUID, args, map[string]interface{}{})
302304
}

query_control_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,30 @@ func (s *RethinkSuite) TestControlToJSON(c *test.C) {
447447
c.Assert(response, test.Equals, "[4,5]")
448448
}
449449

450+
func (s *RethinkSuite) TestControlUUID(c *test.C) {
451+
var response string
452+
query := UUID()
453+
res, err := query.Run(session)
454+
c.Assert(err, test.IsNil)
455+
456+
err = res.One(&response)
457+
458+
c.Assert(err, test.IsNil)
459+
c.Assert(len(response) == 36, test.Equals, true)
460+
}
461+
462+
func (s *RethinkSuite) TestControlUUIDString(c *test.C) {
463+
var response string
464+
query := UUID("rethinkdb")
465+
res, err := query.Run(session)
466+
c.Assert(err, test.IsNil)
467+
468+
err = res.One(&response)
469+
470+
c.Assert(err, test.IsNil)
471+
c.Assert(len(response) == 36, test.Equals, true)
472+
}
473+
450474
func (s *RethinkSuite) TestControlInvalidType(c *test.C) {
451475
query := Expr(map[struct{ string }]string{})
452476
_, err := query.Run(session)

0 commit comments

Comments
 (0)