简体   繁体   English

Sequelize列名/属性冲突?

[英]Sequelize column name/property collision?

I am trying to create a sequelize model for a table that has an options column, but I get an error when I attempt a query (like find, for example): 我正在尝试为具有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)

And my model's definition: 而我的模型定义:

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

Does sequelize really not allow options as a column name, or am I doing something wrong? sequelize真的不允许options作为列名,或者我做错了什么?

Well, that's a pretty stupid "edgecase". 嗯,这是一个非常愚蠢的“边缘”。 Defining an attribute called "options" will overwrite the options of the model :D that sucks :(. 定义一个名为“options”的属性将覆盖模型的选项:D糟透了:(。

The issue was just fixed and the bugfix is available in v1.1.3. 问题刚刚解决,修复程序在v1.1.3中可用。 Please let me know if that works. 如果有效,请告诉我。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM