Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(compiler): insert-with-select statements #4006

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

Open
dennisgsmith wants to merge 1 commit into sqlc-dev:main
base: main
Choose a base branch
Loading
from dennisgsmith:dennisgsmith/fix-insert-cte-select-compiler-error

Conversation

Copy link

@dennisgsmith dennisgsmith commented Jun 30, 2025
edited
Loading

Fixes #3847
Fixes #3996

I was bumping into the above issues (but for postgres) and this bug seemed to be engine agnostic. After inspecting the output with SQLCDEBUG=dumpast=1 and SQLCDEBUG=dumpcatalog=1 I found that:

  1. The CTE relation name was not in the catalog when using insert-cte-select queries.
  2. The AST WithClause was under the SelectStmt, not directly within the parent InsertStmt node.

Using the SelectStmt WithClause when it's not null resolves the issue. Please let me know if there are any changes you'd like to see. Thanks!

@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. 🔧 golang labels Jun 30, 2025
Copy link
Author

@kyleconroy could you please review this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
size:XL This PR changes 500-999 lines, ignoring generated files. 🔧 golang
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

CTE doesn't get recognized by sqlc in insert statement. relation does not exist with insert using CTE
1 participant

AltStyle によって変換されたページ (->オリジナル) /