From 004593539fdfcea8dc6d56cc6ee438cadb62eb43 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Mon, 23 Jan 2023 15:58:23 +0100 Subject: [PATCH] feat: add sql as a valid type in Python --- backend/parsers/windmill-parser-py/src/lib.rs | 1 + frontend/src/lib/components/ScriptBuilder.svelte | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/backend/parsers/windmill-parser-py/src/lib.rs b/backend/parsers/windmill-parser-py/src/lib.rs index 93336ef3b8..bfbbe6d28f 100644 --- a/backend/parsers/windmill-parser-py/src/lib.rs +++ b/backend/parsers/windmill-parser-py/src/lib.rs @@ -104,6 +104,7 @@ pub fn parse_python_signature(code: &str) -> error::Result { "bytes" => Typ::Bytes, "datetime" => Typ::Datetime, "datetime.datetime" => Typ::Datetime, + "Sql" | "sql" => Typ::Sql, _ => Typ::Resource(id), }, _ => Typ::Unknown, diff --git a/frontend/src/lib/components/ScriptBuilder.svelte b/frontend/src/lib/components/ScriptBuilder.svelte index 9e15aba92a..a33a2c2b0b 100644 --- a/frontend/src/lib/components/ScriptBuilder.svelte +++ b/frontend/src/lib/components/ScriptBuilder.svelte @@ -60,9 +60,15 @@ localStorage.removeItem(script.path) script.schema = script.schema ?? emptySchema() - if (!script.schema) { + try { await inferArgs(script.language, script.content, script.schema) + } catch (error) { + sendUserToast( + `Impossible to infer the schema. Assuming this is a script without main function`, + true + ) } + const newHash = await ScriptService.createScript({ workspace: $workspaceStore!, requestBody: { @@ -87,7 +93,13 @@ async function changeStep(step: number) { if (step > 1) { script.schema = script.schema ?? emptySchema() - await inferArgs(script.language, script.content, script.schema) + try { + await inferArgs(script.language, script.content, script.schema) + } catch (error) { + console.info( + 'Impossible to infer the schema. Assuming this is a script without main function' + ) + } } goto(`?step=${step}`) }