rules icon indicating copy to clipboard operation
rules copied to clipboard

anyItem breaks with empty lists

Open charlesjankowski opened this issue 4 years ago • 2 comments

anyItem seems to break with empty lists.

Sample:

with ruleset('test'):

    # Static rules                                                                                                                                                                     
    @when_all(m.features.feature1.anyItem(item == 'a'))
    def feature1(c):
        print('feature1')
        c.assert_fact({'rule': 'feature1'})

    @when_all(m.features.feature2 == 'c')
    def feature2(c):
        print('feature2')
        c.assert_fact({'rule': 'feature2'})

    @when_any(m.rule == 'feature1', m.rule == 'feature2')
    def conditionA(c):
        print('conditionA')
        c.assert_fact({'rule': 'conditionA'})

assert_fact('test', {'features': {'feature1': ['a','b'],'feature2': 'c'}})

This is fine; all rules fire. If however, we have 'feature1':[], no rules are fired (feature2 and then conditionA should have). If I make 'feature1':['dummy'], it fires feature2 and conditionA as expected.

charlesjankowski avatar Mar 31 '20 08:03 charlesjankowski

Hi, thanks for reporting this issue. I have published a fix for it. Please use version 2.0.25.

jruizgit avatar Apr 05 '20 19:04 jruizgit

Jesus,

Thanks for the fix and the great work!

Charles

Charles Jankowski

[email protected] 510 414 6892

On Apr 5, 2020, at 12:47 PM, Jesus Ruiz [email protected] wrote:

Hi, thanks for reporting this issue. I have published a fix for it. Please use version 2.0.25.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jruizgit/rules/issues/325#issuecomment-609471891, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABJSCZY63ZMKKXK6FIUQQOLRLDN43ANCNFSM4LXLREHA.

charlesjankowski avatar Apr 05 '20 20:04 charlesjankowski