changeset 32582c78dc4c in sao:5.2
details: https://hg.tryton.org/sao?cmd=changeset;node=32582c78dc4c
description:
        Do not force value in OR-ed clause

        When any other variable in Or-ed clause is not known, we can not force 
the
        value of the variable.

        issue9092
        review272941002
        (grafted from 0bccb444c4f74bf79ded7764193817228aa20448)
diffstat:

 src/common.js |   7 +++----
 tests/sao.js  |  17 ++++++-----------
 2 files changed, 9 insertions(+), 15 deletions(-)

diffs (70 lines):

diff -r 7b2766053c67 -r 32582c78dc4c src/common.js
--- a/src/common.js     Mon Mar 09 18:33:02 2020 +0100
+++ b/src/common.js     Fri Mar 06 23:14:24 2020 +0100
@@ -2535,11 +2535,10 @@
         inverse: function(symbol, context) {
             var DomainInversion = Sao.common.DomainInversion;
             var result = [];
-            if (!~this.variables.indexOf(symbol) &&
-                !jQuery.isEmptyObject(this.variables.filter(function(e) {
-                    return !(e in context);
+            if (!jQuery.isEmptyObject(this.variables.filter(function(e) {
+                    return (!(e in context)) && (e != symbol);
                 }))) {
-                // In this case we don't know anything about this OR part, we
+                // In this case we don't know enough about this OR part, we
                 // consider it to be True (because people will have the
                 // constraint on this part later).
                 return true;
diff -r 7b2766053c67 -r 32582c78dc4c tests/sao.js
--- a/tests/sao.js      Mon Mar 09 18:33:02 2020 +0100
+++ b/tests/sao.js      Fri Mar 06 23:14:24 2020 +0100
@@ -1917,11 +1917,10 @@
 
         var domain = ['OR', ['x', '=', 3], ['y', '>', 5], ['z', '=', 'abc']];
         var context;
-        QUnit.ok(compare(domain_inversion(domain, 'x'), [['x', '=', 3]]),
+        QUnit.ok(compare(domain_inversion(domain, 'x'), true),
             'domain_inversion(' + JSON.stringify(domain) + ', \'x\')');
         context = {y: 4};
-        QUnit.ok(compare(domain_inversion(domain, 'x', context),
-                [['x', '=', 3]]),
+        QUnit.ok(compare(domain_inversion(domain, 'x', context), true),
             'domain_inversion(' + JSON.stringify(domain) + ', \'x\', ' +
                 JSON.stringify(context) + ')');
         context = {y: 4, z: 'ab'};
@@ -1958,12 +1957,10 @@
             'domain_inversion(' + JSON.stringify(domain) + ', \'z\')');
 
         domain = ['OR', ['x.id', '>', 5], ['y', '<', 3]];
-        QUnit.ok(compare(domain_inversion(domain, 'y'),
-                [['y', '<', 3]]),
+        QUnit.ok(compare(domain_inversion(domain, 'y'), true),
             'domain_inversion(' + JSON.stringify(domain) + ', \'y\',)');
         context = {z: 4};
-        QUnit.ok(compare(domain_inversion(domain, 'y', context),
-                [['y', '<', 3]]),
+        QUnit.ok(compare(domain_inversion(domain, 'y', context), true),
             'domain_inversion(' + JSON.stringify(domain) + ', \'y\', ' +
                 JSON.stringify(context) + ')');
         context = {x: 3};
@@ -1973,8 +1970,7 @@
 
         domain = ['OR', ['length', '>', 5], ['language.code', '=', 'de_DE']];
         context = {length: 0, name: 'n'};
-        QUnit.ok(compare(domain_inversion(domain, 'length', context),
-                [['length', '>', 5]]),
+        QUnit.ok(compare(domain_inversion(domain, 'length', context), true),
             'domain_inversion(' + JSON.stringify(domain) + ', \'length\', ' +
                 JSON.stringify(context) + ')');
     });
@@ -1991,8 +1987,7 @@
         QUnit.strictEqual(domain_inversion(domain, 'x'), true,
             'domain_inversion(' + JSON.stringify(domain) + ', \'x\')');
         context = {y: 4};
-        QUnit.ok(compare(domain_inversion(domain, 'x', context),
-                [[['x', '=', 4]]]),
+        QUnit.ok(compare(domain_inversion(domain, 'x', context), true),
             'domain_inversion(' + JSON.stringify(domain) + ', \'x\', ' +
                 JSON.stringify(context) + ')');
         context = {z: 'abc', y: 7};

Reply via email to