leikind / wice_grid

A Rails grid plugin to create grids with sorting, pagination, and (automatically generated) filters
MIT License
537 stars 215 forks source link

Better case-insensitive matching support #229

Closed bart3r closed 8 years ago

bart3r commented 9 years ago

There really isn't good support for case-insensitive matching, especially for people not using Postgres. I've seen the config for STRING_MATCHING_OPERATOR, but we use an Oracle database and the ILIKE function isn't available, so there is no solution.

Could you not enhance the matching code to include the ability to do an UPPER (or LOWER) comparison on the string? This would be a big improvement and provide a solution for nearly any database.

leikind commented 9 years ago

That is, explicitly configure the plugin as regards case sensitivity? In your opinion what should be the default?

bart3r commented 9 years ago

I certainly believe that the default should be case-insensitive matching as this is much more popular, but there should be a config option to change it.

But by default it should use an UPPER compare, as this works on 99% of databases.

So, in /lib/wice/columns/column_string.rb line 82, change it to something like this:

[ " #{negation} UPPER(#{@column_wrapper.alias_or_table_name(table_alias)}.#{@column_wrapper.name}) #{::Wice.get_string_matching_operators(@column_wrapper.model)} ?", '%' + string_fragment.upcase + '%' ]

bart3r commented 9 years ago

Can you change this, or would you like a Pull Request?

nathanvda commented 9 years ago

I would not make this the default option, in my branch I added support for a separate option CI_LIKE which is translated to using a normal like and uppercase both sides. See: https://github.com/nathanvda/wice_grid/commit/182eb20bcf34d37b42ee67481bc052da75c72156

bart3r commented 8 years ago

Yuri,

Will you add support for this feature in your next release?

leikind commented 8 years ago

@bart3r I plan to merge @nathanvda 's changes

bart3r commented 8 years ago

This didn't seem to make the last release. When will you merge it in ?

leikind commented 8 years ago

Added in 3.6.0.pre4

https://github.com/leikind/wice_grid/wiki/What's-New-In-3.6.0