removal of @ syntax as reference from the backend

This commit is contained in:
filipriec
2025-07-25 12:13:51 +02:00
parent 9eb46cb5d3
commit 7437908baf
2 changed files with 9 additions and 33 deletions

View File

@@ -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

View File

@@ -122,7 +122,6 @@ impl DependencyAnalyzer {
/// - `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<Vec<Dependency>, 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<Vec<Dependency>, DependencyError> {
let mut dependencies = Vec::new();