Sequelize列名/属性冲突?

时间:2011-10-19 19:45:57

标签: javascript node.js sequelize.js

我正在尝试为具有options列的表创建一个sequelize模型,但是当我尝试查询时遇到错误(例如,查找):

/Users/camupod/node_modules/sequelize/lib/sequelize/model.js:17
  var defaults = this.options.hasPrimaryKeys ? {} : { id: null }
                             ^
TypeError: Cannot read property 'hasPrimaryKeys' of null
    at new <anonymous> (/Users/camupod/node_modules/sequelize/lib/sequelize/model.js:17:30)
    at [object Object].build (/Users/camupod/node_modules/sequelize/lib/sequelize/model-definition.js:140:18)
    at /Users/camupod/node_modules/sequelize/lib/sequelize/query.js:47:64
    at Array.map (native)
    at [object Object].onSuccess (/Users/camupod/node_modules/sequelize/lib/sequelize/query.js:47:22)
    at /Users/camupod/node_modules/sequelize/lib/sequelize/query.js:22:38
    at Query.<anonymous> (/Users/camupod/node_modules/mysql/lib/client.js:108:11)
    at Query.emit (events.js:61:17)
    at Query._handlePacket (/Users/camupod/node_modules/mysql/lib/query.js:51:14)
    at Client._handlePacket (/Users/camupod/node_modules/mysql/lib/client.js:312:14)

我模型的定义:

Model.recording = sequelize.define(
    'recordings',
    {
        /* other columns... */
        options: Sequelize.TEXT
    },
    {
        timestamps: false,
        freezeTableName: true
    }
);

sequelize真的不允许options作为列名,还是我做错了什么?

1 个答案:

答案 0 :(得分:2)

嗯,这是一个非常愚蠢的“边缘”。定义一个名为“options”的属性将覆盖模型的选项:D糟透了:(。

问题刚刚解决,修复程序在v1.1.3中可用。如果有效,请告诉我。