-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b6ef46d
commit 81ca4fd
Showing
2 changed files
with
27 additions
and
21 deletions.
There are no files selected for viewing
35 changes: 19 additions & 16 deletions
35
sqlness/examples/interceptor-replace/simple/replace.result
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 |
---|---|---|
@@ -1,44 +1,47 @@ | ||
-- SQLNESS REPLACE 00 | ||
SELECT 0; | ||
|
||
SELECT 0; | ||
SELECT 0 | ||
|
||
-- SQLNESS REPLACE 00 | ||
SELECT 00; | ||
|
||
SELECT ; | ||
SELECT | ||
|
||
-- SQLNESS REPLACE 0 1 | ||
SELECT 0; | ||
|
||
SELECT 1; | ||
SELECT 1 | ||
|
||
-- example of capture group replacement | ||
-- SQLNESS REPLACE (?P<y>\d{4})-(?P<m>\d{2})-(?P<d>\d{2}) $m/$d/$y | ||
2012-03-14, 2013-01-01 and 2014-07-05; | ||
|
||
03/14/2012, 01/01/2013 and 07/05/2014; | ||
03/14/2012, 01/01/2013 and 07/05/2014 | ||
|
||
-- SQLNESS TEMPLATE {"name": "test"} | ||
SELECT * FROM table where name = "test"; | ||
SELECT * FROM table where name = "{{name}}"; | ||
|
||
SELECT * FROM table where name = "test"; | ||
SELECT * FROM table where name = "test" | ||
|
||
-- SQLNESS TEMPLATE {"aggr": ["sum", "avg", "count"]} | ||
SELECT sum(c) from t ; | ||
|
||
SELECT sum(c) from t ; | ||
|
||
SELECT avg(c) from t ; | ||
{% for item in aggr %} | ||
SELECT {{item}}(c) from t {%if not loop.last %} {{sql_delimiter()}} {% endif %} | ||
{% endfor %} | ||
; | ||
|
||
SELECT avg(c) from t ; | ||
SELECT sum(c) from t | ||
|
||
SELECT count(c) from t ; | ||
SELECT avg(c) from t | ||
|
||
SELECT count(c) from t ; | ||
SELECT count(c) from t | ||
|
||
-- SQLNESS TEMPLATE | ||
INSERT INTO t (c) VALUES(1) , (2) , (3) , (4) ; | ||
INSERT INTO t (c) VALUES | ||
{% for num in range(1, 5) %} | ||
({{ num }}) {%if not loop.last %} , {% endif %} | ||
{% endfor %} | ||
; | ||
|
||
INSERT INTO t (c) VALUES(1) , (2) , (3) , (4) ; | ||
INSERT INTO t (c) VALUES(1) , (2) , (3) , (4) | ||
|
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