Skip to content

Commit c62ccdf

Browse files
tomharmonms705
authored andcommitted
add back TODO comment for table options
1 parent f33a0c2 commit c62ccdf

File tree

1 file changed

+18
-38
lines changed

1 file changed

+18
-38
lines changed

src/create_table_options.rs

Lines changed: 18 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use nom::character::complete::{alphanumeric1, multispace0, multispace1};
22

3-
use common::{integer_literal, sql_identifier, string_literal, ws_sep_comma,
4-
ws_sep_equals};
3+
use common::{integer_literal, sql_identifier, string_literal, ws_sep_comma, ws_sep_equals};
54
use nom::branch::alt;
65
use nom::bytes::complete::{tag, tag_no_case};
76
use nom::combinator::{map, opt};
@@ -10,6 +9,7 @@ use nom::sequence::tuple;
109
use nom::IResult;
1110

1211
pub fn table_options(i: &[u8]) -> IResult<&[u8], ()> {
12+
// TODO: make the create options accessible
1313
map(
1414
separated_list(table_options_separator, create_option),
1515
|_| (),
@@ -36,50 +36,40 @@ fn create_option(i: &[u8]) -> IResult<&[u8], ()> {
3636
))(i)
3737
}
3838

39-
4039
/// Helper to parse equals-separated create option pairs.
4140
/// Throws away the create option and value
42-
pub fn create_option_equals_pair<'a, I, O1, O2, F, G>(first: F, second: G) -> impl Fn(I) -> IResult<I, ()>
41+
pub fn create_option_equals_pair<'a, I, O1, O2, F, G>(
42+
first: F,
43+
second: G,
44+
) -> impl Fn(I) -> IResult<I, ()>
4345
where
44-
F: Fn(I) -> IResult<I, O1>,
45-
G: Fn(I) -> IResult<I, O2>,
46-
I: nom::InputTakeAtPosition + nom::InputTake + nom::Compare<&'a str>,
47-
<I as nom::InputTakeAtPosition>::Item: nom::AsChar + Clone,
46+
F: Fn(I) -> IResult<I, O1>,
47+
G: Fn(I) -> IResult<I, O2>,
48+
I: nom::InputTakeAtPosition + nom::InputTake + nom::Compare<&'a str>,
49+
<I as nom::InputTakeAtPosition>::Item: nom::AsChar + Clone,
4850
{
4951
move |i: I| {
5052
let (i, _o1) = first(i)?;
5153
let (i, _) = ws_sep_equals(i)?;
5254
let (i, _o2) = second(i)?;
53-
Ok(( i, () ))
55+
Ok((i, ()))
5456
}
5557
}
5658

5759
fn create_option_type(i: &[u8]) -> IResult<&[u8], ()> {
58-
create_option_equals_pair(
59-
tag_no_case("type"),
60-
alphanumeric1
61-
)(i)
60+
create_option_equals_pair(tag_no_case("type"), alphanumeric1)(i)
6261
}
6362

6463
fn create_option_pack_keys(i: &[u8]) -> IResult<&[u8], ()> {
65-
create_option_equals_pair(
66-
tag_no_case("pack_keys"),
67-
alt((tag("0"), tag("1")))
68-
)(i)
64+
create_option_equals_pair(tag_no_case("pack_keys"), alt((tag("0"), tag("1"))))(i)
6965
}
7066

7167
fn create_option_engine(i: &[u8]) -> IResult<&[u8], ()> {
72-
create_option_equals_pair(
73-
tag_no_case("engine"),
74-
opt(alphanumeric1)
75-
)(i)
68+
create_option_equals_pair(tag_no_case("engine"), opt(alphanumeric1))(i)
7669
}
7770

7871
fn create_option_auto_increment(i: &[u8]) -> IResult<&[u8], ()> {
79-
create_option_equals_pair(
80-
tag_no_case("auto_increment"),
81-
integer_literal,
82-
)(i)
72+
create_option_equals_pair(tag_no_case("auto_increment"), integer_literal)(i)
8373
}
8474

8575
fn create_option_default_charset(i: &[u8]) -> IResult<&[u8], ()> {
@@ -105,27 +95,17 @@ fn create_option_collate(i: &[u8]) -> IResult<&[u8], ()> {
10595
}
10696

10797
fn create_option_comment(i: &[u8]) -> IResult<&[u8], ()> {
108-
create_option_equals_pair(
109-
tag_no_case("comment"),
110-
string_literal,
111-
)(i)
98+
create_option_equals_pair(tag_no_case("comment"), string_literal)(i)
11299
}
113100

114101
fn create_option_max_rows(i: &[u8]) -> IResult<&[u8], ()> {
115-
create_option_equals_pair(
116-
tag_no_case("max_rows"),
117-
integer_literal
118-
)(i)
102+
create_option_equals_pair(tag_no_case("max_rows"), integer_literal)(i)
119103
}
120104

121105
fn create_option_avg_row_length(i: &[u8]) -> IResult<&[u8], ()> {
122-
create_option_equals_pair(
123-
tag_no_case("avg_row_length"),
124-
integer_literal
125-
)(i)
106+
create_option_equals_pair(tag_no_case("avg_row_length"), integer_literal)(i)
126107
}
127108

128-
129109
fn create_option_row_format(i: &[u8]) -> IResult<&[u8], ()> {
130110
let (remaining_input, (_, _, _, _, _)) = tuple((
131111
tag_no_case("row_format"),

0 commit comments

Comments
 (0)