Skip to content

Update items fail on remapped column #506

Closed

Description

@hkbenchan

Node version: 0.10.25
orm version: 2.1.13
mysql version: 2.3.0

Reproduce of the bug:

Create a model that has a key with mapsTo enable, e.g.

var Model = db.define('model', {
    name: String,
    remapKey: { type: "text", mapsTo: "remap_key" }
});;

Later, when save an item that is gotten from Model.get(),

modelObject.remapKey = "another value";
modelObject.save(function (err) {
    if (err) throw err;
    cb();
}

it will throw an error on mysql level, error message as follow

ER_BAD_FIELD_ERROR: Unknown column 'remapKey' in 'field list'

First quick investigation suggests bugs on function savePersisted() on Instance.js with line 246, which

data[opts.changes[i]]

will return an undefined value

Could you please help on fixing this?

Activity

  1. dxg commented on May 22, 2014

    @dxg
    Collaborator

    It seems the implementation of mapsTo was very broken (missing in most cases).
    I've fixed it & written better tests. Please try v2.1.14.

  2. hkbenchan commented on May 25, 2014

    @hkbenchan
    Author

    Thanks, the problem also happens on any instance returned by find()

    The one on get() is fixed

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions