Error: Undefined binding(s) detected when compiling SELECT from Bookshelf.js save()

允我心安 提交于 2020-05-17 06:42:15

问题


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.

My model is this:

    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)

Using this versions:

  • 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.

来源:https://stackoverflow.com/questions/60234474/error-undefined-bindings-detected-when-compiling-select-from-bookshelf-js-sav

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!