1

我正在使用节点 pg 客户端,并且我有一个表

create table test(
   id uuid not null constraint transactions_pkey primary key,
   name varchar(255),
   test_id uuid
);

我正在尝试将 test_id 更新为 NULL,但我无法以编程方式执行此操作。

这是我的更新查询

dbo.query('UPDATE test SET test_id = $1 WHERE id = $2',['null','f2aasced-5633-419c-95d3-3868dd3c9c53'])

它给了我一个错误

error: invalid input syntax for type uuid: "NULL"

4

1 回答 1

1

您只需尝试将字符串“null”插入 uuid 列。尝试

dbo.query('UPDATE test SET test_id = $1 WHERE id = $2',[null,'f2aasced-5633-419c-95d3-3868dd3c9c53'])
于 2019-01-25T07:09:36.963 回答