Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support template interceptor #63

Merged
merged 3 commits into from
Mar 22, 2024
Merged

feat: support template interceptor #63

merged 3 commits into from
Mar 22, 2024

Conversation

jiacai2050
Copy link
Member

@jiacai2050 jiacai2050 commented Mar 16, 2024

Closes #51

@@ -19,3 +19,26 @@ SELECT 1;

03/14/2012, 01/01/2013 and 07/05/2014;

-- SQLNESS TEMPLATE {"name": "test"}
Copy link
Member Author

@jiacai2050 jiacai2050 Mar 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reuse this old example to add test, also I plan to combine interceptor demos into one since their logic are the same.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines +35 to +36
/// In order to generate multiple queries, you can use the builtin function
/// `sql_delimiter()` to insert a delimiter.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we need a special function to insert delimiter, but not write it in literal?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-- SQLNESS TEMPLATE {"aggr": ["sum", "avg", "count"]}
{% for item in aggr %}
SELECT {{item}}(c) from t {%if not loop.last %} {{sql_delimiter()}} {% endif %}
{% endfor %}
;

See this demo, ; is used to separate different SQL, so we can't write it directly in our template.

@waynexia waynexia requested a review from tisonkun March 19, 2024 03:40
@jiacai2050
Copy link
Member Author

@waynexia Any more problems?

I plan to merge this PR this week, and do some work to polish documentation, it's missing lots of new features.

@jiacai2050 jiacai2050 merged commit 3a661b2 into main Mar 22, 2024
2 checks passed
@jiacai2050 jiacai2050 deleted the feat-template branch March 22, 2024 08:51
@waynexia
Copy link
Member

@waynexia Any more problems?

I plan to merge this PR this week, and do some work to polish documentation, it's missing lots of new features.

Great 👍 I leave for a few days, it looks good to me

@tisonkun
Copy link

@jiacai2050 Let's release a 0.6.0 for this feature?

@jiacai2050
Copy link
Member Author

@jiacai2050
Copy link
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement TEMPLATE interceptor
3 participants