From 2c4abb0bbc6ba5d681cabec4f11dfa178dcca1ab Mon Sep 17 00:00:00 2001 From: filipriec Date: Tue, 11 Mar 2025 13:02:58 +0100 Subject: [PATCH] working setup where steel script works, with example --- server/src/steel/docs/pushing_using_steel.txt | 39 +++++++++++++++++++ .../handlers/post_table_script.rs | 10 +++-- 2 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 server/src/steel/docs/pushing_using_steel.txt diff --git a/server/src/steel/docs/pushing_using_steel.txt b/server/src/steel/docs/pushing_using_steel.txt new file mode 100644 index 0000000..50652d6 --- /dev/null +++ b/server/src/steel/docs/pushing_using_steel.txt @@ -0,0 +1,39 @@ +❯ grpcurl -plaintext -d '{ + "table_definition_id": 16, + "target_column": "idea_name", + "script": "(begin (define idea_name \"aaa\") idea_name)", + "description": "Set idea_name to Awesome Idea" +}' localhost:50051 multieko2.table_script.TableScript/PostTableScript +{ + "id": "7" +} +❯ grpcurl -plaintext -d '{ + "profile_name": "script", + "table_name": "2025_berry", + "data": { + "idea_name": "sdfsfs", + "category": "Technology", + "impact_level": "High", + "is_feasible": "true", + "last_updated": "2025-03-11T12:34:56Z" + } +}' localhost:50051 multieko2.tables_data.TablesData/PostTableData +ERROR: + Code: InvalidArgument + Message: Validation failed for 'idea_name'. Expected: 'aaa', Received: 'sdfsfs' +❯ grpcurl -plaintext -d '{ + "profile_name": "script", + "table_name": "2025_berry", + "data": { + "idea_name": "aaa", + "category": "Technology", + "impact_level": "High", + "is_feasible": "true", + "last_updated": "2025-03-11T12:34:56Z" + } +}' localhost:50051 multieko2.tables_data.TablesData/PostTableData +{ + "success": true, + "message": "Data inserted successfully", + "insertedId": "1" +} diff --git a/server/src/table_script/handlers/post_table_script.rs b/server/src/table_script/handlers/post_table_script.rs index 348b44d..1fad4ad 100644 --- a/server/src/table_script/handlers/post_table_script.rs +++ b/server/src/table_script/handlers/post_table_script.rs @@ -61,17 +61,19 @@ pub async fn post_table_script( ) .map_err(|e| Status::invalid_argument(e))?; - // Store script in database with column type + + // Store script in database with column type and profile_id let script_record = sqlx::query!( r#"INSERT INTO table_scripts - (table_definitions_id, target_column, target_column_type, script, description) - VALUES ($1, $2, $3, $4, $5) + (table_definitions_id, target_column, target_column_type, script, description, profile_id) + VALUES ($1, $2, $3, $4, $5, $6) RETURNING id"#, request.table_definition_id, request.target_column, column_type, request.script, - request.description + request.description, + table_def.profile_id // Use the profile_id from table_definitions ) .fetch_one(db_pool) .await