Skip to content

setDataValue sets attribute as changed when updated from null to null #5004

Closed

Description

@Thomathan

Related to #3812

The setDataValue will set an attribute as changed when changing from null to null.

It could be argued that I should have that check in my own code but the instance code does check for changes anyways.

Instance.prototype.setDataValue = function(key, value) {
  var originalValue = this._previousDataValues[key];
  if (!Utils.isPrimitive(value) || value !== originalValue) {
    this.changed(key, true);
  }

  this.dataValues[key] = value;
};

This differs from the set function which does

if (!options.raw && ((!Utils.isPrimitive(value) && value !== null) || value !== originalValue)) {
  this._previousDataValues[key] = originalValue;
  this.changed(key, true);
}
this.dataValues[key] = value;

Activity

  1. mickhansen commented on Dec 9, 2015

    @mickhansen
    Contributor

    setDataValue is meant more as a low level thing, it definitely doesn't have as much logic. Odd that null doesnt register as a primitive though.

  2. Thomathan commented on Dec 9, 2015

    @Thomathan
    Author

    null's have always been odd. It just seems like the setDataValue check should use the conditions as the set check (minus the raw of course). In it's current state, they give inconsistent behaviour.

  3. added
    type: bug
    on Jan 30, 2016
  4. stale commented on Jun 29, 2017

    @stale

    This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment 🙂

  5. Kirill89 commented on Apr 17, 2018

    @Kirill89
    Contributor

    Looks like this bug wasn't fixed.
    It is currently an important issue for me.

    Could you help me to fix this?
    For which cases we need isPrimitive check?
    According to me we can just remove first part of check - !Utils.isPrimitive(value) || . Am I right?

  6. Kirill89 commented on Apr 28, 2018

    @Kirill89
    Contributor

    Guys, please take a look at the pull request. We really suffer about this bug.

  7. sushantdhiman commented on Apr 29, 2018

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions