Reputation: 1422
I am using the following query:
const all = (context, merchantId) => {
return knex(TABLE)
.join('address', 'address.id', '=', 'hotel.id')
.select(
'hotel.id', 'hotel.name', 'hotel.description', 'hotel.thumbnail',
'address.city', 'address.state', 'address.country')
.where('merchant_id', merchantId)
.then(rows => {
return rows;
});
};
But getting error:
Error: Undefined binding(s) detected when compiling SELECT query: select `hotel`.`id`, `hotel`.`name`, `hotel`.`description`, `hotel`.`thumbnail`, `address`.`city`, `address`.`state`, `address`.`country` from `hotel` inner join `address` on `address`.`id` = `hotel`.`id` where `merchant_id` = ?
What I am missing?
Upvotes: 0
Views: 4201
Reputation: 1982
According to knex.js documentation
Important: Supplying knex with an undefined value to any of the where functions will cause knex to throw an error during sql compilation. This is both for yours and our sake. Knex cannot know what to do with undefined values in a where clause, and generally it would be a programmatic error to supply one to begin with. The error will throw a message containing the type of query and the compiled query-string.
Example:
knex('accounts') .where('login', undefined) .select() .toSQL()
Error:
Undefined binding(s) detected when compiling SELECT query: select * from `accounts` where `login` = ?
So I can guess that merchantId
in your code is undefined
Upvotes: 2