Skip to content

Table alias not working #1385

Open
Open

Description

@FreshPer

Version

1.11.0

What happened?

In v1.11.0, when I use an alias for a subquery table, sqlc will report an error for table alias does not exist, but when I change version to v1.10.0 everything is fine

Relevant log output

table alias "subtable" does not exist

Database schema

No response

SQL queries

`
select a.name
from (a subquery) as a
where a.id=?

`

Configuration

No response

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

Activity

  1. added
    bugSomething isn't working
    triageNew issues that hasn't been reviewed
    on Jan 21, 2022
  2. tcastelly commented on Nov 29, 2022

    @tcastelly

    Hello,

    Does someone has a workaround?

  3. ChurchOfTheSubgenius commented on May 10, 2023

    @ChurchOfTheSubgenius

    Any update on this?

  4. smantic commented on Jun 1, 2023

    @smantic

    casting the type of the placeholder seems to be a work around.
    See: https://play.sqlc.dev/p/13001a43c6063935dd690269b5e9c640a9632f3f478680b628724e1da9cf6483

    Also wanted to mention this is only an issue when you have
    subquery_alias.column = $<placeholder>
    subquery_alias.column = 'static_value' works just fine

  5. Dmdv commented on May 15, 2024

    @Dmdv

    Hi everyone
    This error persist since 2022.
    Can someone ping the pull request #3220
    How one can possibly work without CTE or joins?
    Is SQLC only for primitive cases?

    Please, pay attention to issues:
    #2400
    #3169
    #1385

    Though the solution of @smantic works well:
    #1385 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions