deprecated function removed, no need for backup
This commit is contained in:
@@ -49,7 +49,7 @@ pub async fn create_steel_context_with_boolean_conversion(
|
||||
}
|
||||
|
||||
/// Execute script with proper boolean handling
|
||||
pub async fn execute_script_with_boolean_support(
|
||||
pub async fn execute_script(
|
||||
script: String,
|
||||
target_type: &str,
|
||||
db_pool: Arc<PgPool>,
|
||||
@@ -92,38 +92,6 @@ pub async fn execute_script_with_boolean_support(
|
||||
}
|
||||
}
|
||||
|
||||
/// Original execute_script function (kept for backward compatibility)
|
||||
/// Note: This doesn't include boolean conversion - use execute_script_with_boolean_support for new code
|
||||
pub fn execute_script(
|
||||
script: String,
|
||||
target_type: &str,
|
||||
db_pool: Arc<PgPool>,
|
||||
context: SteelContext,
|
||||
) -> Result<Value, ExecutionError> {
|
||||
let mut vm = Engine::new();
|
||||
let context = Arc::new(context);
|
||||
|
||||
// Register existing Steel functions
|
||||
register_steel_functions(&mut vm, context.clone());
|
||||
|
||||
// Register all decimal math functions using the steel_decimal crate
|
||||
register_decimal_math_functions(&mut vm);
|
||||
|
||||
// IMPORTANT: Register variables from the context with the Steel VM
|
||||
// This makes the get-var function available with the actual variable values
|
||||
FunctionRegistry::register_variables(&mut vm, context.row_data.clone());
|
||||
|
||||
// Execute script and process results
|
||||
let results = vm.compile_and_run_raw_program(script)
|
||||
.map_err(|e| ExecutionError::RuntimeError(e.to_string()))?;
|
||||
|
||||
// Convert results to target type
|
||||
match target_type {
|
||||
"STRINGS" => process_string_results(results),
|
||||
_ => Err(ExecutionError::UnsupportedType(target_type.into()))
|
||||
}
|
||||
}
|
||||
|
||||
fn register_steel_functions(vm: &mut Engine, context: Arc<SteelContext>) {
|
||||
// Register steel_get_column with row context
|
||||
vm.register_fn("steel_get_column", {
|
||||
|
||||
@@ -136,8 +136,12 @@ pub async fn post_table_data(
|
||||
script_record.script,
|
||||
"STRINGS",
|
||||
Arc::new(db_pool.clone()),
|
||||
context,
|
||||
schema_id,
|
||||
profile_name.clone(),
|
||||
table_name.clone(),
|
||||
string_data_for_scripts.clone(),
|
||||
)
|
||||
.await
|
||||
.map_err(|e| Status::invalid_argument(
|
||||
format!("Script execution failed for '{}': {}", target_column, e)
|
||||
))?;
|
||||
|
||||
@@ -199,8 +199,17 @@ pub async fn put_table_data(
|
||||
db_pool: Arc::new(db_pool.clone()),
|
||||
};
|
||||
|
||||
let script_result = execution::execute_script(script_record.script, "STRINGS", Arc::new(db_pool.clone()), context)
|
||||
.map_err(|e| Status::invalid_argument(format!("Script execution failed for '{}': {}", target_column, e)))?;
|
||||
let script_result = execution::execute_script(
|
||||
script_record.script,
|
||||
"STRINGS",
|
||||
Arc::new(db_pool.clone()),
|
||||
schema_id,
|
||||
profile_name.clone(),
|
||||
table_name.clone(),
|
||||
final_context_data.clone(),
|
||||
)
|
||||
.await
|
||||
.map_err(|e| Status::invalid_argument(format!("Script execution failed for '{}': {}", target_column, e)))?;
|
||||
|
||||
let Value::Strings(mut script_output_vec) = script_result else {
|
||||
return Err(Status::internal("Script must return string values"));
|
||||
|
||||
@@ -39,8 +39,13 @@ async fn discover_steel_decimal_output(
|
||||
script.to_string(),
|
||||
"STRINGS",
|
||||
Arc::new(pool.clone()),
|
||||
context,
|
||||
).map_err(|e| format!("Script execution failed: {}", e))?;
|
||||
1,
|
||||
"test_schema".to_string(),
|
||||
"test_table".to_string(),
|
||||
input_data,
|
||||
)
|
||||
.await
|
||||
.map_err(|e| format!("Script execution failed: {}", e))?;
|
||||
|
||||
let Value::Strings(mut script_output) = script_result else {
|
||||
return Err("Script must return string values".to_string());
|
||||
|
||||
Reference in New Issue
Block a user