You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We found and solved two issues when using the setRulesFromSQL functionality:
When a "NOT" group contains a single statament, the "NOT" is lost after calling setRulesFromSQL
When a "NOT" group uses the same operator as the external group it is simplified and the "NOT" is lost again.
To replicate these issues we suggest to go to the demo page http://querybuilder.js.org/demo.html and executing this javascript in the inspector console: var sql_import_export = 'name LIKE "%Johnny%" AND ( NOT (category = 2))'; $('#builder-import_export').queryBuilder('setRulesFromSQL', sql_import_export);
The above was the first issue. The second is: var sql_import_export = 'name LIKE "%Johnny%" AND ( NOT (category = 2 AND category != 4))'; $('#builder-import_export').queryBuilder('setRulesFromSQL', sql_import_export);
The problem is in the getRulesFromSQL function, in its recursive "flatten" function.
The first problem is solved by adding those lines about at line 5960 where there is the "it's a leaf" comment:
// it's a leaf
else {
// FIX START
if (data.not==true) {
var group = self.change('sqlToGroup', {
condition: self.settings.default_condition,
rules: []
}, data);
curr.rules.push(group);
curr = group;
i++;
data.not=false;
flatten(data, i);
return;
}
// FIX END
if ($.isPlainObject(data.right.value)) {
Utils.error('SQLParse', 'Value format not supported for {0}.', data.left.value);
}
The second one is solved by adding the statement ( || data.not==true) at around line 5930:
// it's a node if (['AND', 'OR'].indexOf(data.operation.toUpperCase()) !== -1) { // create a sub-group if the condition is not the same and it's not the first level if (i > 0 && (curr.condition != data.operation.toUpperCase() || data.not==true)) {
Best regards
The text was updated successfully, but these errors were encountered:
There seems to be another issue when using the setRulesFromSQL with the not-group plugin. For example, $('#queryBuilderGoesHere').queryBuilder('setRulesFromSQL', 'NOT (price>100)'); would change the query to NOT ( ( NOT ( price > 100 ) ) ).
We found and solved two issues when using the setRulesFromSQL functionality:
To replicate these issues we suggest to go to the demo page http://querybuilder.js.org/demo.html and executing this javascript in the inspector console:
var sql_import_export = 'name LIKE "%Johnny%" AND ( NOT (category = 2))'; $('#builder-import_export').queryBuilder('setRulesFromSQL', sql_import_export);
The above was the first issue. The second is:
var sql_import_export = 'name LIKE "%Johnny%" AND ( NOT (category = 2 AND category != 4))'; $('#builder-import_export').queryBuilder('setRulesFromSQL', sql_import_export);
The problem is in the getRulesFromSQL function, in its recursive "flatten" function.
The first problem is solved by adding those lines about at line 5960 where there is the "it's a leaf" comment:
The second one is solved by adding the statement (
|| data.not==true
) at around line 5930:// it's a node if (['AND', 'OR'].indexOf(data.operation.toUpperCase()) !== -1) { // create a sub-group if the condition is not the same and it's not the first level if (i > 0 && (curr.condition != data.operation.toUpperCase() || data.not==true)) {
Best regards
The text was updated successfully, but these errors were encountered: