Skip to content

sqlc.embed() AS alias does not work #2655

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

Closed
kevinvalk opened this issue Aug 24, 2023 · 3 comments
Closed

sqlc.embed() AS alias does not work #2655

kevinvalk opened this issue Aug 24, 2023 · 3 comments
Labels
bug Something isn't working triage New issues that hasn't been reviewed

Comments

@kevinvalk
Copy link

Version

1.20.0

What happened?

The alias is not used when using sqlc.embed(name) AS alias.

// add a column with a reference to an embedded table
if embed, ok := qc.embeds.Find(n); ok {
cols = append(cols, &Column{
Name: embed.Table.Name,
EmbedTable: embed.Table,
})
continue
}

I think it would make sense to keep this information available somehow as now it is impossible to name sqlc.embed when using for example joins or views.

Relevant log output

No response

Database schema

No response

SQL queries

No response

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

@kevinvalk kevinvalk added bug Something isn't working triage New issues that hasn't been reviewed labels Aug 24, 2023
@orisano
Copy link
Contributor

orisano commented Aug 24, 2023

@andrewmbenton Should I work on this issue?

@kevinvalk
Copy link
Author

Small detail, you can use aliases inside the sqlc.embed. So you can do a SELECT sqlc.embed(t) FROM other_table LEFT JOIN some_table AS t ON .... That said, if you have a typo or did not name the embed correctly you immediately get an edited query syntax is invalid: syntax error at or near "," error, this is definitely not the nicest error to throw to an end user.

@kyleconroy
Copy link
Collaborator

Close as duplicate of #2686

@kyleconroy kyleconroy closed this as not planned Won't fix, can't repro, duplicate, stale Sep 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage New issues that hasn't been reviewed
Projects
None yet
Development

No branches or pull requests

3 participants