You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bookshelf.js update command not returning expected data after updating rows in database. This is observed if instead of using id-attrtibute, a where clause is used to add conditions for the update query.
Pre-requisites :
I have below dummy table structure (If anyone wants to replicate can use below query) :
CREATE TABLE `dummy` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`first_name` varchar(20) NOT NULL,
`last_name` varchar(20) NOT NULL,
`status` tinyint(1) NOT NULL COMMENT '1:Active, 9:Deleted',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
Ideally I should get the row whose first_name is "Bharti" but I'm getting some vague row. Although behind the scenes, bookshelf has updated the right row in db.
Here is what bookshelf.js is returning :
Bookshelf.js update command not returning expected data after updating rows in database. This is observed if instead of using id-attrtibute, a where clause is used to add conditions for the update query.
Pre-requisites :
I have below dummy table structure (If anyone wants to replicate can use below query) :
Below are the rows in the table :
Model Definition using Bookshelf.js :
Issue #1: I want to set status to 9 for [1,2,3] id's and i'm using below query for the same:
Ideally Bookshelf.js should return all 3 rows but it is returning only 1 row. Although bookshelf.js has updated 3 rows in db.
Here is what bookshelf.js is returning :
Has anyone faced such issue or am I using wrong query?
Issue #2 : : I want to update last_name to 'Sam' of a row whose first_name is 'Bharti' and below is the query I'm using :
Ideally I should get the row whose first_name is "Bharti" but I'm getting some vague row. Although behind the scenes, bookshelf has updated the right row in db.
Here is what bookshelf.js is returning :
Has anyone faced such issue or am I using wrong query?
The text was updated successfully, but these errors were encountered: