darrachequesne / spring-data-jpa-datatables

Spring Data JPA extension to work with the great jQuery plugin DataTables (https://datatables.net/)
Apache License 2.0
441 stars 174 forks source link

Simple use case Query trouble : WHERE LIKE instead of WHERE IN #109

Closed SylvainAssemat closed 1 year ago

SylvainAssemat commented 4 years ago

Hi all

I got a problem with a simple case

Javascript : table.column(0).search([2]).draw(); This should generate a 'WHERE IN' query according to the documentation.

But instead i got a WHERE LIKE

Maybe it s a normal behavior for an array with a single element.

So how to make "equals" query or where in (singleElement) ?

Thanks

SylvainAssemat commented 4 years ago

Answering to myself It's a normal behavior

In source code : ColumnFilter.class private boolean isBasicFilter() { return values.size() == 1 && !addNullCase && !isBooleanComparison; }

darrachequesne commented 4 years ago

As a work-around, you can search for -1+2, which will be converted to WHERE .. IN [-1, 2].

We could add a way to have an exact match instead of a LIKE, though I'm not sure how the API will look like.

darrachequesne commented 1 year ago

Added in the documentation here: https://github.com/darrachequesne/spring-data-jpa-datatables#search-for-a-specific-value-in-a-column