spring-data-jpa-datatables
spring-data-jpa-datatables copied to clipboard
Simple use case Query trouble : WHERE LIKE instead of WHERE IN
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
Answering to myself It's a normal behavior
In source code : ColumnFilter.class private boolean isBasicFilter() { return values.size() == 1 && !addNullCase && !isBooleanComparison; }
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.
Added in the documentation here: https://github.com/darrachequesne/spring-data-jpa-datatables#search-for-a-specific-value-in-a-column