Skip to content

Conversation

dennisgsmith
Copy link

@dennisgsmith dennisgsmith commented Jun 30, 2025

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
@dennisgsmith
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
Labels
size:XL This PR changes 500-999 lines, ignoring generated files. 🔧 golang
Projects
None yet
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