Single consolidated method to check if a statement requires graph context This replaces all the scattered *_needs_graph_context methods for a clean PostgreSQL-style approach
(&self, statement: &crate::ast::Statement)
| 2722 | /// Single consolidated method to check if a statement requires graph context |
| 2723 | /// This replaces all the scattered *_needs_graph_context methods for a clean PostgreSQL-style approach |
| 2724 | fn statement_needs_graph_context(&self, statement: &crate::ast::Statement) -> bool { |
| 2725 | use crate::ast::Statement; |
| 2726 | |
| 2727 | match statement { |
| 2728 | Statement::Query(_) => { |
| 2729 | // Query graph context requirements are now determined by the validator |
| 2730 | // This method should not be used for Query statements - use the validator's flag instead |
| 2731 | // Returning true here for backward compatibility, but caller should use validator flag |
| 2732 | true |
| 2733 | } |
| 2734 | Statement::DataStatement(_) => { |
| 2735 | // Data statements (INSERT, DELETE, etc.) always need graph context |
| 2736 | true |
| 2737 | } |
| 2738 | Statement::Call(call_stmt) => { |
| 2739 | // Check if the specific procedure needs graph context |
| 2740 | self.procedure_needs_graph_context(&call_stmt.procedure_name) |
| 2741 | } |
| 2742 | Statement::Select(select_stmt) => { |
| 2743 | // SELECT statements may or may not need graph context |
| 2744 | self.select_statement_needs_graph_context(select_stmt) |
| 2745 | } |
| 2746 | Statement::SessionStatement(_) => { |
| 2747 | // Session statements (SET SESSION, etc.) don't need graph context |
| 2748 | false |
| 2749 | } |
| 2750 | Statement::CatalogStatement(_) => { |
| 2751 | // Catalog statements don't need graph context |
| 2752 | false |
| 2753 | } |
| 2754 | Statement::Declare(_) => { |
| 2755 | // Cursor declarations don't need graph context |
| 2756 | false |
| 2757 | } |
| 2758 | Statement::Next(_) => { |
| 2759 | // NEXT statements may need graph context if they reference graph data |
| 2760 | true |
| 2761 | } |
| 2762 | Statement::AtLocation(_) => { |
| 2763 | // AT statements need graph context for location resolution |
| 2764 | true |
| 2765 | } |
| 2766 | Statement::TransactionStatement(_) => { |
| 2767 | // Transaction statements don't need graph context |
| 2768 | false |
| 2769 | } |
| 2770 | Statement::ProcedureBody(procedure_body) => { |
| 2771 | // Procedure body needs graph context if any of its statements need it |
| 2772 | self.statement_needs_graph_context(&procedure_body.initial_statement) |
| 2773 | || procedure_body |
| 2774 | .chained_statements |
| 2775 | .iter() |
| 2776 | .any(|chained| self.statement_needs_graph_context(&chained.statement)) |
| 2777 | } |
| 2778 | Statement::IndexStatement(_) => { |
| 2779 | // Index DDL statements don't need graph context |
| 2780 | false |
| 2781 | } |
no test coverage detected