Closed juannorris closed 3 weeks ago
@juannorris as far as i can tell this makes sense. im just wondering of there is also a way to elimitate rules from the processing queue based on missing facts. Sort of like a rete engine in the matching phase. But i think its fine like this for now and we can revisit it.
allowUndefinedFacts - By default, when a running engine encounters an undefined fact, an exception is thrown. Turning this option on will cause the engine to treat undefined facts as undefined. (default: false)
@juannorris as far as i can tell this makes sense. im just wondering of there is also a way to elimitate rules from the processing queue based on missing facts. Sort of like a rete engine in the matching phase. But i think its fine like this for now and we can revisit it.
allowUndefinedFacts - By default, when a running engine encounters an undefined fact, an exception is thrown. Turning this option on will cause the engine to treat undefined facts as undefined. (default: false)
Thanks @nimbit-software!
I might be misinterpreting this, but with allowUndefinedFacts
set, I don't think we should eliminate rules based on missing facts, because this is the way consumers can effectively check against missing or null values inside more complex rules.
Before this change, the test named should succeed when undefined facts are allowed
would fail for all these cases:
{ some: { } }
{ some: { undefinedFact: undefined } }
{ some: { undefinedFact: null } }
Hi @juannorris good point. Maybe an additional prop for turning that on. We want to use it for an iot system. So a lot of the time data will be missing for the rules which means the rule should not be considered.
Maybe it makes sense to add some options for rules. Then we can skip rules where all facts are needed (which i assume will be most of them). That way its a lot more flexible
Description of the issue
When
allowUndefinedFacts
istrue
, left-hand side values are treated asnil
instead ofValueNode
ofType: Null
, which causes the evaluation of a condition to be skipped.Perhaps this is the desired behavior, but I would expect the following code snippet to work and it currently does not:
[client_log] Result: testEvent doNotSendEmail
[client_log] No events