sqlc
sqlc copied to clipboard
Querry appends .* to last column in SELECT when trying to use "table".*
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
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.