Я пытаюсь запустить простой скрипт вставки, который загрузит объект json в postgresql db. Я получаю следующее сообщение об ошибке:
No data found
ERROR: INSERT has more target columns than expressions
LINE 132: INSERT INTO books (title, author, genre, year, createdAt, up...
^
SQL state: 42601
Character: 4152
CREATE TABLE Books (id SERIAL PRIMARY KEY, title VARCHAR(255) NOT NULL, author VARCHAR(255) NOT NULL, genre VARCHAR(255), year INTEGER, createdAt timestamp with time zone NOT NULL, updatedAt TIMESTAMP WITH TIME ZONE NOT NULL)
WITH books_json (doc) AS (VALUES(
'[
{
"author": "Jane Austen",
"createdAt": "2018-10-04 18:21:59.011 +00:00",
"genre": "Classic",
"title": "Emma",
"updatedAt": "2018-10-04 18:21:59.011 +00:00",
"year": 1815
}
]'::json))
INSERT INTO books (title, author, genre, year, createdAt, updatedAt)
SELECT p.* FROM books_json l CROSS JOIN lateral
json_populate_recordset(NULL::contacts, doc) AS p ON conflict (id)
do UPDATE SET name = excluded.name, active = excluded.active;