Skip to content

fix: bump sqlc fork to restore CTE scope tracking - #32187

Merged
mafredri merged 2 commits into
mainfrom
mafredri/sqlc-cte-scope-fix
Nov 17, 2026
Merged

mafredri merged 2 commits into
mainfrom
mafredri/sqlc-cte-scope-fix

Conversation

@mafredri

Copy link
Copy Markdown
Member

Bumps the coder/sqlc pin to fb627c9c, which restores the CTE scope fix (coder/sqlc#1). That fix lets sqlc generate valid queries that put a subquery inside a CTE, instead of failing with a false column reference "..." is ambiguous.

#25105 moved the pin to coder/sqlc's merge of upstream v1.31.1 (337309bf). The fix had only ever existed on the side branch the old pin pointed at, so the new pin silently dropped it. Nothing broke because the one query that needed it, GetWorkspaces, had been rewritten in #22290 and its trigger removed in #29085. coder/sqlc#1 is now on the fork's main.

Generated code is unchanged. The flake.nix comment now says what the fork adds on top of upstream. The flake vendorHash stays the same because the fork's go.mod and go.sum did not change. I computed the new src hash with nix-prefetch-url --unpack; the same command reproduces the old hash for 337309bf.

Regression check

Checked against main (d412c38afb) with sqlc built from fb627c9c:

  • make gen and scripts/check_unstaged.sh: clean, no generated file changes.
  • sqlc vet against a migrated database: passes, as it does with 337309bf.
  • go test ./coderd/database/...: passes.

The fix still matters for queries like the original #20501 GetWorkspaces. That query was the owner_id sort in filtered_workspaces_order, with the EXISTS (SELECT 1 FROM tasks ...) filter in filtered_workspaces. On 25af21b5d5~1 with that sort restored, 337309bf fails with workspaces.sql:403:13: column reference "owner_id" is ambiguous, and the fixed build generates it.

In the fork, go test ./... against PostgreSQL 16 fails the same tests with and without the fix: TestReplay/{base,managed-db}/wasm_plugin_sqlc_gen_unsafe_paths. That test's expected path depends on where the repository is checked out.

No queries in coderd/database/queries carry casts, aliases, or type hints that exist because of this bug, so none are simplified here.

🤖 Created with the help of Coder Agents.

The pin moved to coder/sqlc's merge of upstream v1.31.1 in #25105, but
the CTE scope fix (coder/sqlc#1) had never been merged into the fork's
main, so it was dropped. coder/sqlc#1 is now on main as fb627c9c.
Generated code is unchanged.

The flake vendorHash stays the same: the fork's go.mod and go.sum did
not change.
@mafredri
mafredri temporarily deployed to main November 13, 2026 17:42 — with GitHub Actions Inactive
@mafredri
mafredri temporarily deployed to main November 13, 2026 17:42 — with GitHub Actions Inactive
@mafredri

Copy link
Copy Markdown
Member Author

@codex review

@mafredri
mafredri temporarily deployed to main November 17, 2026 10:14 — with GitHub Actions Inactive
@mafredri
mafredri marked this pull request as ready for review November 17, 2026 10:14
@mafredri
mafredri temporarily deployed to main November 17, 2026 10:14 — with GitHub Actions Inactive
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T10:16:22.358568Z d8844c4 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: d8844c44d4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@mafredri
mafredri merged commit d3e471f into main Nov 17, 2026
34 of 35 checks passed
@mafredri
mafredri deleted the mafredri/sqlc-cte-scope-fix branch November 17, 2026 10:41
@mafredri
mafredri temporarily deployed to main November 17, 2026 10:41 — with GitHub Actions Inactive
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 17, 2026

This branch had an error being deployed

1 failed and 1 inactive deployments
main — d8844c44 Deployed Nov 17, 2026 by mafredri via cla #258526
docs-preview — d8844c44 Deployed Nov 17, 2026 by mafredri via cleanup #158
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants