gpt4 book ai didi

javascript - 序列化列名/属性冲突?

转载 作者:行者123 更新时间:2023-12-02 20:02:22 26 4
gpt4 key购买 nike

我正在尝试为具有 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 作为列名,还是我做错了什么?

最佳答案

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

该问题刚刚得到修复,并且 bug 修复已在 v1.1.3 中提供。请告诉我这是否有效。

关于javascript - 序列化列名/属性冲突?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7827186/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com