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

Negation doubled when using setRulesFromSQL #687

Closed
ben-luck opened this issue Apr 28, 2018 · 4 comments
Closed

Negation doubled when using setRulesFromSQL #687

ben-luck opened this issue Apr 28, 2018 · 4 comments
Labels
bug Identified bug which needs a fix
Milestone

Comments

@ben-luck
Copy link

ben-luck commented Apr 28, 2018

There seems to be an issue when using the setRulesFromSQL with the not-group plugin. I tried it on this jsfiddle - https://jsfiddle.net/k2f46297/

For example,

$('#queryBuilderGoesHere').queryBuilder('setRulesFromSQL', 'NOT (price>100)');

would change the query to NOT ( ( NOT ( price > 100 ) ) )

image

Here is the script -

var myFilters = [{
    id: 'price',
    label: 'price',
    type: 'double'
}, {
    id: 'name',
    label: 'Name',
    type: 'string'
}, {
    id: 'email',
    label: 'email',
    type: 'string'
}];
$("#queryBuilderGoesHere").queryBuilder({
    plugins: ['not-group'],
    filters: myFilters
});

$('#queryBuilderGoesHere').queryBuilder('setRulesFromSQL', 'NOT (price>100)');
$("#getsql").on('click', function () {
    var sqlob = $("#queryBuilderGoesHere").queryBuilder("getSQL", false);
    $("#sql").text(sqlob.sql);
});

Thanks!

@ben-luck
Copy link
Author

ben-luck commented Apr 28, 2018

By the way, I am using query-builder.standalone.min.js. This is my workaround for now, not ideal but seems to workaround it -

var rule = $('#queryBuilderGoesHere').queryBuilder('getRulesFromSQL','NOT (price>100)');
if (rule != null) {
	rule.not=false;	
	$('#queryBuilderGoesHere').queryBuilder('setRules', rule);
}

@mistic100
Copy link
Owner

<code> is not how you put code in Github, you must use single or triple back quote https://guides.github.com/features/mastering-markdown/#GitHub-flavored-markdown


I'll work on this.

@mistic100 mistic100 added the bug Identified bug which needs a fix label Apr 28, 2018
@mistic100 mistic100 added this to the 2.5.2 milestone Apr 28, 2018
@ben-luck
Copy link
Author

Thank you!

@ben-luck
Copy link
Author

ben-luck commented May 1, 2018

Great! @mistic100 , couple questions -

  1. Do you have a release date for 2.5.2?
  2. Will it be hard to convert the NOT checkbox button to a regular btn to be consistent with the AND and OR buttons?

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Identified bug which needs a fix
Projects
None yet
Development

No branches or pull requests

2 participants