MySQL Forums
Forum List  »  Connector/Node.js

Value expression strings on relational table update
Posted by: Lianto Lim
Date: February 01, 2021 09:18AM

I read in the documentation that "Value expression strings are used to compute a value which can then be assigned to a given field or column", but I can't get it working with relational table update function using nodejs @mysql/xdevapi@8.0.23.

Portion of code in node.js:
return customerTable.update()
.set("age", mysqlx.expr("age+1"))
.where("name = :name")
.bind('name', 'Andy')
return an error: Unknown column 'doc' in 'field list'
and the log file shows the following query:
UPDATE `customers` SET `age`=(JSON_EXTRACT(doc,'$.age') + 1) WHERE (`name` = 'Andy')

Meanwhile, I test it on MySQL Shell 8.0, with the following portion of code:
set("age", mysqlx.expr("age + 1")).
where('name = :name').
bind('name', 'Andy').
it runs fine and show the following in the log file:
UPDATE `test`.`customers` SET `age`=(`age` + 1) WHERE (`name` = 'Andy')

Can someone help to point out the mistake?

Options: ReplyQuote

Written By
Value expression strings on relational table update
February 01, 2021 09:18AM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.