From bc0e1009a23b20cb991acab66677659054e6cd66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sat, 17 May 2014 18:31:20 +0200 Subject: [PATCH] Fix eval_leaf when field equals 0 Only null must be considered as a value not set which will be forced by the domain inversion. issue3896 review8321003 --- src/common.js | 4 +++- tests/sao.js | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/common.js b/src/common.js index 68dba8eafc..d85f8a8f0e 100644 --- a/src/common.js +++ b/src/common.js @@ -1347,7 +1347,9 @@ // value in the evaluation context is deemed suffisant return Boolean(context[field.split('.')[0]]); } - if ((operand == '=') && !context[field] && (boolop === this.and)) { + if ((operand == '=') && + (context[field] === null || context[field] === undefined) && + (boolop === this.and)) { // We should consider that other domain inversion will set a // correct value to this field return true; diff --git a/tests/sao.js b/tests/sao.js index b9055a2cdd..65b61743ce 100644 --- a/tests/sao.js +++ b/tests/sao.js @@ -1451,7 +1451,7 @@ QUnit.strictEqual(domain_inversion(domain, 'z', context), true, 'domain_inversion(' + JSON.stringify(domain) + ', \'z\', ' + JSON.stringify(context) + ')'); - context = {y: false}; + context = {y: null}; QUnit.ok(compare(domain_inversion(domain, 'x', context), [['x', '=', 3]]), 'domain_inversion(' + JSON.stringify(domain) + ', \'x\', ' + @@ -1507,7 +1507,7 @@ JSON.stringify(context) + ')'); domain = ['OR', ['x', '=', 3], ['y', '=', 5]]; - context = {y: false}; + context = {y: null}; QUnit.ok(compare(domain_inversion(domain, 'x', context), [['x', '=', 3]]), 'domain_inversion(' + JSON.stringify(domain) + ', \'x\', ' + @@ -1801,6 +1801,10 @@ [['OR', ['x', '>', 10], ['x', '<', 0]], {'x': 11}, true], [['OR', ['x', '>', 10], ['x', '<', 0]], {'x': -4}, true], [['OR', ['x', '>', 10], ['x', '<', 0]], {'x': 5}, false], + [['OR', ['x', '>', 0], ['x', '=', null]], {'x': 1}, true], + [['OR', ['x', '>', 0], ['x', '=', null]], {'x': null}, true], + [['OR', ['x', '>', 0], ['x', '=', null]], {'x': -1}, false], + [['OR', ['x', '>', 0], ['x', '=', null]], {'x': 0}, false], [[['x', '>', 0], ['OR', ['x', '=', 3], ['x', '=', 2]]], {'x': 1}, false], [[['x', '>', 0], ['OR', ['x', '=', 3], ['x', '=', 2]]],