我尝试在我的续集查询中使用过程函数。
await model.sequelize.upsert({
id: '123',
code: 'usa',
country: model.sequelize.conn.fn('getCountry', 'usa')
});
这导致这些代码:
INSERT INTO "places" ("id","code","country")
VALUES ($1, $2, getCountry('usa'));
....
bind: [('123', 'usa']
我在日志中找不到任何错误,但是消息说EXEC('1234567') rollback: ...
(错误摘要)
{
connection:
Client {
_ending: false,
_connecting: false,
_connectionError: false,
hasExecuted: true},
finished: 'rollback' } }
当我在postgreSql编辑器中运行以上查询时,令我惊讶的是它起作用了,这就是令人困惑的地方。为什么它不能在编辑器上运行,但不能与sequeline一起使用?
什么原因导致它回滚?
我也尝试这样做:
await model.sequelize.upsert({
id: '123',
code: 'usa',
country: select getCountry('usa')"
});
/// below is what I get from the above sequelize
INSERT INTO "places" ("id","code","country")
VALUES ($1, $2, $3);
bind: [('123', 'usa', 'select getCountry('usa'))]
/// this also caused an error