错误:从Bookshelf.js的SELECT编译时检测到未定义的绑定save() [英] Error: Undefined binding(s) detected when compiling SELECT from Bookshelf.js save()

查看:60
本文介绍了错误:从Bookshelf.js的SELECT编译时检测到未定义的绑定save()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用 oracledb 客户端(版本如下)测试 Bookshelf 模型插入时,我遇到了一个奇怪的错误.我已经使用 mysql pg sqlite3 客户端测试了相同的代码,而该操作没有问题.

While testing a Bookshelf model insert using the oracledb client (versions bellow), I'm having an strange error. I've tested same code with mysql, pg and sqlite3 clients with no problem in this operation.

我的模特是这样的

    Promotion = bookshelf.model('Promotion', {
          tableName: 'promotions'     
    })

触发错误的动作是这样的:

And the action that triggered the error is this:

Promotion.forge({image:"image","featured":false,"price":"2.33","name":"name","description":"description"}).save(null, { method:'insert' })

插入操作似乎已在数据库中执行并提交,但客户端返回此错误:

The insertion seems to be performed and commited in the database but the client returns this error:

(node:1098008) UnhandledPromiseRejectionWarning: Error: Undefined binding(s) detected when compiling SELECT. Undefined 
column(s): [promotions.id] query: select * from (select "promotions".* from "promotions" where "promotions"."image" = ?
 and "promotions"."featured" = ? and "promotions"."price" = ? and "promotions"."name" = ? and "promotions"."description
" = ? and "promotions"."id" = ?) where rownum <= ?                                                                     
    at Oracledb_Compiler.toSQL (/home/user/src/tests/app/api/node_modules/knex/lib/query/compiler.js:101:13)
    at Builder.toSQL (/home/user/src/tests/app/api/node_modules/knex/lib/query/builder.js:77:44)
    at /home/user/src/tests/app/api/node_modules/knex/lib/runner.js:30:36
    at /home/user/src/tests/app/api/node_modules/knex/lib/runner.js:253:24
    at tryCatcher (/home/user/src/tests/app/api/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/home/user/src/tests/app/api/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/home/user/src/tests/app/api/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromise0 (/home/user/src/tests/app/api/node_modules/bluebird/js/release/promise.js:649:10)
    at Promise._settlePromises (/home/user/src/tests/app/api/node_modules/bluebird/js/release/promise.js:729:18)
    at _drainQueueStep (/home/user/src/tests/app/api/node_modules/bluebird/js/release/async.js:93:12)
    at _drainQueue (/home/user/src/tests/app/api/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/home/user/src/tests/app/api/node_modules/bluebird/js/release/async.js:102:5)
    at Immediate.Async.drainQueues (/home/user/src/tests/app/api/node_modules/bluebird/js/release/async.js:15:14)
    at processImmediate (internal/timers.js:439:21)
    at process.topLevelDomainCallback (domain.js:130:23)
(node:1098008) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing 
inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)

使用此版本:

  • 书架 1.1.0(还测试了1.0.1,但存在相同的错误)
  • knex 0.20.9(也是0.20.8)
  • oracledb 4.2.0
  • bookshelf 1.1.0 (also tested 1.0.1 with same error)
  • knex 0.20.9 (also 0.20.8)
  • oracledb 4.2.0

非常感谢您的提前帮助.

Thank you very much for your help in advance.

推荐答案

我遇到了同样的问题.将新实例保存到数据库后,select语句失败.像这样修复它:

I had the same issue. after saving the new instance to the database, the select statement fails. fixed it like this:

 await new BusinessOwnerSpecialty(newSpecialty)
        .save(null,{autoRefresh:false})

{autoRefresh:false} 选项解决了该问题. 来源: https://bookshelfjs.org/api.html#Model-instance-save

The {autoRefresh:false} option fixed the issue. source : https://bookshelfjs.org/api.html#Model-instance-save

这篇关于错误:从Bookshelf.js的SELECT编译时检测到未定义的绑定save()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆