3c7/yaramanager

Filter rules by tags - exclusion

Closed this issue · 4 comments

Hello @3c7 - I wanted to apply some extra filtering conditions using a SQLAlchemy query, but didn't succeeded yet. Here is a question where i described most of the issue, and I was wondering if you may have a better idea maybe? Much appreciated. Thanks

3c7 commented

To be honest, I have thought about that, too, and didn't come up with a solution, because I had the same issue. Will think about that!

3c7 commented

Haven't found a quick solution. Iterating over the tags after retrieving the rules from the DB is possible, but seems not to be very elegant. But it works...

What about this one?

rules = rules.select_from(Tag).join(Rule.tags).filter(~Rule.id.in_(
            rules.select_from(Tag).join(Rule.tags).filter(Tag.name.in_(tags)).with_entities(Rule.id)
))

Is not that elegant, but is sql(ish)

3c7 commented

Thanks, good idea!