Skip to content

sqlc.arg(key) in subquery is not replaced with placeholder #2403

Closed

Description

@nobuyo

Version

1.18.0

What happened?

When generating query.sql.go, if there is a subquery in the query and one arg is used multiple times, the sqlc.arg in subquery is not expanded to a placeholder.

I've attached the playground url, thanks!

Relevant log output

No response

Database schema

No response

SQL queries

No response

Configuration

No response

Playground URL

https://play.sqlc.dev/p/4db6630bb57b14ff1913c150a2c0140e9eb4e587f54e93586f430e99681ae83b

Edit: add outer parenthesis to subquery, then it works.

https://play.sqlc.dev/p/8f4de494021b1db7476e47349f46a8d773575ef495399a5af5441cde3e9b41ae

What operating system are you using?

Linux

What database engines are you using?

MySQL

What type of code are you generating?

Go

Activity

  1. added
    bugSomething isn't working
    triageNew issues that hasn't been reviewed
    on Jul 5, 2023
  2. added a commit that references this issue on Jul 7, 2023
    7a60641
  3. added this to the v1.19.1 milestone on Jul 10, 2023
  4. added 3 commits that reference this issue on Jul 12, 2023
    156bd6d
    7686c18
    f5c528f
  5. added 2 commits that reference this issue on Oct 13, 2025
    b4727b8
    c7789f4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions