Skip to content

fix: maybe_parse preventing parser from erroring on recursion limit #1464

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

Merged
merged 6 commits into from
Oct 21, 2024
4 changes: 2 additions & 2 deletions src/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3196,7 +3196,7 @@ pub enum Statement {
/// Table confs
options: Vec<SqlOption>,
/// Cache table as a Query
query: Option<Query>,
query: Option<Box<Query>>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a nice change

},
/// ```sql
/// UNCACHE TABLE [ IF EXISTS ] <table_name>
Expand Down Expand Up @@ -6995,7 +6995,7 @@ impl fmt::Display for MacroArg {
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
pub enum MacroDefinition {
Expr(Expr),
Table(Query),
Table(Box<Query>),
}

impl fmt::Display for MacroDefinition {
Expand Down
2 changes: 1 addition & 1 deletion src/ast/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1103,7 +1103,7 @@ pub enum PivotValueSource {
/// Pivot on all values returned by a subquery.
///
/// See <https://docs.snowflake.com/en/sql-reference/constructs/pivot#pivot-on-column-values-using-a-subquery-with-dynamic-pivot>.
Subquery(Query),
Subquery(Box<Query>),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

}

impl fmt::Display for PivotValueSource {
Expand Down
4 changes: 2 additions & 2 deletions src/dialect/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -486,9 +486,9 @@ pub trait Dialect: Debug + Any {
fn parse_column_option(
&self,
_parser: &mut Parser,
) -> Option<Result<Option<ColumnOption>, ParserError>> {
) -> Result<Option<Result<Option<ColumnOption>, ParserError>>, ParserError> {
// return None to fall back to the default behavior
None
Ok(None)
}

/// Decide the lexical Precedence of operators.
Expand Down
4 changes: 2 additions & 2 deletions src/dialect/snowflake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ impl Dialect for SnowflakeDialect {
fn parse_column_option(
&self,
parser: &mut Parser,
) -> Option<Result<Option<ColumnOption>, ParserError>> {
) -> Result<Option<Result<Option<ColumnOption>, ParserError>>, ParserError> {
parser.maybe_parse(|parser| {
let with = parser.parse_keyword(Keyword::WITH);

Expand Down Expand Up @@ -247,7 +247,7 @@ pub fn parse_create_table(
builder = builder.comment(parser.parse_optional_inline_comment()?);
}
Keyword::AS => {
let query = parser.parse_boxed_query()?;
let query = parser.parse_query()?;
builder = builder.query(Some(query));
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/parser/alter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ impl<'a> Parser<'a> {
let _ = self.parse_keyword(Keyword::WITH);
// option
let mut options = vec![];
while let Some(opt) = self.maybe_parse(|parser| parser.parse_pg_role_option()) {
while let Some(opt) = self.maybe_parse(|parser| parser.parse_pg_role_option())? {
options.push(opt);
}
// check option
Expand Down
Loading
Loading