mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-09-04 13:10:31 +00:00
Use Option<Expr>
for Min and Max vals in Seq Opts, fix alter col seq display (#1106)
This commit is contained in:
parent
1b6b6aa65f
commit
f5e27366f3
3 changed files with 21 additions and 38 deletions
|
@ -355,17 +355,13 @@ impl fmt::Display for AlterColumnOperation {
|
||||||
|
|
||||||
write!(f, "ADD GENERATED{generated_as} AS IDENTITY",)?;
|
write!(f, "ADD GENERATED{generated_as} AS IDENTITY",)?;
|
||||||
if let Some(options) = sequence_options {
|
if let Some(options) = sequence_options {
|
||||||
if !options.is_empty() {
|
write!(f, " (")?;
|
||||||
write!(f, " (")?;
|
|
||||||
}
|
|
||||||
|
|
||||||
for sequence_option in options {
|
for sequence_option in options {
|
||||||
write!(f, "{sequence_option}")?;
|
write!(f, "{sequence_option}")?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if !options.is_empty() {
|
write!(f, " )")?;
|
||||||
write!(f, " )")?;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -3835,8 +3835,8 @@ impl fmt::Display for Statement {
|
||||||
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
|
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
|
||||||
pub enum SequenceOptions {
|
pub enum SequenceOptions {
|
||||||
IncrementBy(Expr, bool),
|
IncrementBy(Expr, bool),
|
||||||
MinValue(MinMaxValue),
|
MinValue(Option<Expr>),
|
||||||
MaxValue(MinMaxValue),
|
MaxValue(Option<Expr>),
|
||||||
StartWith(Expr, bool),
|
StartWith(Expr, bool),
|
||||||
Cache(Expr),
|
Cache(Expr),
|
||||||
Cycle(bool),
|
Cycle(bool),
|
||||||
|
@ -3853,28 +3853,18 @@ impl fmt::Display for SequenceOptions {
|
||||||
increment = increment
|
increment = increment
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
SequenceOptions::MinValue(value) => match value {
|
SequenceOptions::MinValue(Some(expr)) => {
|
||||||
MinMaxValue::Empty => {
|
write!(f, " MINVALUE {expr}")
|
||||||
write!(f, "")
|
}
|
||||||
}
|
SequenceOptions::MinValue(None) => {
|
||||||
MinMaxValue::None => {
|
write!(f, " NO MINVALUE")
|
||||||
write!(f, " NO MINVALUE")
|
}
|
||||||
}
|
SequenceOptions::MaxValue(Some(expr)) => {
|
||||||
MinMaxValue::Some(minvalue) => {
|
write!(f, " MAXVALUE {expr}")
|
||||||
write!(f, " MINVALUE {minvalue}")
|
}
|
||||||
}
|
SequenceOptions::MaxValue(None) => {
|
||||||
},
|
write!(f, " NO MAXVALUE")
|
||||||
SequenceOptions::MaxValue(value) => match value {
|
}
|
||||||
MinMaxValue::Empty => {
|
|
||||||
write!(f, "")
|
|
||||||
}
|
|
||||||
MinMaxValue::None => {
|
|
||||||
write!(f, " NO MAXVALUE")
|
|
||||||
}
|
|
||||||
MinMaxValue::Some(maxvalue) => {
|
|
||||||
write!(f, " MAXVALUE {maxvalue}")
|
|
||||||
}
|
|
||||||
},
|
|
||||||
SequenceOptions::StartWith(start, with) => {
|
SequenceOptions::StartWith(start, with) => {
|
||||||
write!(
|
write!(
|
||||||
f,
|
f,
|
||||||
|
|
|
@ -8805,24 +8805,21 @@ impl<'a> Parser<'a> {
|
||||||
}
|
}
|
||||||
//[ MINVALUE minvalue | NO MINVALUE ]
|
//[ MINVALUE minvalue | NO MINVALUE ]
|
||||||
if self.parse_keyword(Keyword::MINVALUE) {
|
if self.parse_keyword(Keyword::MINVALUE) {
|
||||||
sequence_options.push(SequenceOptions::MinValue(MinMaxValue::Some(Expr::Value(
|
sequence_options.push(SequenceOptions::MinValue(Some(Expr::Value(
|
||||||
self.parse_number_value()?,
|
self.parse_number_value()?,
|
||||||
))));
|
))));
|
||||||
} else if self.parse_keywords(&[Keyword::NO, Keyword::MINVALUE]) {
|
} else if self.parse_keywords(&[Keyword::NO, Keyword::MINVALUE]) {
|
||||||
sequence_options.push(SequenceOptions::MinValue(MinMaxValue::None));
|
sequence_options.push(SequenceOptions::MinValue(None));
|
||||||
} else {
|
|
||||||
sequence_options.push(SequenceOptions::MinValue(MinMaxValue::Empty));
|
|
||||||
}
|
}
|
||||||
//[ MAXVALUE maxvalue | NO MAXVALUE ]
|
//[ MAXVALUE maxvalue | NO MAXVALUE ]
|
||||||
if self.parse_keywords(&[Keyword::MAXVALUE]) {
|
if self.parse_keywords(&[Keyword::MAXVALUE]) {
|
||||||
sequence_options.push(SequenceOptions::MaxValue(MinMaxValue::Some(Expr::Value(
|
sequence_options.push(SequenceOptions::MaxValue(Some(Expr::Value(
|
||||||
self.parse_number_value()?,
|
self.parse_number_value()?,
|
||||||
))));
|
))));
|
||||||
} else if self.parse_keywords(&[Keyword::NO, Keyword::MAXVALUE]) {
|
} else if self.parse_keywords(&[Keyword::NO, Keyword::MAXVALUE]) {
|
||||||
sequence_options.push(SequenceOptions::MaxValue(MinMaxValue::None));
|
sequence_options.push(SequenceOptions::MaxValue(None));
|
||||||
} else {
|
|
||||||
sequence_options.push(SequenceOptions::MaxValue(MinMaxValue::Empty));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//[ START [ WITH ] start ]
|
//[ START [ WITH ] start ]
|
||||||
if self.parse_keywords(&[Keyword::START]) {
|
if self.parse_keywords(&[Keyword::START]) {
|
||||||
if self.parse_keywords(&[Keyword::WITH]) {
|
if self.parse_keywords(&[Keyword::WITH]) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue