INSERT has more expressions than target columns
Created by: FGRibreau
Hello !
I have two tables: user
& test
located in a private
schema.
- user has :
user_id
,avatar
,fullName
andcolor
columns - test has :
user_id
,icon_id
andurl
columns
I tried this with :
db.private.user.insert({ user_id: 'b146c47f-3380-49b4-8022-58a7d47f56d7',
avatar: 'string',
fullName: 'string',
color: 'string',
'private.test':
[ { user_id: 'b146c47f-3380-49b4-8022-58a7d47f56d7',
icon_id: 'twitter',
url: 'http://plokok' } ] });
And got the error INSERT has more expressions than target columns
.
The SQL generated is:
WITH inserted AS (
INSERT INTO "private"."user" ("user_id", "avatar", "fullName", "color")
VALUES ('481ea860-3555-4859-a373-7ae4da46816e', 'string', 'string', 'string')
RETURNING *
), q_0_0 AS (
INSERT INTO private.test ("user_id", "icon_id", "url")
SELECT "user_id", '481ea860-3555-4859-a373-7ae4da46816e', 'twitter', 'http://plokok'
FROM inserted
)
SELECT * FROM inserted
As we can see it seems massive adds a "SELECT "user_id"," where it should not and use "VALUES(" instead.
Note:
I had to explicitly specify private
schema for link relation, I had though db.private
was enough, is this a bug?