-
Notifications
You must be signed in to change notification settings - Fork 14
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(search): enable deep search with path expressions #590
Conversation
support search via path expressions: - deep search via associations - include calculated elements if explicitly requested - keep existing caching mechanisms --- rework of #252
This is necessary if we expose an association in the inner query and traverse it in the outer query: ```cds select from (select from Books) { author.name } ``` to come up with a proper join node, we must add a table alias around the subquery in from. I came up with `__select__` as artifical name. To make it always unique, I request a unique alias from the subquery based on `__select__`, the subquery knows all outer aliases and is able to calculate a universally unique alias. bugs found in #590
if (searchTerm) { | ||
// Search target can be a navigation, in that case use _target to get the correct entity | ||
const { where, having } = transformSearch(searchTerm) | ||
if (where) inferred.SELECT.where = where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't you need to append the search terms instead of replacing the existing where/having clauses?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is done in line 243ff
blocked by > q = SELECT`from ${Books} as Foo { Foo.ID }`
Query {
SELECT: {
from: { ref: [ 'my.bookshop.Books' ], as: 'Foo' },
columns: [ { ref: [ 'Foo', 'ID' ] } ]
}
}
> q.elements
Uncaught:
Error: Couldn't resolve element "Foo/ID" in entity my.bookshop.Books [ 'ID', 'title', 'stock' ]
at /Users/patricebender/SAPDevelop/foo/node_modules/@sap/cds/lib/ql/infer.js:80:22
at Array.forEach (<anonymous>)
at Function.elements4 (/Users/patricebender/SAPDevelop/foo/node_modules/@sap/cds/lib/ql/infer.js:61:32)
at get elements [as elements] (/Users/patricebender/SAPDevelop/foo/node_modules/@sap/cds/lib/ql/SELECT.js:157:53) |
Why would cds.infer have to handle aliases? Where do they stem from? |
If we want to support path expressions in a search annotation, we must attach the
Each |
🤖 I have created a release *beep* *boop* --- <details><summary>db-service: 1.11.0</summary> ## [1.11.0](db-service-v1.10.3...db-service-v1.11.0) (2024-07-08) ### Added * **search:** enable deep search with path expressions ([#590](#590)) ([e9e9461](e9e9461)) ### Changed * `search` interprets only first search term instead of raising an error ([#707](#707)) ([0b9108c](0b9108c)) ### Fixed * optimize foreign key access for expand with aggregations ([#734](#734)) ([77b7978](77b7978)) </details> <details><summary>hana: 1.1.0</summary> ## [1.1.0](hana-v1.0.1...hana-v1.1.0) (2024-07-08) ### Added * Enable native HANA fuzzy search for `search` function queries ([#707](#707)) ([0b9108c](0b9108c)) ### Fixed * **mtx:** sidecar scenario due to usage of wrong credentials ([#732](#732)) ([0b5c91f](0b5c91f)) </details> --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --------- Co-authored-by: Johannes Vogel <[email protected]>
support search via path expressions:
with
cds.infer
being a part of all our query objects, each query comes withtarget
andelements
even without theinfer
function of thedb-service
being called. Hence, it was possible to calculate the search term as a very first step ofcqn4sql
. After thecontains(…)
function has been added to the querieswhere
orhaving
clause the usual join tree algorithm is executed, making it possible to use path expressions within the search term.rework of #252