You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to write a query that uses multiple tables with duplicated columns (through a NATURAL JOIN) it appears we need to use table aliases, instead of being able to reference the table name.
Relevant log output
# package db
queries.sql:59:3: column "engine" does not exist
exit status 1
internal/datasources/awsrds/db/generate.go:3: running "go": exit status 1
Database schema
CREATETABLEIF NOT EXISTS aws_rds_databases (
account_id TEXTNOT NULL,
region TEXTNOT NULL,
arn TEXTNOT NULL,
name TEXTNOT NULL,
engine TEXTNOT NULL,
engine_version TEXTNOT NULL,
-- tags is a JSON object
tags TEXTNOT NULL,
UNIQUE (account_id, region, arn) ON CONFLICT REPLACE
);
CREATETABLEIF NOT EXISTS aws_rds_databases_engines (
engine TEXTNOT NULL,
engine_version TEXTNOT NULL,
deprecation TEXTNOT NULL,
UNIQUE (engine, engine_version) ON CONFLICT REPLACE
);
SQL queries
-------------------- this is expected to fail, due to:--> # package db--> queries.sql:59:3: column reference "engine" is ambiguous-- name: RetrieveAllWithDeprecation :manyselect
arn,
name,
engine
from
aws_rds_databases
natural join aws_rds_databases_engines;
-------------------- expected to work-- name: RetrieveAllWithDeprecation :manyselect
arn,
name,
aws_rds_databases.enginefrom
aws_rds_databases r
natural join aws_rds_databases_engines
;
-------------------- this works, however-- name: RetrieveAllWithDeprecation :manyselect
arn,
name,
r.enginefrom
aws_rds_databases r
natural join aws_rds_databases_engines
;
Version
1.17.2
What happened?
When trying to write a query that uses multiple tables with duplicated columns (through a
NATURAL JOIN
) it appears we need to use table aliases, instead of being able to reference the table name.Relevant log output
Database schema
SQL queries
Configuration
Playground URL
https://play.sqlc.dev/p/9c6cd6f2df6585a2c1b5d5762b350179a9c78af984f8a657233c433153ca8732
What operating system are you using?
Linux, macOS
What database engines are you using?
SQLite
What type of code are you generating?
Go
The text was updated successfully, but these errors were encountered: