From 562f581dd658748a5701315c94c490dc8d6b2f51 Mon Sep 17 00:00:00 2001 From: sabir-akhadov-localstack Date: Mon, 17 Aug 2026 16:59:31 +0200 Subject: [PATCH] Visit CreateView name as a relation The visitor framework skipped CreateView.name, so visit_relations / visit_relations_mut did not surface or rewrite the view name in CREATE VIEW statements, unlike CreateTable, CreateIndex, and AlterTable which already annotate their names with visit_relation. Co-Authored-By: Claude Fable 5 --- src/ast/ddl.rs | 1 + src/ast/visitor.rs | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/ast/ddl.rs b/src/ast/ddl.rs index a0e69ad8a..5146454d4 100644 --- a/src/ast/ddl.rs +++ b/src/ast/ddl.rs @@ -4386,6 +4386,7 @@ pub struct CreateView { /// pub secure: bool, /// View name + #[cfg_attr(feature = "visitor", visit(with = "visit_relation"))] pub name: ObjectName, /// If `if_not_exists` is true, this flag is set to true if the view name comes before the `IF NOT EXISTS` clause. /// Example: diff --git a/src/ast/visitor.rs b/src/ast/visitor.rs index 9011a94d5..41b703207 100644 --- a/src/ast/visitor.rs +++ b/src/ast/visitor.rs @@ -1242,6 +1242,27 @@ mod tests { do_visit("SELECT a, b FROM t", &mut visitor); assert_eq!(visitor.idents, vec!["a", "b", "t"]); } + + #[derive(Default)] + struct RelationVisitor { + relations: Vec, + } + + impl Visitor for RelationVisitor { + type Break = (); + + fn pre_visit_relation(&mut self, relation: &ObjectName) -> ControlFlow { + self.relations.push(relation.to_string()); + ControlFlow::Continue(()) + } + } + + #[test] + fn test_visit_create_view_name_as_relation() { + let mut visitor = RelationVisitor::default(); + do_visit("CREATE VIEW db1.v AS SELECT * FROM t", &mut visitor); + assert_eq!(visitor.relations, vec!["db1.v", "t"]); + } } #[cfg(test)]