WORKING STEEL PROPER IMPLEMENTATION finally fixed
This commit is contained in:
@@ -18,18 +18,13 @@ pub enum Value {
|
||||
String(String),
|
||||
}
|
||||
|
||||
// TODO LEAKING MEMORY NEEDS IMIDATE FIX BEFORE PROD
|
||||
pub fn execute_script(
|
||||
script: &str,
|
||||
script: String,
|
||||
target_type: &str,
|
||||
) -> Result<Value, ExecutionError> {
|
||||
let mut vm = Engine::new();
|
||||
|
||||
// SAFETY: THIS IS NEEDS TO BE REDONE
|
||||
// Convert to Box<str> then leak to get 'static lifetime
|
||||
let static_script: &'static str = Box::leak(script.to_string().into_boxed_str());
|
||||
|
||||
let results = vm.compile_and_run_raw_program(static_script)
|
||||
let results = vm.compile_and_run_raw_program(script)
|
||||
.map_err(|e| ExecutionError::RuntimeError(e.to_string()))?;
|
||||
|
||||
let last_result = results.last()
|
||||
|
||||
@@ -114,18 +114,17 @@ pub async fn post_table_data(
|
||||
.await
|
||||
.map_err(|e| Status::internal(format!("Failed to fetch scripts: {}", e)))?;
|
||||
|
||||
// TODO SCRIPT EXECUTION NEEDS REDESING
|
||||
for script_record in scripts {
|
||||
let target_column = script_record.target_column;
|
||||
|
||||
|
||||
// Ensure target column exists in submitted data
|
||||
let user_value = data.get(&target_column)
|
||||
.ok_or_else(|| Status::invalid_argument(
|
||||
format!("Script target column '{}' is required", target_column)
|
||||
))?;
|
||||
|
||||
// Execute the script using your existing implementation
|
||||
let script_result = execution::execute_script(&script_record.script, "STRING")
|
||||
// Execute the script using the owned String
|
||||
let script_result = execution::execute_script(script_record.script.clone(), "STRING") // Changed here
|
||||
.map_err(|e| Status::invalid_argument(
|
||||
format!("Script execution failed for '{}': {}", target_column, e)
|
||||
))?;
|
||||
@@ -137,7 +136,7 @@ pub async fn post_table_data(
|
||||
"Validation failed for '{}'. Expected: '{}', Received: '{}'",
|
||||
target_column, expected_value, user_value
|
||||
)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Prepare SQL parameters
|
||||
|
||||
Reference in New Issue
Block a user