Skip to content

Insert Statement exposes its columns in the SELECT query #601

Open
@hfhbd

Description

Failing ANSI SQL

CREATE TABLE siths(
name TEXT
);

CREATE TABLE jedi(
name TEXT
);

INSERT INTO siths (name)
SELECT jedi.name
FROM jedi
LEFT JOIN siths ON jedi.name = siths.name -- Multiple columns found with name name
WHERE siths.name IS NULL;

Description

To resolve the column name in the column list here (name), it using the same function queryAvailable(). This behavior is not expected with a INSERT ... SELECT, the select query has no access to the table unless it is explicitly joined.

Unfortunately, you need this behavior when using ON CONFLICT SET UPDATE, in this case the table is exposed as old/new.

There is a workaround through: INSERT INTO siths AS notAvailable (name)

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions