Open
Description
Version
1.20.0
What happened?
This prevent to do multiple join with the same table. Like a table making between multiple entries like linking users to users.
With the provided example the resulting struct would look like:
type ListUserRelationRow struct {
User User
User_2 User
}
I would expect it to look like:
type ListUserRelationRow struct {
Owner User
Consumer User
}
I could work on a fix. I just first want to make sure that it would be ok to switch to the format I would expect.
Relevant log output
No response
Database schema
CREATE TABLE users (
id INT UNSIGNED NOT NULL,
name VARCHAR(255) NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE user_links (
owner_id INT UNSIGNED NOT NULL,
consumer_id INT UNSIGNED NOT NULL,
PRIMARY KEY (owner_id, consumer_id)
);
SQL queries
-- name: ListUserRelation :many
SELECT
sqlc.embed(owner),
sqlc.embed(consumer)
FROM
user_links
INNER JOIN users AS owner ON owner.id = user_links.owner_id
INNER JOIN users AS consumer ON consumer.id = user_links.consumer_id;
Configuration
{
"version": "1",
"packages": [
{
"path": "db",
"engine": "mysql",
"schema": "query.sql",
"queries": "query.sql"
}
]
}
Playground URL
https://play.sqlc.dev/p/f81ff911dc5e18f6398998262c44b25169a2b4685d81c9dfc9669d962f3e26a5
What operating system are you using?
Linux
What database engines are you using?
MySQL
What type of code are you generating?
Go