sqlc icon indicating copy to clipboard operation
sqlc copied to clipboard

Argument inside CTE not detected

Open cjtheham opened this issue 4 months ago • 0 comments

Version

1.29.0

What happened?

Using a CTE (WITH) before a SELECT statement with a ? argument in it (or sqlc.arg() call) - the argument is not detected by SQLC causing a missing argument error. Below is a redacted version of the query with the issue presented.

Relevant log output


Database schema


SQL queries

WITH submissions AS (
  SELECT *
  FROM 
    submissions 
  WHERE 
    submissions.id = ?
) 

SELECT *
FROM contracts 

WHERE contracts.id = ?;

Configuration

version: "1"
packages:
  - name: db
    path: db_generated
    schema: schema/*
    queries: queries/
    engine: mysql
    database:
      managed: true

Playground URL

No response

What operating system are you using?

macOS

What database engines are you using?

MySQL

What type of code are you generating?

Go

cjtheham avatar Jun 13 '25 17:06 cjtheham