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

Querry appends .* to last column in SELECT when trying to use "table".* #1444

Closed
nd291195 opened this issue Feb 17, 2022 · 1 comment · Fixed by #2576
Closed

Querry appends .* to last column in SELECT when trying to use "table".* #1444

nd291195 opened this issue Feb 17, 2022 · 1 comment · Fixed by #2576

Comments

@nd291195
Copy link

nd291195 commented Feb 17, 2022

Version

1.12.0

What happened?

When I join two tables and try to select everything from only one of them using the "table".* syntax the generated code has .* appended to the last column in the SELECT statement of the query. This only happens if the table name is written in quotes.

Relevant log output

const bookFindByName = `-- name: BookFindByName :many
select book.id, book.name.*
from "book"
`

Database schema

create table if not exists "book"
(
  "id"         bigint generated by default as identity not null,
  "name" timestamptz,
  primary key ("id")
);

create table if not exists "author"
(
  "id"         bigint generated by default as identity not null,
  "name" timestamptz,
  primary key ("id")
);

create table if not exists "book_author"
(
  "book_id"       bigint not null,
  "author_id"	  bigint not null,
  primary key ("id")
);

SQL queries

-- name: BookFindBySome :many
select "book".*
from "book";

Configuration

{
  "version": "1",
  "packages": [
    {
      "path": "db",
      "engine": "postgresql",
      "schema": "query.sql",
      "queries": "query.sql"
    }
  ]
}

Playground URL

https://play.sqlc.dev/p/3e11ceef30748363dded68181cd1ee514a22e602642956351cb2a4511af55ee1

What operating system are you using?

macOS

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go

@nd291195 nd291195 added bug Something isn't working triage New issues that hasn't been reviewed labels Feb 17, 2022
@kyleconroy kyleconroy removed the triage New issues that hasn't been reviewed label Aug 28, 2022
@kyleconroy
Copy link
Collaborator

The issue is that sqlc isn't taking into account that "books".* is quoted. If you remove the quotes, the generated code is correct.

https://play.sqlc.dev/p/333efd4103b524488f7dd3de8fcb483788172191790474562f3997f30cc15247

Obviously still a bug but hopefully this will get you unblocked.

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

Successfully merging a pull request may close this issue.

2 participants