|
18 | 18 | //! Recursive visitors for ast Nodes. See [`Visitor`] for more details.
|
19 | 19 |
|
20 | 20 | use crate::ast::{
|
21 |
| - Expr, Function, GroupByExpr, ObjectName, OrderBy, Query, SelectItem, Statement, TableFactor, |
22 |
| - Value, |
| 21 | + Expr, Function, GroupByExpr, ObjectName, OrderBy, Query, Select, SelectItem, Statement, |
| 22 | + TableFactor, Value, With, |
23 | 23 | };
|
24 | 24 | use core::ops::ControlFlow;
|
25 | 25 | use sqlparser::ast::Ident;
|
@@ -307,6 +307,36 @@ pub trait Visitor {
|
307 | 307 | fn post_visit_order_by(&mut self, _order_by: &OrderBy) -> ControlFlow<Self::Break> {
|
308 | 308 | ControlFlow::Continue(())
|
309 | 309 | }
|
| 310 | + |
| 311 | + /// Invoked for any Select that appear in the AST before visiting children |
| 312 | + fn pre_visit_select(&mut self, _select: &Select) -> ControlFlow<Self::Break> { |
| 313 | + ControlFlow::Continue(()) |
| 314 | + } |
| 315 | + |
| 316 | + /// Invoked for any Select that appear in the AST after visiting children |
| 317 | + fn post_visit_select(&mut self, _select: &Select) -> ControlFlow<Self::Break> { |
| 318 | + ControlFlow::Continue(()) |
| 319 | + } |
| 320 | + |
| 321 | + /// Invoked for any With that appear in the AST before visiting children |
| 322 | + fn pre_visit_with(&mut self, _select: &With) -> ControlFlow<Self::Break> { |
| 323 | + ControlFlow::Continue(()) |
| 324 | + } |
| 325 | + |
| 326 | + /// Invoked for any With that appear in the AST after visiting children |
| 327 | + fn post_visit_with(&mut self, _select: &With) -> ControlFlow<Self::Break> { |
| 328 | + ControlFlow::Continue(()) |
| 329 | + } |
| 330 | + |
| 331 | + /// Invoked for any Projection that appear in the AST before visiting children |
| 332 | + fn pre_visit_projection(&mut self, _select: &Vec<SelectItem>) -> ControlFlow<Self::Break> { |
| 333 | + ControlFlow::Continue(()) |
| 334 | + } |
| 335 | + |
| 336 | + /// Invoked for any Projection that appear in the AST after visiting children |
| 337 | + fn post_visit_projection(&mut self, _select: &Vec<SelectItem>) -> ControlFlow<Self::Break> { |
| 338 | + ControlFlow::Continue(()) |
| 339 | + } |
310 | 340 | }
|
311 | 341 |
|
312 | 342 | /// A visitor that can be used to mutate an AST tree.
|
@@ -487,6 +517,36 @@ pub trait VisitorMut {
|
487 | 517 | fn post_visit_order_by(&mut self, _order_by: &mut OrderBy) -> ControlFlow<Self::Break> {
|
488 | 518 | ControlFlow::Continue(())
|
489 | 519 | }
|
| 520 | + |
| 521 | + /// Invoked for any Select Expr that appear in the AST before visiting children |
| 522 | + fn pre_visit_select(&mut self, _select: &mut Select) -> ControlFlow<Self::Break> { |
| 523 | + ControlFlow::Continue(()) |
| 524 | + } |
| 525 | + |
| 526 | + /// Invoked for any Select Expr that appear in the AST after visiting children |
| 527 | + fn post_visit_select(&mut self, _select: &mut Select) -> ControlFlow<Self::Break> { |
| 528 | + ControlFlow::Continue(()) |
| 529 | + } |
| 530 | + |
| 531 | + /// Invoked for any With Expr that appear in the AST before visiting children |
| 532 | + fn pre_visit_with(&mut self, _select: &mut With) -> ControlFlow<Self::Break> { |
| 533 | + ControlFlow::Continue(()) |
| 534 | + } |
| 535 | + |
| 536 | + /// Invoked for any With Expr that appear in the AST after visiting children |
| 537 | + fn post_visit_with(&mut self, _select: &mut With) -> ControlFlow<Self::Break> { |
| 538 | + ControlFlow::Continue(()) |
| 539 | + } |
| 540 | + |
| 541 | + /// Invoked for any Projection that appear in the AST before visiting children |
| 542 | + fn pre_visit_projection(&mut self, _select: &mut Vec<SelectItem>) -> ControlFlow<Self::Break> { |
| 543 | + ControlFlow::Continue(()) |
| 544 | + } |
| 545 | + |
| 546 | + /// Invoked for any Projection that appear in the AST after visiting children |
| 547 | + fn post_visit_projection(&mut self, _select: &mut Vec<SelectItem>) -> ControlFlow<Self::Break> { |
| 548 | + ControlFlow::Continue(()) |
| 549 | + } |
490 | 550 | }
|
491 | 551 |
|
492 | 552 | struct RelationVisitor<F>(F);
|
|
0 commit comments