File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -97,13 +97,15 @@ QueryBuilder.extend({
9797 if ( options . silent_fail === undefined ) options . silent_fail = false ;
9898
9999 if ( node instanceof Group ) {
100+ // invert group condition
100101 if ( this . settings . conditionOpposites [ node . condition ] ) {
101102 node . condition = this . settings . conditionOpposites [ node . condition ] ;
102103 }
103104 else if ( ! options . silent_fail ) {
104105 error ( 'Unknown inverse of condition "{0}"' , node . condition ) ;
105106 }
106107
108+ // recursive call
107109 if ( options . recursive ) {
108110 node . each ( function ( rule ) {
109111 if ( options . invert_rules ) {
@@ -115,9 +117,14 @@ QueryBuilder.extend({
115117 }
116118 }
117119 else if ( node instanceof Rule ) {
118- if ( node . operator ) {
120+ if ( node . operator && ! node . filter . no_invert ) {
121+ // invert rule operator
119122 if ( this . settings . operatorOpposites [ node . operator . type ] ) {
120- node . operator = this . getOperatorByType ( this . settings . operatorOpposites [ node . operator . type ] ) ;
123+ var invert = this . settings . operatorOpposites [ node . operator . type ] ;
124+ // check if the invert is "authorized"
125+ if ( ! node . filter . operators || node . filter . operators . indexOf ( invert ) != - 1 ) {
126+ node . operator = this . getOperatorByType ( invert ) ;
127+ }
121128 }
122129 else if ( ! options . silent_fail ) {
123130 error ( 'Unknown inverse of operator "{0}"' , node . operator . type ) ;
You can’t perform that action at this time.
0 commit comments