WORKING STEEL PROPER IMPLEMENTATION finally fixed
This commit is contained in:
@@ -18,18 +18,13 @@ pub enum Value {
|
|||||||
String(String),
|
String(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO LEAKING MEMORY NEEDS IMIDATE FIX BEFORE PROD
|
|
||||||
pub fn execute_script(
|
pub fn execute_script(
|
||||||
script: &str,
|
script: String,
|
||||||
target_type: &str,
|
target_type: &str,
|
||||||
) -> Result<Value, ExecutionError> {
|
) -> Result<Value, ExecutionError> {
|
||||||
let mut vm = Engine::new();
|
let mut vm = Engine::new();
|
||||||
|
|
||||||
// SAFETY: THIS IS NEEDS TO BE REDONE
|
let results = vm.compile_and_run_raw_program(script)
|
||||||
// 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)
|
|
||||||
.map_err(|e| ExecutionError::RuntimeError(e.to_string()))?;
|
.map_err(|e| ExecutionError::RuntimeError(e.to_string()))?;
|
||||||
|
|
||||||
let last_result = results.last()
|
let last_result = results.last()
|
||||||
|
|||||||
@@ -114,7 +114,6 @@ pub async fn post_table_data(
|
|||||||
.await
|
.await
|
||||||
.map_err(|e| Status::internal(format!("Failed to fetch scripts: {}", e)))?;
|
.map_err(|e| Status::internal(format!("Failed to fetch scripts: {}", e)))?;
|
||||||
|
|
||||||
// TODO SCRIPT EXECUTION NEEDS REDESING
|
|
||||||
for script_record in scripts {
|
for script_record in scripts {
|
||||||
let target_column = script_record.target_column;
|
let target_column = script_record.target_column;
|
||||||
|
|
||||||
@@ -124,8 +123,8 @@ pub async fn post_table_data(
|
|||||||
format!("Script target column '{}' is required", target_column)
|
format!("Script target column '{}' is required", target_column)
|
||||||
))?;
|
))?;
|
||||||
|
|
||||||
// Execute the script using your existing implementation
|
// Execute the script using the owned String
|
||||||
let script_result = execution::execute_script(&script_record.script, "STRING")
|
let script_result = execution::execute_script(script_record.script.clone(), "STRING") // Changed here
|
||||||
.map_err(|e| Status::invalid_argument(
|
.map_err(|e| Status::invalid_argument(
|
||||||
format!("Script execution failed for '{}': {}", target_column, e)
|
format!("Script execution failed for '{}': {}", target_column, e)
|
||||||
))?;
|
))?;
|
||||||
|
|||||||
Reference in New Issue
Block a user