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

Support for ALL/DISTINCT/ORDER BY in aggregate functions #12

Merged
merged 4 commits into from
Oct 2, 2023

Conversation

ppputtyo
Copy link
Contributor

@ppputtyo ppputtyo commented Sep 29, 2023

ALL/DISTINCT/ORDER BY in aggregate functions are supported.
Grammar is based on here.

An example format is as follows

ALL

SELECT
	COUNT(
		ALL
			TBL.COL1
	)
;

DISTINCT

SELECT
	COUNT(
		DISTINCT
			TBL.COL1
	)
;

ORDER_BY

SELECT
	STRING_AGG(
		DISTINCT
			TBL.COLUMN1
		,	','
		ORDER BY
			TBL.COLUMN2
		,	TBL.COLUMN3
	)
;

Close #10
Close #11

@tanzaku
Copy link
Collaborator

tanzaku commented Oct 2, 2023

今回の修正で以下の警告が発生するようになっているようです。

warning: method `force_multi_line` is never used
  --> crates\uroborosql-fmt\src\cst\expr\column_list.rs:34:19
   |
21 | impl ColumnList {
   | --------------- method in this implementation
...
34 |     pub(crate) fn force_multi_line(&self) -> bool {
   |                   ^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(dead_code)]` on by default

今後使用する可能性があるforce_multi_lineメソッドを今消す必要はないと思うので、警告を回避するため以下のアトリビュートを付与してください。

    #[allow(dead_code)]
    pub(crate) fn force_multi_line(&self) -> bool {
        self.force_multi_line
    }

@ppputtyo
Copy link
Contributor Author

ppputtyo commented Oct 2, 2023

@tanzaku

trim_bind_paramの未使用警告が出ているので削除お願いします

今回の修正で以下の警告が発生するようになっているようです。

warning: method `force_multi_line` is never used
  --> crates\uroborosql-fmt\src\cst\expr\column_list.rs:34:19
   |
21 | impl ColumnList {
   | --------------- method in this implementation
...
34 |     pub(crate) fn force_multi_line(&self) -> bool {
   |                   ^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(dead_code)]` on by default

cargo clippyの実行を忘れていました。:bow:
trim_bind_paramの削除、#[allow(dead_code)]アトリビュートの追加を行いました。

719f679

@tanzaku
Copy link
Collaborator

tanzaku commented Oct 2, 2023

追加の修正で以下警告が出るようになっていたので、そちらの対応(use itertools::Itertools の削除)もお願いします 🙇

warning: unused import: `Itertools`
 --> crates\uroborosql-fmt\src\cst\body\insert.rs:1:27
  |
1 | use itertools::{repeat_n, Itertools};
  |                           ^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

@ppputtyo
Copy link
Contributor Author

ppputtyo commented Oct 2, 2023

追加の修正で以下警告が出るようになっていたので、そちらの対応(use itertools::Itertools の削除)もお願いします 🙇

warning: unused import: `Itertools`
 --> crates\uroborosql-fmt\src\cst\body\insert.rs:1:27
  |
1 | use itertools::{repeat_n, Itertools};
  |                           ^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

失礼しました:bow:
修正いたしました。
bc67483

@tanzaku
Copy link
Collaborator

tanzaku commented Oct 2, 2023

LGTM

@tanzaku tanzaku merged commit 43cd6ac into main Oct 2, 2023
7 checks passed
@tanzaku tanzaku deleted the dev_kawabuchi_support_aggregate_fn branch October 2, 2023 09:43
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.

Support string_agg(..., ... order by ...) Support COUNT(DISTINCT ...)
2 participants