Skip to content

JS driver - ignore undefined fields in MakeObject #2233

Open

Description

@neumino

It is sometimes convenient to just set a key to undefined instead of using delete (like when copying a foreign key).
I feel like it's safe to ignore fields that are undefined.

We currently throw an error
https://github.com/rethinkdb/rethinkdb/blob/next/drivers/javascript/ast.coffee#L436

Putting in backlog for now, if someone has an opinion about this, I would be interested in.

Activity

  1. added this to the backlog milestone on Apr 9, 2014
  2. coffeemug commented on Apr 9, 2014

    @coffeemug
    Contributor

    Marking as a ReQL proposal since it's a user-visible change.

    I think doing this would be better than what we have now, though I wonder how it will interact with whatever we're going to do for non-existence (might this confuse people when we change something?)

  3. srh commented on Apr 9, 2014

    @srh
    Contributor

    I don't see how this would be possible or make sense anywhere but the Javascript driver. (Edit: Oh, you said that.)

  4. neumino commented on Jul 8, 2014

    @neumino
    MemberAuthor

    Any objection if I do that?

    We'll still catch undefined in an array, but just ignore undefined fields.

  5. coffeemug commented on Jul 8, 2014

    @coffeemug
    Contributor

    @neumino -- to clarify, do you just want to treat fields set to undefined as if they weren't there at all? So, for example:

    > r.table('foo').get(1).run()
    { id: 1, foo: 1}
    
    > r.table('foo').get(1).update({foo: undefined}).run()
    { id: 1, foo: 1}

    Is that the behavior you want?

  6. neumino commented on Jul 8, 2014

    @neumino
    MemberAuthor

    {foo: undefined, bar: 1} is basically the same as {bar: 1}

    So instead of calling delete obj.foo, people can just do obj.foo = undefined.

  7. coffeemug commented on Jul 9, 2014

    @coffeemug
    Contributor

    Do you think this behavior might confuse people when they call update? In my example above a reasonable expectation is that foo will be removed from the object. It seems a little weird to me, what do you think?

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions