Skip to content

Commit b65c867

Browse files
gzsomborms705
authored andcommitted
FunctionArguments -> FunctionArgument rename
1 parent bf2ad32 commit b65c867

File tree

5 files changed

+32
-32
lines changed

5 files changed

+32
-32
lines changed

src/arithmetic.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ mod tests {
256256
ArithmeticBase::{Column as ABColumn, Scalar},
257257
ArithmeticOperator::*,
258258
};
259-
use crate::column::{FunctionArguments, FunctionExpression};
259+
use crate::column::{FunctionArgument, FunctionExpression};
260260

261261
let lit_ae = [
262262
"5 + 42",
@@ -308,7 +308,7 @@ mod tests {
308308
alias: None,
309309
table: None,
310310
function: Some(Box::new(FunctionExpression::Max(
311-
FunctionArguments::Column("foo".into()),
311+
FunctionArgument::Column("foo".into()),
312312
))),
313313
}),
314314
Scalar(3333.into()),

src/column.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ use keywords::escape_if_keyword;
88

99
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
1010
pub enum FunctionExpression {
11-
Avg(FunctionArguments, bool),
12-
Count(FunctionArguments, bool),
11+
Avg(FunctionArgument, bool),
12+
Count(FunctionArgument, bool),
1313
CountStar,
14-
Sum(FunctionArguments, bool),
15-
Max(FunctionArguments),
16-
Min(FunctionArguments),
17-
GroupConcat(FunctionArguments, String),
14+
Sum(FunctionArgument, bool),
15+
Max(FunctionArgument),
16+
Min(FunctionArgument),
17+
GroupConcat(FunctionArgument, String),
1818
}
1919

2020
impl Display for FunctionExpression {
@@ -38,16 +38,16 @@ impl Display for FunctionExpression {
3838
}
3939

4040
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
41-
pub enum FunctionArguments {
41+
pub enum FunctionArgument {
4242
Column(Column),
4343
Conditional(CaseWhenExpression),
4444
}
4545

46-
impl Display for FunctionArguments {
46+
impl Display for FunctionArgument {
4747
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
4848
match *self {
49-
FunctionArguments::Column(ref col) => write!(f, "{}", col)?,
50-
FunctionArguments::Conditional(ref e) => {
49+
FunctionArgument::Column(ref col) => write!(f, "{}", col)?,
50+
FunctionArgument::Conditional(ref e) => {
5151
write!(f, "{}", e)?;
5252
}
5353
}
@@ -247,7 +247,7 @@ mod tests {
247247
alias: None,
248248
table: None,
249249
function: Some(Box::new(FunctionExpression::Sum(
250-
FunctionArguments::Column(Column::from("mytab.foo")),
250+
FunctionArgument::Column(Column::from("mytab.foo")),
251251
false,
252252
))),
253253
};

src/common.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::str::FromStr;
99

1010
use arithmetic::{arithmetic_expression, ArithmeticExpression};
1111
use case::case_when_column;
12-
use column::{Column, FunctionArguments, FunctionExpression};
12+
use column::{Column, FunctionArgument, FunctionExpression};
1313
use keywords::{escape_if_keyword, sql_keyword};
1414
use nom::bytes::complete::{is_not, tag, tag_no_case, take, take_until, take_while1};
1515
use nom::combinator::opt;
@@ -631,11 +631,11 @@ pub fn type_identifier(i: &[u8]) -> IResult<&[u8], SqlType> {
631631

632632
// Parses the arguments for an aggregation function, and also returns whether the distinct flag is
633633
// present.
634-
pub fn function_arguments(i: &[u8]) -> IResult<&[u8], (FunctionArguments, bool)> {
634+
pub fn function_arguments(i: &[u8]) -> IResult<&[u8], (FunctionArgument, bool)> {
635635
let distinct_parser = opt(tuple((tag_no_case("distinct"), multispace1)));
636636
let args_parser = alt((
637-
map(case_when_column, |cw| FunctionArguments::Conditional(cw)),
638-
map(column_identifier_no_alias, |c| FunctionArguments::Column(c)),
637+
map(case_when_column, |cw| FunctionArgument::Conditional(cw)),
638+
map(column_identifier_no_alias, |c| FunctionArgument::Column(c)),
639639
));
640640
let (remaining_input, (distinct, args)) = tuple((distinct_parser, args_parser))(i)?;
641641
Ok((remaining_input, (args, distinct.is_some())))
@@ -656,7 +656,7 @@ fn group_concat_fx(i: &[u8]) -> IResult<&[u8], (Column, Option<&[u8]>)> {
656656
pair(column_identifier_no_alias, opt(group_concat_fx_helper))(i)
657657
}
658658

659-
fn delim_fx_args(i: &[u8]) -> IResult<&[u8], (FunctionArguments, bool)> {
659+
fn delim_fx_args(i: &[u8]) -> IResult<&[u8], (FunctionArgument, bool)> {
660660
delimited(tag("("), function_arguments, tag(")"))(i)
661661
}
662662

@@ -688,7 +688,7 @@ pub fn column_function(i: &[u8]) -> IResult<&[u8], FunctionExpression> {
688688
None => String::from(","),
689689
Some(s) => String::from_utf8(s.to_vec()).unwrap(),
690690
};
691-
FunctionExpression::GroupConcat(FunctionArguments::Column(col.clone()), sep)
691+
FunctionExpression::GroupConcat(FunctionArgument::Column(col.clone()), sep)
692692
},
693693
),
694694
))(i)
@@ -1128,7 +1128,7 @@ mod tests {
11281128
alias: None,
11291129
table: None,
11301130
function: Some(Box::new(FunctionExpression::Max(
1131-
FunctionArguments::Column(Column::from("addr_id")),
1131+
FunctionArgument::Column(Column::from("addr_id")),
11321132
))),
11331133
};
11341134
assert_eq!(res.unwrap().1, expected);

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ extern crate pretty_assertions;
1111
pub use self::arithmetic::{ArithmeticBase, ArithmeticExpression, ArithmeticOperator};
1212
pub use self::case::{CaseWhenExpression, ColumnOrLiteral};
1313
pub use self::column::{
14-
Column, ColumnConstraint, ColumnSpecification, FunctionArguments, FunctionExpression,
14+
Column, ColumnConstraint, ColumnSpecification, FunctionArgument, FunctionExpression,
1515
};
1616
pub use self::common::{
1717
FieldDefinitionExpression, FieldValueExpression, Literal, LiteralExpression, Operator, Real,

src/select.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ pub fn nested_selection(i: &[u8]) -> IResult<&[u8], SelectStatement> {
310310
mod tests {
311311
use super::*;
312312
use case::{CaseWhenExpression, ColumnOrLiteral};
313-
use column::{Column, FunctionArguments, FunctionExpression};
313+
use column::{Column, FunctionArgument, FunctionExpression};
314314
use common::{
315315
FieldDefinitionExpression, FieldValueExpression, ItemPlaceholder, Literal, Operator,
316316
};
@@ -732,7 +732,7 @@ mod tests {
732732
let qstring = "SELECT max(addr_id) FROM address;";
733733

734734
let res = selection(qstring.as_bytes());
735-
let agg_expr = FunctionExpression::Max(FunctionArguments::Column(Column::from("addr_id")));
735+
let agg_expr = FunctionExpression::Max(FunctionArgument::Column(Column::from("addr_id")));
736736
assert_eq!(
737737
res.unwrap().1,
738738
SelectStatement {
@@ -753,7 +753,7 @@ mod tests {
753753
let qstring = "SELECT max(addr_id) AS max_addr FROM address;";
754754

755755
let res = selection(qstring.as_bytes());
756-
let agg_expr = FunctionExpression::Max(FunctionArguments::Column(Column::from("addr_id")));
756+
let agg_expr = FunctionExpression::Max(FunctionArgument::Column(Column::from("addr_id")));
757757
let expected_stmt = SelectStatement {
758758
tables: vec![Table::from("address")],
759759
fields: vec![FieldDefinitionExpression::Col(Column {
@@ -796,7 +796,7 @@ mod tests {
796796

797797
let res = selection(qstring.as_bytes());
798798
let agg_expr =
799-
FunctionExpression::Count(FunctionArguments::Column(Column::from("vote_id")), true);
799+
FunctionExpression::Count(FunctionArgument::Column(Column::from("vote_id")), true);
800800
let expected_stmt = SelectStatement {
801801
tables: vec![Table::from("votes")],
802802
fields: vec![FieldDefinitionExpression::Col(Column {
@@ -826,7 +826,7 @@ mod tests {
826826
operator: Operator::Greater,
827827
});
828828
let agg_expr = FunctionExpression::Count(
829-
FunctionArguments::Conditional(CaseWhenExpression {
829+
FunctionArgument::Conditional(CaseWhenExpression {
830830
then_expr: ColumnOrLiteral::Column(Column::from("vote_id")),
831831
else_expr: None,
832832
condition: filter_cond,
@@ -862,7 +862,7 @@ mod tests {
862862
operator: Operator::Equal,
863863
});
864864
let agg_expr = FunctionExpression::Sum(
865-
FunctionArguments::Conditional(CaseWhenExpression {
865+
FunctionArgument::Conditional(CaseWhenExpression {
866866
then_expr: ColumnOrLiteral::Column(Column::from("vote_id")),
867867
else_expr: None,
868868
condition: filter_cond,
@@ -899,7 +899,7 @@ mod tests {
899899
operator: Operator::Equal,
900900
});
901901
let agg_expr = FunctionExpression::Sum(
902-
FunctionArguments::Conditional(CaseWhenExpression {
902+
FunctionArgument::Conditional(CaseWhenExpression {
903903
then_expr: ColumnOrLiteral::Column(Column::from("vote_id")),
904904
else_expr: Some(ColumnOrLiteral::Literal(Literal::Integer(6))),
905905
condition: filter_cond,
@@ -946,7 +946,7 @@ mod tests {
946946
operator: Operator::And,
947947
});
948948
let agg_expr = FunctionExpression::Count(
949-
FunctionArguments::Conditional(CaseWhenExpression {
949+
FunctionArgument::Conditional(CaseWhenExpression {
950950
then_expr: ColumnOrLiteral::Column(Column::from("votes.vote")),
951951
else_expr: None,
952952
condition: filter_cond,
@@ -1165,7 +1165,7 @@ mod tests {
11651165

11661166
let res = selection(qstr.as_bytes());
11671167

1168-
let agg_expr = FunctionExpression::Max(FunctionArguments::Column(Column::from("o_id")));
1168+
let agg_expr = FunctionExpression::Max(FunctionArgument::Column(Column::from("o_id")));
11691169
let recursive_select = SelectStatement {
11701170
tables: vec![Table::from("orders")],
11711171
fields: vec![FieldDefinitionExpression::Col(Column {
@@ -1279,7 +1279,7 @@ mod tests {
12791279
alias: None,
12801280
table: None,
12811281
function: Some(Box::new(FunctionExpression::Max(
1282-
FunctionArguments::Column("o_id".into()),
1282+
FunctionArgument::Column("o_id".into()),
12831283
))),
12841284
}),
12851285
ArithmeticBase::Scalar(3333.into()),
@@ -1309,7 +1309,7 @@ mod tests {
13091309
alias: None,
13101310
table: None,
13111311
function: Some(Box::new(FunctionExpression::Max(
1312-
FunctionArguments::Column("o_id".into()),
1312+
FunctionArgument::Column("o_id".into()),
13131313
))),
13141314
}),
13151315
ArithmeticBase::Scalar(2.into()),

0 commit comments

Comments
 (0)