goliatone / core.io-data-manager

core.io Data manager module

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

BaseModel.updateOrCreate fails if criteria has numeric id but field is text/string

goliatone opened this issue · comments

If we have defined our update payload with a numeric id:

{
  "id": 1,
  "name": "goliat"
}

And our model:

let User = {
  attributes: {
    id:  {
      type: 'text',
      primaryKey: true,
      unique: true,
    }
};

The User.updateOrCreate call will fail, since User.findOne({id:1}) will return null but User.findOne({id:"1"}) will find the right record.