gpt4 book ai didi

mysql - _BAD_FIELD_ERROR : Unknown column 'table' in 'field list' with objection. js+mysql

转载 作者:行者123 更新时间:2023-11-29 06:12:04 26 4
gpt4 key购买 nike

我使用 mysql 数据库和 objection.js 来处理我的数据库操作。当我尝试插入值时,我收到 R_BAD_FIELD_ERROR:“字段列表”中的未知列“表”。这是我用于插入数据的代码,

Modelclass.query()
.insert( { storeId: xxxxxx,
itemLocalName: 'LSストレ',
itemCode: xxxxxx,
itemType: '',
skus: xxxxxx,
itemLevel: 'L2',
colorCode: '99',
colorName: 'Other',
regionCode: 'jqs' } )
.then(function () {
console.log( 'inserted' );
}).catch( function( err ) {
console.log( 'error while inserting, error : ' + err );
});

生成的查询是:

insert into `sampleTable` (`colorCode`, `colorName`,   `itemCode`, `itemLevel`, 
`itemLocalName`, `itemType`, `regionCode`, `skus`, `storeId`, `table`)
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )'
}

插入时出错:

insert into `sampleTable` (`colorCode`, `colorName`,   `itemCode`, `itemLevel`, 
`itemLocalName`, `itemType`, `regionCode`, `skus`, `storeId`, `table`)
values ('99', 'Other', 'xxxxxx', 'L2', 'LSストレ', '','jqs', 'xxxxxx', 'xxxxxx', 'sampleTable')

表字段包含在我的示例表中不存在的 objection.js 中

请帮我解决这个问题。

最佳答案

您的模型定义中有一些东西添加了 table 列。异议不会这样做。不看模型就不可能告诉你它是什么,但我有几个想法:

  1. 如果您覆盖了 $formatDatabaseJson 方法,您可能会无意中添加该列。
  2. 您在包含的类中有一个可枚举的 getter 属性。

将模型类定义添加到问题中会提供更好的答案。

关于mysql - _BAD_FIELD_ERROR : Unknown column 'table' in 'field list' with objection. js+mysql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37752289/

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