You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Following discussion with @coffeemug regarding rethinkdb/docs#467, we decided it would be least-confusing for users to have the r.binary term also operate on the server when operating on other terms.
Internally, r.binary will just run the same code as coerce_to('binary').
Scheduling for 1.14 since we don't want people to be confused by r.binary in the first version.
r.binary(r.expr("foo")) // returns a binary
r.binary("foo") // throws an error
Is it expected? Shouldn't we release the constraint and just send everything to the server -- and the server decides whether we should return an error or not.
@neumino, I'm worried that users will assume that will work in the example of r.binary("f\x00"), which it will not. In that case, it would evaluate to r.binary(r.expr("f\x00")), which would cause an error in the protocol, as expected.
@Tryneus -- make sense
I don't really have a strong opinion on that, and I actually don't really expect people to write r.binary("foo") so I'm fine with the current behavior.
I think it's fine that we don't accept strings like that, as it can hide subtly incorrect behavior and we require the user to be more explicit. We have the following behavior in each driver:
Ruby - no error, strings are converted to the Binary pseudotype by default
Python - Cannot convert a unicode string to binary, use 'unicode.encode()' to specify the encoding.
Javascript - Parameter to 'r.binary' must be a Buffer object or RQL query.
@mlucy, r.binary("foo") is the normal way of constructing a binary object through the Ruby driver as there is no binary-specific type like bytes in Python or Buffer in Javascript.
Activity
Tryneus commentedon Aug 19, 2014
This is up in review 1982.
Tryneus commentedon Aug 19, 2014
This has been approved and merged to
nextin commits 7acffc9, 6b3985d, and 3e4de55, and cherry-picked intov1.14.xin commits b2175ff, 6b2e878, and 036d9f7.neumino commentedon Aug 19, 2014
The JS driver has the following behavior:
Is it expected? Shouldn't we release the constraint and just send everything to the server -- and the server decides whether we should return an error or not.
Tryneus commentedon Aug 19, 2014
@neumino, I'm worried that users will assume that will work in the example of
r.binary("f\x00"), which it will not. In that case, it would evaluate tor.binary(r.expr("f\x00")), which would cause an error in the protocol, as expected.neumino commentedon Aug 19, 2014
@Tryneus -- make sense
I don't really have a strong opinion on that, and I actually don't really expect people to write
r.binary("foo")so I'm fine with the current behavior.Ping @coffeemug -- any thought on that?
coffeemug commentedon Aug 20, 2014
I don't have a strong opinion on this.
Tryneus commentedon Aug 20, 2014
I think it's fine that we don't accept strings like that, as it can hide subtly incorrect behavior and we require the user to be more explicit. We have the following behavior in each driver:
Ruby - no error, strings are converted to the Binary pseudotype by default
Python -
Cannot convert a unicode string to binary, use 'unicode.encode()' to specify the encoding.Javascript -
Parameter to 'r.binary' must be a Buffer object or RQL query.mlucy commentedon Aug 20, 2014
I didn't quite follow that; what happens to strings when?
Tryneus commentedon Aug 20, 2014
@mlucy,
r.binary("foo")is the normal way of constructing a binary object through the Ruby driver as there is no binary-specific type likebytesin Python orBufferin Javascript.