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

Join Helpers FROM Clause Doesn't Use Alias (psql) #112

Closed
davidwarshaw opened this issue Oct 9, 2023 · 2 comments · Fixed by #115
Closed

Join Helpers FROM Clause Doesn't Use Alias (psql) #112

davidwarshaw opened this issue Oct 9, 2023 · 2 comments · Fixed by #115
Labels
bug Something isn't working

Comments

@davidwarshaw
Copy link

davidwarshaw commented Oct 9, 2023

First, thanks for the great project!

When using join helpers with a schema-ed DB in version v0.20.5, it seems that the join FROM clause doesn't use an alias, but the ON clause does.
This:

	q := bobmodel.AJets(ctx, db,
		bobmodel.SelectJoins(ctx).AJets.InnerJoin.Pilot,
	)
	fmt.Println(q.MustBuild())

Gives me:

SELECT 
*
FROM "a"."jets" AS "a.jets"
INNER JOIN "a"."pilots" ON ("a.pilots"."pilotid" = "a.jets"."pilotid")

Which gives the error:

pq: missing FROM-clause entry for table "a.pilots"

It looks like the join helper should alias the table name, like so:

SELECT 
*
FROM "a"."jets" AS "a.jets"
INNER JOIN "a"."pilots" AS "a.pilots" ON ("a.pilots"."pilotid" = "a.jets"."pilotid")
@stephenafamo
Copy link
Owner

Looks like a bug. I'll find some time to fix it, if it is urgent for you, you can send in a PR and I'll review it.

@stephenafamo stephenafamo added the bug Something isn't working label Oct 11, 2023
@stephenafamo
Copy link
Owner

Check if #115 fixes this for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants