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

Fix many-to-one-one queries #3463

Merged
merged 2 commits into from
Aug 25, 2020
Merged

Fix many-to-one-one queries #3463

merged 2 commits into from
Aug 25, 2020

Conversation

timleslie
Copy link
Contributor

No description provided.

@changeset-bot
Copy link

changeset-bot bot commented Aug 25, 2020

🦋 Changeset is good to go

Latest commit: 1352457

We got this.

This PR includes changesets to release 2 packages
Name Type
@keystonejs/api-tests Patch
@keystonejs/adapter-knex Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@request-info
Copy link

request-info bot commented Aug 25, 2020

It looks like we could use some more details. Good titles and descriptions help us fix things faster. If you can provide more information please update this issue.

@timleslie timleslie force-pushed the fix-many-to-one-to-one branch 2 times, most recently from b232459 to 12b34cf Compare August 25, 2020 03:34
@@ -869,10 +872,13 @@ class QueryBuilder {
);
}

const subSubQuery = listAdapter.parentAdapter.knex.raw(
`SELECT "${selectCol}" FROM (${subQuery}) AS unused_alias`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need an alias?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://www.postgresql.org/docs/12/sql-select.html

A sub-SELECT can appear in the FROM clause. This acts as though its output were created as a temporary table for the duration of this single SELECT command. Note that the sub-SELECT must be surrounded by parentheses, and an alias must be provided for it. A VALUES command can also be used here.

@timleslie timleslie merged commit 096d13f into master Aug 25, 2020
@timleslie timleslie deleted the fix-many-to-one-to-one branch August 25, 2020 04:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants