Skip to content

Commit 032c9bb

Browse files
committed
Remove duplicated code by parse_boolean_string usage
1 parent 7697d35 commit 032c9bb

File tree

2 files changed

+3
-21
lines changed

2 files changed

+3
-21
lines changed

src/dialect/snowflake.rs

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -598,29 +598,11 @@ pub fn parse_create_table(
598598
}
599599
Keyword::ENABLE_SCHEMA_EVOLUTION => {
600600
parser.expect_token(&Token::Eq)?;
601-
let enable_schema_evolution =
602-
match parser.parse_one_of_keywords(&[Keyword::TRUE, Keyword::FALSE]) {
603-
Some(Keyword::TRUE) => true,
604-
Some(Keyword::FALSE) => false,
605-
_ => {
606-
return parser.expected("TRUE or FALSE", next_token);
607-
}
608-
};
609-
610-
builder = builder.enable_schema_evolution(Some(enable_schema_evolution));
601+
builder = builder.enable_schema_evolution(Some(parser.parse_boolean_string()?));
611602
}
612603
Keyword::CHANGE_TRACKING => {
613604
parser.expect_token(&Token::Eq)?;
614-
let change_tracking =
615-
match parser.parse_one_of_keywords(&[Keyword::TRUE, Keyword::FALSE]) {
616-
Some(Keyword::TRUE) => true,
617-
Some(Keyword::FALSE) => false,
618-
_ => {
619-
return parser.expected("TRUE or FALSE", next_token);
620-
}
621-
};
622-
623-
builder = builder.change_tracking(Some(change_tracking));
605+
builder = builder.change_tracking(Some(parser.parse_boolean_string()?));
624606
}
625607
Keyword::DATA_RETENTION_TIME_IN_DAYS => {
626608
parser.expect_token(&Token::Eq)?;

src/parser/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9772,7 +9772,7 @@ impl<'a> Parser<'a> {
97729772
}
97739773

97749774
/// Parse a boolean string
9775-
pub fn parse_boolean_string(&mut self) -> Result<bool, ParserError> {
9775+
pub(crate) fn parse_boolean_string(&mut self) -> Result<bool, ParserError> {
97769776
match self.parse_one_of_keywords(&[Keyword::TRUE, Keyword::FALSE]) {
97779777
Some(Keyword::TRUE) => Ok(true),
97789778
Some(Keyword::FALSE) => Ok(false),

0 commit comments

Comments
 (0)