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

@cap-js/sqlite: search with multiple words leads to error #127

Open
sjvans opened this issue Jul 21, 2023 · 9 comments
Open

@cap-js/sqlite: search with multiple words leads to error #127

sjvans opened this issue Jul 21, 2023 · 9 comments
Labels
bug Something isn't working enhancement New feature or request postgres sqlite

Comments

@sjvans
Copy link
Contributor

sjvans commented Jul 21, 2023

  • customer reports error SQLite only supports single value arguments for $search.
  • fine on postgres.
  • should be avoided by concatenating multiple search clauses with OR
@danjoa
Copy link
Contributor

danjoa commented Jul 23, 2023

Can you add an example?

@sjvans
Copy link
Contributor Author

sjvans commented Jul 24, 2023

#132

@danjoa
Copy link
Contributor

danjoa commented Jul 24, 2023

Thanks. We intentionally decided to provide only limited support for $search beyond simple strings, at least in SQLite, as the complexity and performance overhead would be significant, and the value rather low as most end users don't do advanced search expressions. But we can revisit that.

@danjoa danjoa added the enhancement New feature or request label Jul 24, 2023
@sjvans
Copy link
Contributor Author

sjvans commented Jul 24, 2023

actually, the error also occurs on postgres, i.e., the error message wrongly status "SQLite".

i think we should revisit, at least for postgres. issue occurs as soon as user input contains a whitespace as this is an implicit AND as per OData spec. reproducible, for example, in sflight.

i added a change to my pr that would support it. not sure it's the right way, though. i'm not really familiar with this coding. ;)

@ArtyomAD
Copy link

Hello.

Can someone please clarify if this issue/missing functionality plan to be released soon?

We might require to disable main Search functionality in our Fiori application which is running on @cap-js/posgres exactly due to this issue.
$seach from fiori elements app

@gregorwolf
Copy link
Collaborator

Hi @ArtyomAD,

I would think that it would be better if you check if this issue also occurs when you use sqlite as then you could contribute the SQL statement that is created when you issue the query. Or you create a new issue which mentions the postgres driver.

@ArtyomAD
Copy link

ArtyomAD commented Aug 1, 2023

Hello @gregorwolf.

We face identical error in both cases with sqlite and postgres.

SQLite:
sqlite logs
Trace without $search:
sqlite trace without $search
Trace with $search:
sqlite trace with $search

Postgres in BTP:
postgres logs
Confirmation from BTP as it's running with postgres:
btp postgres db logs

@sebastianesch
Copy link
Collaborator

I can confirm that the issue also occurs with SQLite. The search input from Fiori Elements is passed directly to the search query - if the user enters a search string with whitespaces, search produces an error.

@sebastianesch
Copy link
Collaborator

This issue also breaks Fiori Elements apps, when users try to enter text with whitespaces in value help fields.

@patricebender patricebender added bug Something isn't working postgres labels Oct 9, 2023
johannes-vogel pushed a commit that referenced this issue Feb 20, 2024
…ds (#472)

This patch improves the error handling for #127 by showing a slightly
better understandable error message to the user.

Before:
<img width="622" alt="image"
src="https://github.com/cap-js/cds-dbs/assets/12449/370b718c-0efe-4c45-b0bb-afa7ad1549a0">

After:
<img width="620" alt="image"
src="https://github.com/cap-js/cds-dbs/assets/12449/032c340a-758d-43eb-825e-2b3b5afc22b8">

Seems like CAP expects an Error instance these days, because it accesses
error.message.
`Parameter 'error.message' must be type of 'string'`

# CDS setup
@sap/cds: 7.3.1
@sap/cds-compiler: 4.3.2
@sap/cds-dk (global): 7.3.2
@sap/cds-fiori: 1.1.0
@sap/cds-foss: 4.0.2
@sap/cds-mtxs: 1.12.1
@sap/eslint-plugin-cds: 2.6.3
Node.js: v18.19.1
cds-dbs: 1.3.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request postgres sqlite
Projects
None yet
Development

No branches or pull requests

6 participants