-
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.
* refactor example * Update PR template * update Makefile * fix CI
- Loading branch information
1 parent
3a661b2
commit 9157ab3
Showing
24 changed files
with
215 additions
and
494 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,7 @@ | ||
# Which issue does this PR close? | ||
## Rationale | ||
|
||
Closes # | ||
|
||
# Rationale for this change | ||
|
||
<!--- | ||
Why are you proposing this change? If this is already explained clearly in the issue, then this section is not needed. | ||
Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes. | ||
--> | ||
## Detailed Changes | ||
|
||
# What changes are included in this PR? | ||
|
||
<!--- | ||
There is no need to duplicate the description in the issue here, but it is sometimes worth providing a summary of the individual changes in this PR to help reviewers understand the structure. | ||
--> | ||
|
||
# Are there any user-facing changes? | ||
|
||
<!--- | ||
Please mention if: | ||
- there are user-facing changes that need to update the documentation or configuration. | ||
- this is a breaking change to public APIs | ||
--> | ||
|
||
# How does this change test | ||
|
||
<!-- | ||
Please describe how you test this change (like by unit test case, integration test or some other ways) if this change has touched the code. | ||
--> | ||
## Test Plan |
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,2 +1,4 @@ | ||
target | ||
Cargo.lock | ||
.DS_Store | ||
.project |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,121 @@ | ||
-- SQLNESS ARG bla=a addr=127.0.0.1 port=3306 | ||
SELECT * FROM t; | ||
|
||
Args: addr=127.0.0.1, bla=a, port=3306 | ||
|
||
SELECT * FROM t; | ||
|
||
-- SQLNESS 🤪ARG🤪 addr=127.0.0.1 port=3306 | ||
-- SQLNESS ARG port=3307 | ||
SELECT * | ||
FROM t | ||
WHERE A=B; | ||
|
||
Args: port=3307 | ||
|
||
SELECT * | ||
FROM t | ||
WHERE A=B; | ||
|
||
-- multiple env in one line | ||
-- SQLNESS ENV ENV1 ENV2 NONEXISTENT1 NONEXISTENT2 NONEXISTENT3 | ||
SELECT $ENV1, $ENV2, $NONEXISTENT1 FROM t; | ||
|
||
SELECT value1, value2, $NONEXISTENT1 FROM t; | ||
|
||
-- multiple env in multiple lines | ||
-- SQLNESS ENV ENV1 | ||
-- SQLNESS ENV ENV2 | ||
-- SQLNESS ENV NONEXISTENT1 | ||
-- SQLNESS ENV NONEXISTENT2 | ||
-- SQLNESS ENV NONEXISTENT3 | ||
SELECT $ENV1, $ENV2, $NONEXISTENT1, FROM t; | ||
|
||
SELECT value1, value2, $NONEXISTENT1, FROM t; | ||
|
||
-- Undeclared env won't be rendered | ||
-- SQLNESS ENV ENV2 | ||
SELECT $ENV1, $ENV2, $NONEXISTENT1 FROM t; | ||
|
||
SELECT $ENV1, value2, $NONEXISTENT1 FROM t; | ||
|
||
-- SQLNESS REPLACE 00 | ||
SELECT 0; | ||
|
||
SELECT 0; | ||
|
||
-- SQLNESS REPLACE 00 | ||
SELECT 00; | ||
|
||
SELECT ; | ||
|
||
-- SQLNESS REPLACE 0 1 | ||
SELECT 0; | ||
|
||
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; | ||
|
||
-- SQLNESS TEMPLATE {"name": "test"} | ||
SELECT * FROM table where name = "{{name}}"; | ||
|
||
SELECT * FROM table where name = "test"; | ||
|
||
-- SQLNESS TEMPLATE {"aggr": ["sum", "avg", "count"]} | ||
{% for item in aggr %} | ||
SELECT {{item}}(c) from t {%if not loop.last %} {{sql_delimiter()}} {% endif %} | ||
{% endfor %} | ||
; | ||
|
||
SELECT sum(c) from t ; | ||
|
||
SELECT avg(c) from t ; | ||
|
||
SELECT count(c) from t ; | ||
|
||
-- SQLNESS TEMPLATE | ||
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) ; | ||
|
||
-- SQLNESS SORT_RESULT | ||
4 | ||
3 | ||
6 | ||
1; | ||
|
||
1; | ||
3 | ||
4 | ||
6 | ||
|
||
-- SQLNESS SORT_RESULT 1 1 | ||
7 | ||
1 | ||
4 | ||
2 | ||
2; | ||
|
||
7 | ||
1 | ||
2 | ||
4 | ||
2; | ||
|
||
-- SQLNESS SORT_RESULT -1 | ||
6 | ||
2 | ||
4; | ||
|
||
6 | ||
2 | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
-- SQLNESS ARG bla=a addr=127.0.0.1 port=3306 | ||
SELECT * FROM t; | ||
|
||
-- SQLNESS 🤪ARG🤪 addr=127.0.0.1 port=3306 | ||
-- SQLNESS ARG port=3307 | ||
SELECT * | ||
FROM t | ||
WHERE A=B; | ||
|
||
-- multiple env in one line | ||
-- SQLNESS ENV ENV1 ENV2 NONEXISTENT1 NONEXISTENT2 NONEXISTENT3 | ||
SELECT $ENV1, $ENV2, $NONEXISTENT1 FROM t; | ||
|
||
-- multiple env in multiple lines | ||
-- SQLNESS ENV ENV1 | ||
-- SQLNESS ENV ENV2 | ||
-- SQLNESS ENV NONEXISTENT1 | ||
-- SQLNESS ENV NONEXISTENT2 | ||
-- SQLNESS ENV NONEXISTENT3 | ||
SELECT $ENV1, $ENV2, $NONEXISTENT1, FROM t; | ||
|
||
-- Undeclared env won't be rendered | ||
-- SQLNESS ENV ENV2 | ||
SELECT $ENV1, $ENV2, $NONEXISTENT1 FROM t; | ||
|
||
-- SQLNESS REPLACE 00 | ||
SELECT 0; | ||
|
||
-- SQLNESS REPLACE 00 | ||
SELECT 00; | ||
|
||
-- SQLNESS REPLACE 0 1 | ||
SELECT 0; | ||
|
||
-- 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; | ||
|
||
-- SQLNESS TEMPLATE {"name": "test"} | ||
SELECT * FROM table where name = "{{name}}"; | ||
|
||
-- SQLNESS TEMPLATE {"aggr": ["sum", "avg", "count"]} | ||
{% for item in aggr %} | ||
SELECT {{item}}(c) from t {%if not loop.last %} {{sql_delimiter()}} {% endif %} | ||
{% endfor %} | ||
; | ||
|
||
-- SQLNESS TEMPLATE | ||
INSERT INTO t (c) VALUES | ||
{% for num in range(1, 5) %} | ||
({{ num }}) {%if not loop.last %} , {% endif %} | ||
{% endfor %} | ||
; | ||
|
||
-- SQLNESS SORT_RESULT | ||
4 | ||
3 | ||
6 | ||
1; | ||
|
||
-- SQLNESS SORT_RESULT 1 1 | ||
7 | ||
1 | ||
4 | ||
2 | ||
2; | ||
|
||
-- SQLNESS SORT_RESULT -1 | ||
6 | ||
2 | ||
4; |
Oops, something went wrong.