2

我正在尝试将 jsonb 数组中的一系列值插入到 postgres 中。但是,我得到了错误error: invalid input syntax for uuid:

我的数据看起来像这样

[
  {
    code: "dwfwradsa",
    purpose: "description",
    id: uuid (real uuid, this is just a placeholder)
  },
  {repeat},
  {repeat}
]

我的功能的相关部分如下。@codes 是传递给函数的参数。

  INSERT INTO
    "codes" (
      "code",
      "purpose",
      "id"
    )
  SELECT
    codes->>'code',
    codes->>'purpose',
    codes->>'id'::UUID -- this is a foreign key from another table
  FROM jsonb_array_elements("@codes") codes
  ON CONFLICT ON CONSTRAINT unique_code DO NOTHING;

即使铸造似乎也不能解决问题。

如果我不投,我会收到此错误error: column "column_name" is of type uuid but expression is of type text

4

0 回答 0