Closed VanHiro closed 2 years ago
You must tell the builder that you are working with a multi value input.
Two solutions :
input: 'select', multiple: true,
(will disallow to use "equal" operator with multiple values)value_separator: ',', multiple: true,
(will allow "equal" by concatenating the values)That does get me closer to where I want to go indeed, thank you. I will implement my code with those options and see which one better fits my needs.
I was approaching the issue from a different perspective and was hoping I could interdict the user from even trying to select multiple inputs for the equal operator but I see that the issue has been handled differently and it works.
The Issue
I am allowing the user to use the IN/NOT IN operator with the filters that have a selectize input. The issue is that even though the user selects multiple items the query-builder's GetSQL method treats the value as a single string. The retrieved string sql will contain IN('A,B,C'). But, if I execute the query in the DB with that value I will obtain a very different result than if I would with the expected outcome IN('A','B','C').
The code
Link to the jsFiddle example: http://jsfiddle.net/vanhiro/Lt2h7zse/1/
I linked an example of the situation but it is a mere visual representation since the issue is actually in the query-builder.standalone file.
---> This is how the input is handled normally from the query-builder
Code at line 5931 of query-builder.standalone.js This code will return IN('A,B,C').
rule.value.forEach(function(v, i) {
---> This is the solution that allows me to receive an array of strings inside the IN(...) stored in the SQL variable is:
This code will return IN('A','B','C')
My point
Has anyone encountered this issue already and if so, how did they fix it without changing the query-builder file?