Skip to content

Proposal: r.object #1857

Closed
Closed

Description

@coffeemug
r.object('a', 1, 'b', 2)
{a: 1, b: 2}

A convenience method equivalent to r.expr({}).addFields('a', 1, 'b', 2).

Activity

  1. ghost assigned on Jan 14, 2014
  2. coffeemug commented on Jan 14, 2014

    @coffeemug
    ContributorAuthor

    @AtnNn pointed out that we might just want to implement this and not #1856 (since r.expr({}).addFields('a', 1, 'b', 2) is just r.expr({}).merge(r.object('a', 1, 'b', 2)). I'd be cool with dropping addFields.

  3. mlucy commented on Jan 14, 2014

    @mlucy
    Member

    I don't feel that strongly; let's just drop add_fields to lessen the amount of work.

  4. coffeemug commented on Jan 14, 2014

    @coffeemug
    ContributorAuthor

    Also, r.object('a', 1, 'a', 2) should return {'a' : 2}.

  5. danielmewes commented on Jan 14, 2014

    @danielmewes
    Member

    Also, r.object('a', 1, 'a', 2) should return {'a' : 2}.

    @coffeemug You probably have some reason for why you want r.object() to behave like that. What is that reason? Is it a specific use case? I would think it should error in such cases.

  6. coffeemug commented on Jan 14, 2014

    @coffeemug
    ContributorAuthor

    Ah, I thought that r.object(i, j, k, m) should be equivalent to r.expr([[i, j], [k, m]]).coerceTo('object'), and I was under the impression that that accepts duplicates. Turns out it does not:

    r.expr([['a', 1], ['a', 2]]).coerceTo('object')
    RqlRuntimeError: Duplicate key a in coerced object.
    

    So you're right, r.object('a', 1, 'a', 2) should return the same error.

  7. AtnNn commented on Jan 15, 2014

    @AtnNn
    Member

    This is implemented and in review 1127

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions