-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
Search does not work on postgres citext fields #13726
Comments
To followup. I complete repaved the Directus instance. And found a sortof related bug, in that I modified a citext field using Directus, and after commiting the changes (to make it NOT NULL), I noticed that all of a sudden the "search" worked for that field. However I noticed that Directus when it altered the table to add not null, it also changed the field type to text from citext. (Which I guess makes sense if allowing Directus to manage the database). What was interesting, is that even with the column being text, case-INsensitive search functioned! Whereas a few versions ago it didn't function. So I'm not sure if I should close this bug. But I sure appreciate that Directus now supports case-insensitive search even on postgres without having to specify citext fields! |
This is an interesting one. Seems like the reason why it wasn't working initially is due to the search logic checks the field type to actually add said field into the WHERE query: directus/api/src/utils/apply-query.ts Lines 613 to 614 in 3e1c753
however, during this time (even though the App shows Tracing it back to the directus/packages/schema/src/dialects/postgres.ts Lines 32 to 35 in 3e1c753
will retrieve
but as @bamboowonder described, "updating the field" via disabling then re-enabling Feels like this is not really a Directus bug though, and could something to be explored in the knex-schema-inspector end, additionally since citext is Postgres-specific and there already is case-insensitive functionality built-in now. @rijkvanzanten thoughts on this? |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
|
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Describe the Bug
I've finally diagnosed why search is not working for us.
varchar fields are fine.
text fields are fine.
citext fields are not searched at all. app or api.
Previously a bug report had fixed it so that Directus treated "citext" as a "text" field instead of "unknown".
But it looks like the search mechanism doesn't include database citext fields. Even though Directus sees them as text.
To Reproduce
create a varchar, a text, a citext field in database with test data.
search on the values from any of those 3 fields using the search box in directus or the api
nothing in citext is searched
Errors Shown
no errors are shown anywhere
What version of Directus are you using?
9.12.1
What version of Node.js are you using?
12.22.9
What database are you using?
postgres 14
What browser are you using?
chrome
How are you deploying Directus?
CLI npm package
The text was updated successfully, but these errors were encountered: