Okipa / laravel-table

Generate tables from Eloquent models.
MIT License
534 stars 64 forks source link

[Feature] Case insensitive search #1

Closed jamesst20 closed 5 years ago

jamesst20 commented 5 years ago

Hi,

Would it be possible to make the search case insensitive ?

Thank you

Okipa commented 5 years ago

Hi @jamesst20
I am wondering if applying case sensitive search queries wouldn't be penalizing for some use cases.
Could you explain me your use case in order to check how to implement this optionally ?

jamesst20 commented 5 years ago

There could be many use cases, such as typing a word, a name, a project name.

It's a little annoying to have to respect the word cases especially when they are not all the same

jamesst20 commented 5 years ago

"I am wondering if applying case sensitive search queries wouldn't be penalizing for some use cases."

By the way, i'm talking about case insensitive. It is already case sensitive

Okipa commented 5 years ago

@jamesst20
Sorry, I read too fast. According to my usages, it is already insensitive.
Could you fork the package and write a test to point the problem ?

Okipa commented 5 years ago

@jamesst20
I just added a test for this : https://github.com/Okipa/laravel-table/blob/689442a45e2c8cfa9b9cd223363ab6837c964b04/tests/Unit/SearchTest.php#L377
Everything goes fine.

I think your case sensitive problem could be related to your database version and configuration. Could you tell me which version do you use and which encoding ?

EDIT : with the default Laravel utf8_unicode_ci charset and collation, the used operator for the search (LIKE) is insensitive.

jamesst20 commented 5 years ago

@Okipa

Sorry for the slow response, here is what I found according to PostgresSQL documentation. (I am using Postgres, I should have mentioned it in the first place).

The key word ILIKE can be used instead of LIKE to make the match case-insensitive according to the active locale. This is not in the SQL standard but is a PostgreSQL extension. The operator ~~ is equivalent to LIKE , and ~~* corresponds to ILIKE .
Okipa commented 5 years ago

Thanks for your return, this should be fixed in https://github.com/Okipa/laravel-table/releases/tag/1.0.9.
Please reopen if you have an issue.