Created
May 22, 2012 18:10
-
-
Save dstnbrkr/2770652 to your computer and use it in GitHub Desktop.
predicate templates
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
// the query: | |
// foo amount:15 | |
// first becomes an array of predicate templates | |
[ "${column} like '%foo%'", "${column} >= 14 and ${column} <= 16" ] | |
// next, we inspect the model to find which columns to search on | |
// and repeat each query for each property | |
[ [ "description like '%foo%'", "memo like '%foo%'" ], [ "amount >= 14 and amount <= 16" ] ] | |
// the subarrays get OR'd | |
[ "description like '%foo%' OR memo like '%foo%'", "amount >= 14 and amount <= 16" ] | |
// then the entire array gets AND'd | |
"(description like '%foo%' OR memo like '%foo%') AND (amount >= 14 and amount <= 16)" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment