Created
November 6, 2013 21:29
-
-
Save plajjan/7344419 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Simple dictSQL to match on one column using the equal operator. val1 contains name of column/attribute name of prefix to match while val2 contains the value it should match using the specified operator. | |
dictSQL = { | |
'val1': 'description', | |
'operator': 'equals', | |
'val2': 'bar' | |
} | |
Expands to: | |
description = 'bar' | |
Here we combine two conditions with a logical or, ie we are going to match a description of "bar" OR a comment of "foo". | |
dictSQL = { | |
'val1': { | |
'val1': 'description', | |
'operator': 'equals', | |
'val2': 'bar' | |
}, | |
'operator': 'or', | |
'val2': { | |
'val1': 'comment', | |
'operator': 'equals', | |
'val2': 'foo' | |
} | |
} | |
Expands to: | |
(description = 'bar') OR (comment = 'foo') | |
To combine more than two values, we need to add further nesting; | |
dictSQL = { | |
'val1': { | |
'val1': { | |
'val1': 'description', | |
'operator': 'equals', | |
'val2': 'bar' | |
}, | |
'operator': 'or', | |
'val2': { | |
'val1': 'comment', | |
'operator': 'equals', | |
'val2': 'foo' | |
} | |
}, | |
'operator': 'or', | |
'val2': { | |
'val1': 'prefix', | |
'operator': 'equals', | |
'val2': '1.3.0.0/24' | |
} | |
} | |
Expands to pseudo-SQL: | |
(description = 'bar') OR (comment = 'foo') OR (prefix = '1.3.0.0/24') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment