Closed
Description
Version
1.17.2
What happened?
The trailing .*
gets appended to the last column when trying to scope *
to a specific table in a join query.
SELECT "ledger".* ...
becomes
SELECT ledger.id, ledger.submitted_at.* ...
Here are the exact inputs and outputs
-- name: IndividualListRecords :many
SELECT
"ledger".*
FROM
"ledger"
INNER JOIN
"ledger_party"
ON "ledger"."id" = "ledger_party"."ledger_id"
INNER JOIN
"party_identifier"
ON "ledger_party"."party_id" = "party_identifier"."party_id"
WHERE
"party_identifier"."party_id" = $1
OR
(
"party_identifier"."identifier" = $2
AND $2 != ''
)
;
const individualListRecords = `-- name: IndividualListRecords :many
SELECT
ledger.id, ledger._old_id, ledger.record_type, ledger.account_id, ledger.data, ledger.submitted_by, ledger.submitted_as, ledger.submitted_at.*
FROM
"ledger"
INNER JOIN
"ledger_party"
ON "ledger"."id" = "ledger_party"."ledger_id"
INNER JOIN
"party_identifier"
ON "ledger_party"."party_id" = "party_identifier"."party_id"
WHERE
"party_identifier"."party_id" = $1
OR
(
"party_identifier"."identifier" = $2
AND $2 != ''
)
`
I need to go fix this. I'm just documenting it here for now. I see there are hundreds of open issues, so HMU if you need more info to investigate and I'll provide it.
Relevant log output
ERROR: missing FROM-clause entry for table "submitted_at" (SQLSTATE 42P01)
Database schema
No response
SQL queries
-- name: IndividualListRecords :many
SELECT
"ledger".*
FROM
"ledger"
INNER JOIN
"ledger_party"
ON "ledger"."id" = "ledger_party"."ledger_id"
INNER JOIN
"party_identifier"
ON "ledger_party"."party_id" = "party_identifier"."party_id"
WHERE
"party_identifier"."party_id" = $1
OR
(
"party_identifier"."identifier" = $2
AND $2 != ''
)
;
Configuration
version: 2
sql:
- engine: "postgresql"
schema: "./migrations/"
queries: "./sql/queries/"
gen:
go:
package: "reportsv2"
out: "reportsv2"
sql_package: "pgx/v4"
emit_json_tags: true
json_tags_case_style: "snake"
overrides:
- column: "party_identifier.id"
go_struct_tag: 'json:"-"'
- column: "party_identifier.party_id"
go_struct_tag: 'json:"-"'
Playground URL
https://play.sqlc.dev/p/c81734d4c314b5313bfbd8547c20412f49594b8194665ba09107ed45bf286f76
What operating system are you using?
macOS
What database engines are you using?
PostgreSQL
What type of code are you generating?
Go