Skip to content

Add r.binary term on the server #2931

Closed

Description

@Tryneus

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.

Activity

  1. added this to the 1.14 milestone on Aug 18, 2014
  2. self-assigned this
    on Aug 18, 2014
  3. Tryneus commented on Aug 19, 2014

    @Tryneus
    MemberAuthor

    This is up in review 1982.

  4. Tryneus commented on Aug 19, 2014

    @Tryneus
    MemberAuthor

    This has been approved and merged to next in commits 7acffc9, 6b3985d, and 3e4de55, and cherry-picked into v1.14.x in commits b2175ff, 6b2e878, and 036d9f7.

  5. neumino commented on Aug 19, 2014

    @neumino
    Member

    The JS driver has the following behavior:

    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.

  6. Tryneus commented on Aug 19, 2014

    @Tryneus
    MemberAuthor

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

  7. neumino commented on Aug 19, 2014

    @neumino
    Member

    @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?

  8. coffeemug commented on Aug 20, 2014

    @coffeemug
    Contributor

    I don't have a strong opinion on this.

  9. Tryneus commented on Aug 20, 2014

    @Tryneus
    MemberAuthor

    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.

  10. mlucy commented on Aug 20, 2014

    @mlucy
    Member

    Ruby - no error, strings are converted to the Binary pseudotype by default

    I didn't quite follow that; what happens to strings when?

  11. Tryneus commented on Aug 20, 2014

    @Tryneus
    MemberAuthor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions