Skip to content

docs: cqn4sql path expression transformations - #1558

Open
patricebender wants to merge 2 commits into
mainfrom
patrice/cqn4sql-doc
Open

docs: cqn4sql path expression transformations#1558
patricebender wants to merge 2 commits into
mainfrom
patrice/cqn4sql-doc

Conversation

@patricebender

Copy link
Copy Markdown
Member

Summary

  • Adds a document covering all join-related path expression transformations in cqn4sql
  • Covers association-to-join, exists subqueries, expand/inline, infix filters, inner joins in exists, FROM navigation, and UPDATE/DELETE rewrites
  • Documents the current limitation around join-relevant paths in infix filters and the planned concept from feat(a2j): enable path expression inside filter #1361


### FK shortcut — no join needed

If the path accesses only a foreign key field (or the association itself without further navigation), no join is generated:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

clarify: what if also another field is accessed via the assoc?

{ author.name as author_name }
```

The same association with **different filters** (or with/without a filter) produces **separate joins** with unique aliases:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why "with/without"?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

→ the same association once with a filter and once without a filter produce separate joins

}
```

Infix filters also apply in `exists` and `FROM` navigation, where they become conditions in the `WHERE EXISTS` subquery.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
Infix filters also apply in `exists` and `FROM` navigation, where they become conditions in the `WHERE EXISTS` subquery.
Infix filters also can occur in `exists` and `FROM` navigation, where they become conditions in the `WHERE EXISTS` subquery.


## 3. WHERE EXISTS Subqueries

Both association paths in `FROM` and the `exists` predicate produce `WHERE EXISTS` correlated subqueries. The mechanics are the same — a `FROM` path like `Authors:books` is semantically equivalent to `SELECT from Books where exists author`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
Both association paths in `FROM` and the `exists` predicate produce `WHERE EXISTS` correlated subqueries. The mechanics are the same — a `FROM` path like `Authors:books` is semantically equivalent to `SELECT from Books where exists author`.
Association paths both in `FROM` and in an `exists` predicate produce `WHERE EXISTS` correlated subqueries. The mechanics are the same — a `FROM` path like `Authors:books` is semantically equivalent to `SELECT from Books where exists author`.


### Association in FROM

An association step in the `FROM` clause rewrites the query target to the association's target entity and adds a `WHERE EXISTS` subquery correlating back to the source:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
An association step in the `FROM` clause rewrites the query target to the association's target entity and adds a `WHERE EXISTS` subquery correlating back to the source:
An association step in the `FROM` clause moves the query target to the association's target entity and adds a `WHERE EXISTS` subquery correlating back to the source:

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