question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for INTERSECT?

See original GitHub issue

Hi, is it possible to add support for intersect? eg:

 rule_engine.Rule('role INTERSECT {"R1", "R2"}').matches({"role": ["R1"]})

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
zeroSteinercommented, Mar 15, 2021

Alright this is done in the v3.1.0 release which is now on PyPi. You can use the new SET data type along with the bitwise and operator &. For example:

python -m rule_engine.debug_repl
rule > {"R1", "R2", "R3"} & {"R3", "R4"}
result: 
{'R3'}
rule > 'Testing'.to_set & {'a', 'e', 'i', 'o', 'u'}
result: 
{'e', 'i'}
rule > 

Both the ARRAY and STRING data types have a to_set attribute that will convert them as well.

2reactions
zeroSteinercommented, Mar 11, 2021

I’ve started the work for a SET data type which would support the bitwise operators and, or and xor (&, |, and ^ respectively). Usage of the bitwise and operator will have the desired effect of checking for the intersection of two SETs just like it does in Python. There will be accompanying attributes for converting arrays and strings into sets. This will be in the 3.1 release (probably) in the next couple of weeks. A preview is available in the feat/v3.1 branch.

I’d still like to have array comprehension support, but that can come later. These two features don’t seem like they need to be mutually exclusive and a SET data type will solve the problem at hand more directly.

Read more comments on GitHub >

github_iconTop Results From Across the Web

MySQL: INTERSECT Operator - TechOnTheNet
This MySQL tutorial explains how to use the INTERSECT operator with syntax and examples. Although there is no INTERSECT operator in MySQL, you...
Read more >
MySQL 8.0 Reference Manual :: 13.2.8 INTERSECT Clause
INTERSECT limits the result from multiple query blocks to those rows which ... For INTERSECT ALL , the maximum supported number of duplicates...
Read more >
Support - Intersect Systems
Two support program options are available for Intersect software users. These programs provide software updates, telephone support, continuing training, ...
Read more >
How to Emulate The MySQL INTERSECT Operator
Note that MySQL does not support the INTERSECT operator. This tutorial introduces you to how to emulate the INTERSECT operator in MySQL using...
Read more >
SQL Intersect: Your Complete Guide to Using The Operator
Wondering what is the SQL INTERSECT Operator, how do you use it, and what are the operator's uses? Learn all of it with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found