gpt4 book ai didi

node.js - Postgres SequelizeDatabaseError : syntax error at or near RETURNING

转载 作者:行者123 更新时间:2023-12-03 22:28:23 28 4
gpt4 key购买 nike

出于某种原因,Sequelize 驱动程序将: RETURNING * 添加到 select 语句的末尾。有谁知道为什么?

目的:

Lol.create({
id: record.dynamodb.NewImage.id.S,
userId: record.dynamodb.NewImage.userId.S,
summonerId: record.dynamodb.NewImage.summonerId.N,
name: record.dynamodb.NewImage.name.S,
profileIconId: record.dynamodb.NewImage.profileIconId.N,
summonerLevel: record.dynamodb.NewImage.summonerLevel.N,
revisionDate: record.dynamodb.NewImage.revisionDate.N,
createdAt: record.dynamodb.NewImage.createdAt.S,
updatedAt: record.dynamodb.NewImage.updatedAt.S
}).then(function (user) {
console.log(user);
}).catch(function (err) {
console.log(err);
});

错误:
name: 'SequelizeDatabaseError',
message: 'syntax error at or near "RETURNING"',
parent:
{ [error: syntax error at or near "RETURNING"]
name: 'error',
length: 136,
severity: 'ERROR',
code: '42601',
detail: undefined,
hint: undefined,
position: '330',
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: '/home/ec2-user/padb/src/pg/src/backend/parser/parser_scan.l',
line: '699',
routine: 'yyerror',
sql: 'INSERT INTO "Lol" ("id","userId","summonerId","name","profileIconId","summonerLevel","revisionDate","createdAt","updatedAt") VALUES (\'463d118c-2139-4679-8cdb-d07249bd2498\',\'a845a2ca-14c9-46de-93c6-d3dd1bd1a8a0\',\'2122373\',\'mariaraujo\',\'716\',\'30\',\'14804545500\',\'2017-01-09 18:50:15.282 +00:00\',\'2017-02-08 00:53:44.853 +00:00\') RETURNING *;' }

最佳答案

我可以让它工作,设置返回false:

Lol.create({
id: record.dynamodb.NewImage.id.S,
userId: record.dynamodb.NewImage.userId.S,
summonerId: record.dynamodb.NewImage.summonerId.N,
name: record.dynamodb.NewImage.name.S,
profileIconId: record.dynamodb.NewImage.profileIconId.N,
summonerLevel: record.dynamodb.NewImage.summonerLevel.N,
revisionDate: record.dynamodb.NewImage.revisionDate.N,
createdAt: record.dynamodb.NewImage.createdAt.S,
updatedAt: record.dynamodb.NewImage.updatedAt.S
}, {returning: false}).then(function (user) {
console.log(user);
}).catch(function (err) {
console.log(err);
});

关于node.js - Postgres SequelizeDatabaseError : syntax error at or near RETURNING,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42103966/

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