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

feat: path expressions inside filter of scoped queries #991

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

patricebender
Copy link
Member

@patricebender patricebender commented Jan 22, 2025

Support path expressions in infix filter conditions along a FROM clause.

  • Filter conditions at from.ref.at(-1):

    • SELECT: Render an INNER JOIN for each association traversal and attach it to the main query's FROM clause.
    • UPDATE/DELETE: Render an INNER JOIN for each association traversal and attach it to the subquery's FROM clause. Transform UPDATE/DELETE statements with path expressions into UPDATE … WHERE <Primary Key(s)> IN (<subquery>).
  • Filter conditions along from.ref (excluding the leaf ref.where):

    • SELECT/UPDATE/DELETE: Render an INNER JOIN for each association traversal and attach it to the corresponding EXISTS <subquery>.

)
})
it('renders nested inner joins for the path expression at the leaf of scoped queries', () => {
let query = CQL`SELECT from bookshop.Authors:books[genre.parent.name = null] { ID }`
Copy link
Contributor

Choose a reason for hiding this comment

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

What about books that don't have a genre? Should they also appear in the result?

@stewsk
Copy link
Contributor

stewsk commented Jan 28, 2025

There should be a test where there is a to-many association in the filter of the last path step.
Simply translating that to a JOIN would not be right, in my opinion, as this would potentially increase the size of the result set rather than reducing it (this is a mistake that we have already made when dealing with to-many assocs in the WHERE clause

@patricebender
Copy link
Member Author

There should be a test where there is a to-many association in the filter of the last path step. Simply translating that to a JOIN would not be right, in my opinion, as this would potentially increase the size of the result set rather than reducing it (this is a mistake that we have already made when dealing with to-many assocs in the WHERE clause

👍 having an inner join and not an left outer join for all filter path expressions should take care of that, shouldnt it?

@stewsk
Copy link
Contributor

stewsk commented Jan 28, 2025

having an inner join and not an left outer join for all filter path expressions should take care of that, shouldnt it?

no, concerning "duplication" there is no difference between INNER and LEFT OUTER

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.

3 participants