Error "inconsistent types deduced" for table save method
Created by: stephensong
Hi guys,
Found an issue with the table save command.
db.users.save({userId: userId, userName: newName, updated: dt }, function (err,rslt) {
where userId is the pk of the users table. It yielded the following error:
"Unhandled rejection error: inconsistent types deduced for parameter $1"
and the generated sql was:
UPDATE "users" SET "userName" = $1, "updated" = $2
WHERE "userId" = $1 RETURNING *
which is clearly wrong. Am I doing something wrong? I found a simple fix in the source was to simply remove a line from the table save method:
if(this.containsPk(args)){
var pk = this.primaryKeyName();
//it's an update, use the id to run it
var where = {};
where[pk] = args[pk];
commented out the following line:
//delete args[pk];
this.update(args,where,next);
}else{
which seems like it should be ok - yes?
It seems like the code is written with the implicit assumption that the pk field will always be the last, which in my case was not true (alas!).
thanks.