Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use of SQL operator "IN" #43

Closed
giessebi opened this issue Oct 13, 2014 · 11 comments
Closed

use of SQL operator "IN" #43

giessebi opened this issue Oct 13, 2014 · 11 comments

Comments

@giessebi
Copy link
Contributor

When you use IN it would be logical to specify more than one argument (comma separated).
The SQL parser gives out a wrong result, though: if you specify IN a,b, the resulting query fragment reads as IN('a,b') which would search for a single argument instead of two.
I realize you may want to allow users to look for commas (but they could escape commas, couldn't they?), however a useful IN option should output more than one argument as IN('a','b','c'...)

@mistic100
Copy link
Owner

I can't reproduce

are you using the last upstream ?

what are your filters ?

@mistic100
Copy link
Owner

I added a unit test in #3b0352f493

@graphite-kom
Copy link

Same problem here // also impossible to use IN operator with integers ...

@mistic100
Copy link
Owner

Are you willing to give details about your config or not ?
(Jsfiddle)

@graphite-kom
Copy link

This one shows how IN operator doesn't quote every item separately as mentionned above by giessebi:
http://jsfiddle.net/graphitekom/vqjmpyLx/

This one shows how IN operator doesn't allow a list of integers :
http://jsfiddle.net/graphitekom/ap9gxo4L/

@mistic100
Copy link
Owner

this is not an intended usage,
the IN operator is actually only for multiple select and checkbox (and plugins like Selectize)

you can use a simple text input with IN operator if you provide the valueParser callback to transform your string in an array

@mistic100
Copy link
Owner

I prefer to stick to this highly customizable way, rather than impose comma as separator (or even add a parameter for that)

@giessebi
Copy link
Contributor Author

Hi,
actually last release fixed it for me: it correctly separates arguments, with quoted strings and unquoted integers. So as far as I'm concerned I'll close the issue.
Thank you.

@heffer86
Copy link

I have the following Selectize and it doesn't quote string the individual values. Do I needed a custom valueGetter to get values like IN('1415','1516')

                id: 'fayr',
                label: 'FAYR',
                type: 'string',
                plugin: 'selectize',
                plugin_config: {
                    valueField: 'value',
                    labelField: 'name',
                    searchField: 'name',
                    options: [],
                    create: false,
                    maxItems: 3,
                    plugins: ['remove_button'],
                    load: function (query, callback) {
                        if (!query.length) return callback();
                        $.ajax({
                            url: '/api/ASC_SearchQuery',
                            type: 'GET',
                            dataType: 'json',
                            error: function () {
                                callback();
                            },
                            success: function (res) {
                                callback(res);
                            }
                        });
                    }
                },
                valueSetter: function (rule, value) {
                    console.log(rule);
                    rule.$el.find('.rule-value-container input')[0].selectize.setValue(value);
                }

@mistic100
Copy link
Owner

yes you need to customize the valueSetter, and also the valueParser

@mistic100
Copy link
Owner

Version 2.4.0 added value_separator option.

$('#builder').queryBuilder({
  filters: [
    {
      id: 'name',
      type: 'string',
      value_separator: ','
    }
  ]
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants