KNEX Undefined binding(s) detected when compiling SELECT query

Viewed 23678
var knex = require('knex')(config);
var bookshelf = require('bookshelf')(knex);
var SKU = bookshelf.Model.extend({
    tableName: 'skus',

});
SKU.where('id', undefined).fetch().then(function (skus) {
    if (skus) console.log(skus.toJSON());
}).catch(function (err) {
    console.error(err);
});

It throws

Undefined binding(s) detected when compiling SELECT query.

It is working fine with 0.11.5, it stopped working with 0.11.6 onwards. I am pointing to 0.13.0 right now.

useNullAsDefault: true

works fine with insert queries but not select queries. Is there any flag i should pass to resolve this error?

2 Answers

the parameter which sql query is expecting and the parameter you sending in requestbody is not matching. in my case sql was expecting parameter "gradeId" but in requestBody i was sending "postId"

Related