-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #72 from camptocamp/simplify_in
Better simplification of IN SQL clauses
- Loading branch information
Showing
3 changed files
with
29 additions
and
1 deletion.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from c2cwsgiutils.stats_pyramid import _simplify_sql as simplify_sql # pylint: disable=W0212 | ||
|
||
|
||
def test_simplify_sql(): | ||
|
||
assert simplify_sql("SELECT a FROM xxx WHERE b IN (1, 2, 3)") == \ | ||
"SELECT FROM xxx WHERE b IN (?)" | ||
|
||
assert simplify_sql("SELECT a FROM xxx WHERE b IN (1, 2, 3) AND c=2") == \ | ||
"SELECT FROM xxx WHERE b IN (?) AND c=2" | ||
|
||
assert simplify_sql("SELECT a FROM xxx WHERE b IN (1, 2, 3) AND c IN (d, e)") == \ | ||
"SELECT FROM xxx WHERE b IN (?) AND c IN (?)" | ||
|
||
assert simplify_sql("SELECT a FROM xxx WHERE b IN (1, 2) AND c IN ((d, 1), (e, 2))") == \ | ||
"SELECT FROM xxx WHERE b IN (?) AND c IN (?)" |