spring-data-jpa-datatables icon indicating copy to clipboard operation
spring-data-jpa-datatables copied to clipboard

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

Open SylvainAssemat opened this issue 5 years ago • 2 comments

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 avatar Nov 25 '19 10:11 SylvainAssemat

Answering to myself It's a normal behavior

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

SylvainAssemat avatar Nov 25 '19 12:11 SylvainAssemat

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 avatar May 26 '20 05:05 darrachequesne

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

darrachequesne avatar Feb 13 '23 11:02 darrachequesne