-- 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 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\d{4})-(?P\d{2})-(?P\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; -- Test case for https://github.com/CeresDB/sqlness/issues/68 INSERT INTO timestamp VALUES ('1900-1-1 00;00;00'); INSERT INTO timestamp VALUES ('1900-1-1 00;00;00');