changeset cd849c829475 in sao:5.0
details: https://hg.tryton.org/sao?cmd=changeset;node=cd849c829475
description:
        Skip invalid branch of domain without the inverted field

        Those branches of the domain should not prevent to compute a proper 
inverted
        domain for the field as the other fields will be fixed later.

        issue9200
        review311191002
        (grafted from 505aa0836b25cfeaf8818862c2cff24817cfbfdc)
diffstat:

 src/common.js |  5 ++++-
 tests/sao.js  |  6 ++++--
 2 files changed, 8 insertions(+), 3 deletions(-)

diffs (45 lines):

diff -r 71ea04eb2994 -r cd849c829475 src/common.js
--- a/src/common.js     Fri Apr 10 18:32:55 2020 +0200
+++ b/src/common.js     Sun Apr 12 23:21:08 2020 +0200
@@ -2488,6 +2488,9 @@
                 if (part instanceof DomainInversion.And) {
                     var part_inversion = part.inverse(symbol, context);
                     var evaluated = typeof part_inversion == 'boolean';
+                    if (!~part.variables.indexOf(symbol)) {
+                        continue;
+                    }
                     if (!evaluated) {
                         result.push(part_inversion);
                     } else if (part_inversion) {
@@ -2539,7 +2542,7 @@
                 if (part instanceof DomainInversion.And) {
                     var part_inversion = part.inverse(symbol, context);
                     var evaluated = typeof part_inversion == 'boolean';
-                    if (!~this.variables.indexOf(symbol)) {
+                    if (!~part.variables.indexOf(symbol)) {
                         if (evaluated && part_inversion) {
                             return true;
                         }
diff -r 71ea04eb2994 -r cd849c829475 tests/sao.js
--- a/tests/sao.js      Fri Apr 10 18:32:55 2020 +0200
+++ b/tests/sao.js      Sun Apr 12 23:21:08 2020 +0200
@@ -2020,7 +2020,8 @@
             'domain_inversion(' + JSON.stringify(domain) + ', \'z\', ' +
                 JSON.stringify(context) + ')');
         context = {x: 5, y: 5};
-        QUnit.strictEqual(domain_inversion(domain, 'z', context), false,
+        QUnit.ok(compare(domain_inversion(domain, 'z', context),
+                [['z', '=', 3]]),
             'domain_inversion(' + JSON.stringify(domain) + ', \'z\', ' +
                 JSON.stringify(context) + ')');
         context = {x: 5, y: 7};
@@ -2045,7 +2046,8 @@
             'domain_inversion(' + JSON.stringify(domain) + ', \'z\', ' +
                 JSON.stringify(context) + ')');
         context = {y: 5};
-        QUnit.strictEqual(domain_inversion(domain, 'z', context), false,
+        QUnit.ok(compare(domain_inversion(domain, 'z', context),
+                [['z', '=', 3]]),
             'domain_inversion(' + JSON.stringify(domain) + ', \'z\', ' +
                 JSON.stringify(context) + ')');
         context = {x: 4, y: 7};

Reply via email to