序列化列名/属性冲突?
我正在尝试为具有 options
列的表创建一个续集模型,但是当我尝试查询(例如查找)时出现错误:
/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
}
);
确实续集吗不允许 options
作为列名,还是我做错了什么?
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):
/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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
嗯,这是一个非常愚蠢的“边缘情况”。定义一个名为“options”的属性将覆盖模型的选项:D,这很糟糕:(。
这个问题刚刚得到解决,并且 bug 修复在 v1.1.3 中可用。请告诉我这是否有效。
Well, that's a pretty stupid "edgecase". Defining an attribute called "options" will overwrite the options of the model :D that sucks :(.
The issue was just fixed and the bugfix is available in v1.1.3. Please let me know if that works.