Skip to content

Allow for DDL and unsupported statements as a query #2377

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

Closed
wants to merge 3 commits into from

Conversation

Jille
Copy link
Contributor

@Jille Jille commented Jun 28, 2023

By adding 'no-inference' to your query comment, sqlc won't try to understand your query. (The dolphin/postgresql/sqlite parser still need to understand your syntax.) This means that params and output columns don't work, but you can run any query you want.

Jille added 2 commits June 28, 2023 10:27
Like `-- name: InsertMulti :exec multiple` and `-- name: Select :many key=group_id`

issue sqlc-dev#2353
By adding 'no-inference' to your query comment, sqlc won't try to
understand your query. (The dolphin/postgresql parser still need to
understand your syntax.) This means that params and output columns don't
work, but you can run any query you want.
@andrewmbenton
Copy link
Collaborator

Sorry for the delay @Jille. I think we shouldn't introduce new query comment syntax, but the idea here is good. I think what we should do is allow :exec to be more permissive. In other words, I think (to modify your test example a little) the following should "just work" instead of silently doing nothing like sqlc does currently.

CREATE TABLE foo (val text not null);

-- name: CreateTempTable :exec
CREATE TEMPORARY TABLE bar (LIKE foo);

@andrewmbenton
Copy link
Collaborator

@Jille the new database-backed analyzer actually handles the test case in my last comment.

andrewmbenton added a commit that referenced this pull request Dec 19, 2023
…odes

This allows users to run generate on any parseable query, even
when sqlc doesn't understand it.

Closes #2377
andrewmbenton added a commit that referenced this pull request Dec 20, 2023
…odes (#3069)

This allows users to run generate on any parseable query, even
when sqlc doesn't understand it.

Closes #2377
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants