Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sqlc could not support table alias (error: table alias "t1" does not exist) #2400

Open
ankisme opened this issue Jul 4, 2023 · 1 comment
Labels
📚 mysql bug Something isn't working 🔧 golang

Comments

@ankisme
Copy link

ankisme commented Jul 4, 2023

Version

1.18.0

What happened?

Sqlc could not support table alias, the sql example is in below.

The error message is "table alias "t1" does not exist"

Relevant log output

No response

Database schema

CREATE TABLE authors (
          id   BIGINT PRIMARY KEY AUTO_INCREMENT,
          name text      NOT NULL,
          bio  text
);

SQL queries

/* name: ListAuthors2 :many */
select * from (SELECT * FROM authors) as t1 where t1.id > ?;

Configuration

No response

Playground URL

No response

What operating system are you using?

No response

What database engines are you using?

No response

What type of code are you generating?

No response

@ankisme ankisme added bug Something isn't working triage New issues that hasn't been reviewed labels Jul 4, 2023
@kyleconroy kyleconroy added 📚 mysql 🔧 golang and removed triage New issues that hasn't been reviewed labels Jul 6, 2023
Jille added a commit to Jille/sqlc that referenced this issue Feb 27, 2024
kyleconroy pushed a commit that referenced this issue Mar 28, 2024
* fix(resolve): fix resolving reference to CTEs

Fixed resolving refs to CTEs by adding CTEs to the aliasMap and indexing
its columns when resolving catalog references.

Fix #3219

* feat(compiler): Support subqueries in the FROM clause

issue #2989, #2400 and probably others

---------

Co-authored-by: Simon Klee <hello@simonklee.dk>
Jille added a commit to Jille/sqlc that referenced this issue Apr 3, 2024
kyleconroy pushed a commit that referenced this issue Apr 4, 2024
…#3310)

* fix(resolve): fix resolving reference to CTEs

Fixed resolving refs to CTEs by adding CTEs to the aliasMap and indexing
its columns when resolving catalog references.

Fix #3219

* feat(compiler): Support subqueries in the FROM clause

issue #2989, #2400 and probably others

* chore(endtoend): Bump version in cte_resolve_ref to 1.26.0 to appease CI

---------

Co-authored-by: Simon Klee <hello@simonklee.dk>
@kyleconroy kyleconroy added this to the 1.27.0 milestone Apr 4, 2024
Jille added a commit to Jille/sqlc that referenced this issue Apr 4, 2024
Jille added a commit to Jille/sqlc that referenced this issue Apr 4, 2024
simonklee pushed a commit to simonklee/sqlc that referenced this issue Apr 9, 2024
simonklee pushed a commit to simonklee/sqlc that referenced this issue Apr 9, 2024
@Dmdv
Copy link

Dmdv commented May 15, 2024

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)

lisitsky pushed a commit to lisitsky/sqlc that referenced this issue Jun 21, 2024
* fix(resolve): fix resolving reference to CTEs

Fixed resolving refs to CTEs by adding CTEs to the aliasMap and indexing
its columns when resolving catalog references.

Fix sqlc-dev#3219

* feat(compiler): Support subqueries in the FROM clause

issue sqlc-dev#2989, sqlc-dev#2400 and probably others

---------

Co-authored-by: Simon Klee <hello@simonklee.dk>
lisitsky pushed a commit to lisitsky/sqlc that referenced this issue Jun 21, 2024
…sqlc-dev#3310)

* fix(resolve): fix resolving reference to CTEs

Fixed resolving refs to CTEs by adding CTEs to the aliasMap and indexing
its columns when resolving catalog references.

Fix sqlc-dev#3219

* feat(compiler): Support subqueries in the FROM clause

issue sqlc-dev#2989, sqlc-dev#2400 and probably others

* chore(endtoend): Bump version in cte_resolve_ref to 1.26.0 to appease CI

---------

Co-authored-by: Simon Klee <hello@simonklee.dk>
@kyleconroy kyleconroy removed this from the 1.27.0 milestone Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📚 mysql bug Something isn't working 🔧 golang
Projects
None yet
Development

No branches or pull requests

3 participants