Skip to content

The return_changes optarg (for mutation commands) should return the changes in order #5041

Closed

Description

@coffeemug

Suppose I run the following command:

r.table('foo').insert([{a: 1}, {a: r.minval }, {a: r.minval }, {a: 2}],
                      { returnChanges: 'always' })

In the current implementation, the changes don't come back in the same order as the documents inserted (the order isn't specified). That makes the always mode essentially useless.

The changes in this case should be guaranteed to come back in order.

/cc @mlucy (we just discussed this) and @Tryneus (he needs this for a secret super-project he's working on)

Activity

  1. added this to the 2.3 milestone on Nov 5, 2015
  2. danielmewes commented on Nov 5, 2015

    @danielmewes
    Member

    Would this be only for insert?

  3. deontologician commented on Nov 5, 2015

    @deontologician
    Contributor

    Also, it would be nice if there were error changes inserted if the documents fail to insert properly, rather than fake keys like generated_keys

    {new_val: ..., old_val: ...}, {error: "Key already exists"}, {new_val: ..., old_val: ...}
    
  4. coffeemug commented on Nov 5, 2015

    @coffeemug
    ContributorAuthor

    I was going to add -- including errors would be really helpful.

    I think this should be the case for all commands where you can pass { returnChanges: 'always' }, not just insert.

  5. danielmewes commented on Nov 30, 2015

    @danielmewes
    Member

    The reason I was asking is because insert is somewhat different from the other write operations.

    In the case of insert, the order is explicitly specified in the command itself, as you pass an array with documents.

    For an update, replace or delete, the order is not provided in the same way. Instead it's implicit in the selection that the command is applied on. We could return changes in the "right" order if the selection is ordered, such as in r.table('test').orderBy({index: "id"}).delete(). Unless this is something that will occur in Fusion, I think that's a pretty rare use case though.

    I suspect that we'll also need separate code to ensure this for insert vs. the other write terms.

    I suggest that we implement it for insert first. Does that sound reasonable?

  6. danielmewes commented on Nov 30, 2015

    @danielmewes
    Member

    Also +1 on that error syntax.

  7. deontologician commented on Dec 2, 2015

    @deontologician
    Contributor

    I think we only actually need it for insert since that's the only place where we don't have an id for a failed document operation and have to rely on stuff like ordering to figure out what went wrong

  8. neumino commented on Dec 2, 2015

    @neumino
    Member

    It's the same as #3853 -- and would be really nice as thinky now has to do it itself (and that it's annoying when primary keys are not string).

  9. danielmewes commented on Dec 3, 2015

    @danielmewes
    Member

    Ah thanks @neumino . I had a feeling you had brought this up before for Thinky, but I couldn't find the issue when I looked for it.

  10. karlgrz commented on Jan 20, 2016

    @karlgrz

    This is slightly annoying for us, as well. Any date on 2.3 release candidates?

  11. danielmewes commented on Jan 20, 2016

    @danielmewes
    Member

    @karlgrz Our current estimate for 2.3 is 1-2 months from now.

  12. karlgrz commented on Jan 20, 2016

    @karlgrz

    @danielmewes thank you!

  13. nighelles commented on Jan 29, 2016

    @nighelles
  14. nighelles commented on Feb 16, 2016

    @nighelles

    This is in next.

  15. karlgrz commented on Feb 16, 2016

    @karlgrz

    Fantastic news, thank you!

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions