Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Insert Statement exposes its columns in the SELECT query #601

Open
hfhbd opened this issue Feb 2, 2024 · 0 comments
Open

Insert Statement exposes its columns in the SELECT query #601

hfhbd opened this issue Feb 2, 2024 · 0 comments
Labels

Comments

@hfhbd
Copy link
Collaborator

hfhbd commented Feb 2, 2024

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)

@hfhbd hfhbd added the bug label Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant