From 7437908baff84c50990a016e396c4e9407d5346e Mon Sep 17 00:00:00 2001 From: filipriec Date: Fri, 25 Jul 2025 12:13:51 +0200 Subject: [PATCH] removal of @ syntax as reference from the backend --- server/src/steel/server/execution.rs | 9 +++-- .../handlers/dependency_analyzer.rs | 33 +++---------------- 2 files changed, 9 insertions(+), 33 deletions(-) diff --git a/server/src/steel/server/execution.rs b/server/src/steel/server/execution.rs index 1036ef1..7d88e14 100644 --- a/server/src/steel/server/execution.rs +++ b/server/src/steel/server/execution.rs @@ -82,13 +82,12 @@ pub async fn execute_script( // Register decimal math operations register_decimal_math_functions(&mut vm); - // Register row data as variables in the Steel VM - // Both bare names and @-prefixed names are supported for flexibility + // Register row data as variables in the Steel VM for get-var access let mut define_script = String::new(); for (key, value) in &context.row_data { - // Register both @ prefixed and bare variable names - define_script.push_str(&format!("(define @{} \"{}\")\n", key, value)); + // Register only bare variable names for get-var access + define_script.push_str(&format!("(define {} \"{}\")\n", key, value)); } // Execute variable definitions if any exist @@ -169,7 +168,7 @@ fn register_decimal_math_functions(vm: &mut Engine) { /// Processes Steel script results into string format for consistent output. fn process_string_results(results: Vec) -> Result { let mut strings = Vec::new(); - + for result in results { let result_str = match result { SteelVal::StringV(s) => s.to_string(), diff --git a/server/src/table_script/handlers/dependency_analyzer.rs b/server/src/table_script/handlers/dependency_analyzer.rs index 60afbd7..ab4efa2 100644 --- a/server/src/table_script/handlers/dependency_analyzer.rs +++ b/server/src/table_script/handlers/dependency_analyzer.rs @@ -103,7 +103,7 @@ impl From for Status { } /// Analyzes Steel scripts to extract table dependencies and validate referential integrity. -/// +/// /// This analyzer identifies how tables reference each other through Steel function calls /// and ensures that dependency graphs remain acyclic while respecting table link constraints. pub struct DependencyAnalyzer { @@ -117,12 +117,11 @@ impl DependencyAnalyzer { } /// Analyzes a Steel script to extract all table dependencies. - /// + /// /// Uses regex patterns to identify function calls that create dependencies: /// - `steel_get_column` calls for direct column access /// - `steel_get_column_with_index` calls for indexed access /// - `steel_query_sql` calls for raw SQL access - /// - Variable references like `@column_name` /// - `get-var` calls in transformed scripts /// /// # Arguments @@ -139,7 +138,6 @@ impl DependencyAnalyzer { dependencies.extend(self.extract_function_calls(script)?); dependencies.extend(self.extract_sql_dependencies(script)?); dependencies.extend(self.extract_get_var_calls(script, current_table_name)?); - dependencies.extend(self.extract_variable_references(script, current_table_name)?); Ok(dependencies) } @@ -202,27 +200,6 @@ impl DependencyAnalyzer { Ok(dependencies) } - /// Extracts direct variable references like @price, @quantity. - /// These represent self-references to the current table. - fn extract_variable_references(&self, script: &str, current_table_name: &str) -> Result, DependencyError> { - let mut dependencies = Vec::new(); - - // Pattern: @variable_name - let variable_pattern = regex::Regex::new(r#"@([a-zA-Z_][a-zA-Z0-9_]*)"#) - .map_err(|e: regex::Error| DependencyError::ScriptParseError { error: e.to_string() })?; - - for caps in variable_pattern.captures_iter(script) { - let variable_name = caps[1].to_string(); - dependencies.push(Dependency { - target_table: current_table_name.to_string(), - dependency_type: DependencyType::ColumnAccess { column: variable_name }, - context: None, - }); - } - - Ok(dependencies) - } - /// Extracts table references from SQL queries in steel_query_sql calls. fn extract_sql_dependencies(&self, script: &str) -> Result, DependencyError> { let mut dependencies = Vec::new(); @@ -272,7 +249,7 @@ impl DependencyAnalyzer { } /// Checks for circular dependencies in the dependency graph. - /// + /// /// This function validates that adding new dependencies won't create cycles /// that could lead to infinite loops during script execution. Self-references /// are explicitly allowed and filtered out from cycle detection. @@ -421,7 +398,7 @@ impl DependencyAnalyzer { } /// Validates that structured table access respects table link constraints. - /// + /// /// # Access Rules /// - Self-references are always allowed (table can access its own columns) /// - Structured access (steel_get_column functions) requires explicit table links @@ -532,7 +509,7 @@ impl DependencyAnalyzer { } /// Saves dependencies to the database within an existing transaction. - /// + /// /// This function replaces all existing dependencies for a script with the new set, /// ensuring the database reflects the current script analysis results. ///