Skip to content

Commit fbb19e8

Browse files
committed
Introduce Visitor#visit_select
1 parent fc0398a commit fbb19e8

3 files changed

Lines changed: 24 additions & 4 deletions

File tree

src/ast/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9946,7 +9946,7 @@ pub enum CreateFunctionBody {
99469946
/// ```
99479947
///
99489948
/// [MsSql]: https://learn.microsoft.com/en-us/sql/t-sql/statements/create-function-transact-sql?view=sql-server-ver16#select_stmt
9949-
AsReturnSelect(Select),
9949+
AsReturnSelect(#[cfg_attr(feature = "visitor", visit(with = "visit_select"))] Select),
99509950
}
99519951

99529952
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]

src/ast/query.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,10 @@ impl fmt::Display for ProjectionSelect {
149149
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
150150
pub enum SetExpr {
151151
/// Restricted SELECT .. FROM .. HAVING (no ORDER BY or set operations)
152-
Select(Box<Select>),
152+
Select(#[cfg_attr(feature = "visitor", visit(with = "visit_select"))] Box<Select>),
153153
/// Parenthesized SELECT subquery, which may include more set operations
154154
/// in its body and an optional ORDER BY / LIMIT.
155-
Query(Box<Query>),
155+
Query(#[cfg_attr(feature = "visitor", visit(with = "visit_query"))] Box<Query>),
156156
/// UNION/EXCEPT/INTERSECT of two queries
157157
/// A set operation combining two query expressions.
158158
SetOperation {

src/ast/visitor.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
//! Recursive visitors for ast Nodes. See [`Visitor`] for more details.
1919
20-
use crate::ast::{Expr, ObjectName, Query, Statement, TableFactor, Value};
20+
use crate::ast::{Expr, ObjectName, Query, Statement, TableFactor, Value, Select};
2121
use core::ops::ControlFlow;
2222

2323
/// A type that can be visited by a [`Visitor`]. See [`Visitor`] for
@@ -207,6 +207,16 @@ pub trait Visitor {
207207
ControlFlow::Continue(())
208208
}
209209

210+
/// Invoked for any [Select] that appear in the AST before visiting children
211+
fn pre_visit_select(&mut self, _select: &Select) -> ControlFlow<Self::Break> {
212+
ControlFlow::Continue(())
213+
}
214+
215+
/// Invoked for any [Select] that appear in the AST after visiting children
216+
fn post_visit_select(&mut self, _select: &Select) -> ControlFlow<Self::Break> {
217+
ControlFlow::Continue(())
218+
}
219+
210220
/// Invoked for any relations (e.g. tables) that appear in the AST before visiting children
211221
fn pre_visit_relation(&mut self, _relation: &ObjectName) -> ControlFlow<Self::Break> {
212222
ControlFlow::Continue(())
@@ -319,6 +329,16 @@ pub trait VisitorMut {
319329
ControlFlow::Continue(())
320330
}
321331

332+
/// Invoked for any [Select] that appear in the AST before visiting children
333+
fn pre_visit_select(&mut self, _select: &Select) -> ControlFlow<Self::Break> {
334+
ControlFlow::Continue(())
335+
}
336+
337+
/// Invoked for any [Select] that appear in the AST after visiting children
338+
fn post_visit_select(&mut self, _select: &Select) -> ControlFlow<Self::Break> {
339+
ControlFlow::Continue(())
340+
}
341+
322342
/// Invoked for any relations (e.g. tables) that appear in the AST before visiting children
323343
fn pre_visit_relation(&mut self, _relation: &mut ObjectName) -> ControlFlow<Self::Break> {
324344
ControlFlow::Continue(())

0 commit comments

Comments
 (0)