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
This commit is contained in:
C?dric Krier 2014-05-17 18:31:20 +02:00
parent 62ecbeba3f
commit b20128a747
2 changed files with 9 additions and 3 deletions

View file

@ -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;

View file

@ -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]]],