From 9152b237c5fccc11dfcbc1c1bcfc44c0db512cd2 Mon Sep 17 00:00:00 2001 From: HugoCasa Date: Tue, 14 Jan 2025 17:48:12 +0100 Subject: [PATCH] fix: update ms sql template (#5059) --- .../parsers/windmill-parser-sql/src/lib.rs | 10 +++++----- .../apps/editor/component/default-codes.ts | 20 +++++++++---------- .../lib/components/copilot/prompts/edit.yaml | 2 +- .../components/copilot/prompts/editPrompt.ts | 2 +- .../lib/components/copilot/prompts/fix.yaml | 2 +- .../components/copilot/prompts/fixPrompt.ts | 2 +- .../lib/components/copilot/prompts/gen.yaml | 2 +- .../components/copilot/prompts/genPrompt.ts | 2 +- frontend/src/lib/script_helpers.ts | 10 +++++----- 9 files changed, 26 insertions(+), 26 deletions(-) diff --git a/backend/parsers/windmill-parser-sql/src/lib.rs b/backend/parsers/windmill-parser-sql/src/lib.rs index dd6bc2b955..1188542d49 100644 --- a/backend/parsers/windmill-parser-sql/src/lib.rs +++ b/backend/parsers/windmill-parser-sql/src/lib.rs @@ -923,11 +923,11 @@ SELECT ?; #[test] fn test_parse_mssql_sig() -> anyhow::Result<()> { let code = r#" --- @p1 param1 (int) = 3 --- @p2 param2 (varchar) --- @p3 param3 (varchar) -SELECT @p3, @p1; -SELECT @p2; +-- @P1 param1 (int) = 3 +-- @P2 param2 (varchar) +-- @P3 param3 (varchar) +SELECT @P3, @P1; +SELECT @P2; "#; assert_eq!( parse_mssql_sig(code)?, diff --git a/frontend/src/lib/components/apps/editor/component/default-codes.ts b/frontend/src/lib/components/apps/editor/component/default-codes.ts index 2ec82a1040..1758d6dfd4 100644 --- a/frontend/src/lib/components/apps/editor/component/default-codes.ts +++ b/frontend/src/lib/components/apps/editor/component/default-codes.ts @@ -221,12 +221,12 @@ LIMIT @limit OFFSET @offset;`, SELECT * FROM demo WHERE LENGTH(?) = 0 OR CONCAT("ID") ILIKE CONCAT('%', ?, '%') OR CONCAT("NAME") ILIKE CONCAT('%', ?, '%') LIMIT 100 OFFSET 0`, - mssql: `-- @p1 limit (int) --- @p2 offset (int) --- @p3 search (text) -SELECT * FROM Demo WHERE (@p3 = '' OR CONCAT([col1], [col2], [col3]) LIKE '%' + @p3 + '%') + mssql: `-- @P1 limit (int) +-- @P2 offset (int) +-- @P3 search (text) +SELECT * FROM Demo WHERE (@P3 = '' OR CONCAT([col1], [col2], [col3]) LIKE '%' + @P3 + '%') ORDER BY col1 -OFFSET @p2 ROWS FETCH NEXT @p1 ROWS ONLY` +OFFSET @P2 ROWS FETCH NEXT @P1 ROWS ONLY` }, aggridinfinitecomponentee: { deno: `type User = { @@ -341,12 +341,12 @@ LIMIT @limit OFFSET @offset;`, SELECT * FROM demo WHERE LENGTH(?) = 0 OR CONCAT("ID") ILIKE CONCAT('%', ?, '%') OR CONCAT("NAME") ILIKE CONCAT('%', ?, '%') LIMIT 100 OFFSET 0`, - mssql: `-- @p1 limit (int) --- @p2 offset (int) --- @p3 search (text) -SELECT * FROM Demo WHERE (@p3 = '' OR CONCAT([col1], [col2], [col3]) LIKE '%' + @p3 + '%') + mssql: `-- @P1 limit (int) +-- @P2 offset (int) +-- @P3 search (text) +SELECT * FROM Demo WHERE (@P3 = '' OR CONCAT([col1], [col2], [col3]) LIKE '%' + @P3 + '%') ORDER BY col1 -OFFSET @p2 ROWS FETCH NEXT @p1 ROWS ONLY` +OFFSET @P2 ROWS FETCH NEXT @P1 ROWS ONLY` }, textcomponent: { deno: `export async function main() { diff --git a/frontend/src/lib/components/copilot/prompts/edit.yaml b/frontend/src/lib/components/copilot/prompts/edit.yaml index a6e5a5d1a8..1f52898edb 100644 --- a/frontend/src/lib/components/copilot/prompts/edit.yaml +++ b/frontend/src/lib/components/copilot/prompts/edit.yaml @@ -112,7 +112,7 @@ prompts: {code} ``` - Arguments can be obtained directly in the statement with @p1, @p2, etc.. Name the parameters by adding comments before the statement like that: `-- @p1 name1 ({type})` or `-- @p2 name2 ({type}) = default` (one per row) + Arguments can be obtained directly in the statement with @P1, @P2, etc.. Name the parameters by adding comments before the statement like that: `-- @P1 name1 ({type})` or `-- @P2 name2 ({type}) = default` (one per row) My instructions: {description} graphql: diff --git a/frontend/src/lib/components/copilot/prompts/editPrompt.ts b/frontend/src/lib/components/copilot/prompts/editPrompt.ts index 5562af2748..e3f3c06dbf 100644 --- a/frontend/src/lib/components/copilot/prompts/editPrompt.ts +++ b/frontend/src/lib/components/copilot/prompts/editPrompt.ts @@ -26,7 +26,7 @@ export const EDIT_PROMPT = { "prompt": "Here's my snowflake code: \n```sql\n{code}\n```\n\nArguments can be obtained directly in the statement with ?. Name the parameters by adding comments before the statement like that: `-- ? name1 ({type})` or `-- ? name2 ({type}) = default` (one per row)\n\nMy instructions: {description}" }, "mssql": { - "prompt": "Here's my Microsoft SQL Server code: \n```sql\n{code}\n```\n\nArguments can be obtained directly in the statement with @p1, @p2, etc.. Name the parameters by adding comments before the statement like that: `-- @p1 name1 ({type})` or `-- @p2 name2 ({type}) = default` (one per row)\n\nMy instructions: {description}" + "prompt": "Here's my Microsoft SQL Server code: \n```sql\n{code}\n```\n\nArguments can be obtained directly in the statement with @P1, @P2, etc.. Name the parameters by adding comments before the statement like that: `-- @P1 name1 ({type})` or `-- @P2 name2 ({type}) = default` (one per row)\n\nMy instructions: {description}" }, "graphql": { "prompt": "Here's my graphql code: \n```graphql\n{code}\n```\n\nAdd the needed arguments as query parameters.\n\nMy instructions: {description}" diff --git a/frontend/src/lib/components/copilot/prompts/fix.yaml b/frontend/src/lib/components/copilot/prompts/fix.yaml index 2ac40b45e1..ccf138937a 100644 --- a/frontend/src/lib/components/copilot/prompts/fix.yaml +++ b/frontend/src/lib/components/copilot/prompts/fix.yaml @@ -122,7 +122,7 @@ prompts: {code} ``` - Arguments can be obtained directly in the statement with @p1, @p2, etc.. Name the parameters by adding comments before the statement like that: `-- @p1 name1 ({type})` or `-- @p2 name2 ({type}) = default` (one per row) + Arguments can be obtained directly in the statement with @P1, @P2, etc.. Name the parameters by adding comments before the statement like that: `-- @P1 name1 ({type})` or `-- @P2 name2 ({type}) = default` (one per row) I get the following error: {error} Fix my code. diff --git a/frontend/src/lib/components/copilot/prompts/fixPrompt.ts b/frontend/src/lib/components/copilot/prompts/fixPrompt.ts index 2b913abcbc..ea2589e889 100644 --- a/frontend/src/lib/components/copilot/prompts/fixPrompt.ts +++ b/frontend/src/lib/components/copilot/prompts/fixPrompt.ts @@ -26,7 +26,7 @@ export const FIX_PROMPT = { "prompt": "Here's my snowflake code: \n```sql\n{code}\n```\n\nArguments can be obtained directly in the statement with ?. Name the parameters by adding comments before the statement like that: `-- ? name1 ({type})` or `-- ? name2 ({type}) = default` (one per row)\n\nI get the following error: {error}\nFix my code." }, "mssql": { - "prompt": "Here's my Microsoft SQL Server code: \n```sql\n{code}\n```\n\nArguments can be obtained directly in the statement with @p1, @p2, etc.. Name the parameters by adding comments before the statement like that: `-- @p1 name1 ({type})` or `-- @p2 name2 ({type}) = default` (one per row)\n\nI get the following error: {error}\nFix my code." + "prompt": "Here's my Microsoft SQL Server code: \n```sql\n{code}\n```\n\nArguments can be obtained directly in the statement with @P1, @P2, etc.. Name the parameters by adding comments before the statement like that: `-- @P1 name1 ({type})` or `-- @P2 name2 ({type}) = default` (one per row)\n\nI get the following error: {error}\nFix my code." }, "graphql": { "prompt": "Here's my graphql code: \n```graphql\n{code}\n```\n\nAdd the needed arguments as query parameters.\n\nI get the following error: {error}\nFix my code." diff --git a/frontend/src/lib/components/copilot/prompts/gen.yaml b/frontend/src/lib/components/copilot/prompts/gen.yaml index 6913860b78..402b7205f7 100644 --- a/frontend/src/lib/components/copilot/prompts/gen.yaml +++ b/frontend/src/lib/components/copilot/prompts/gen.yaml @@ -78,7 +78,7 @@ prompts: mssql: prompt: |- - You have to write a statement for Microsoft SQL Server. Arguments can be obtained directly in the statement with @p1, @p2, etc.. Name the parameters by adding comments before the statement like that: `-- @p1 name1 ({type})` or `-- @p2 name2 ({type}) = default` (one per row) + You have to write a statement for Microsoft SQL Server. Arguments can be obtained directly in the statement with @P1, @P2, etc.. Name the parameters by adding comments before the statement like that: `-- @P1 name1 ({type})` or `-- @P2 name2 ({type}) = default` (one per row) My instructions: {description} graphql: diff --git a/frontend/src/lib/components/copilot/prompts/genPrompt.ts b/frontend/src/lib/components/copilot/prompts/genPrompt.ts index f8ba685947..898adc721a 100644 --- a/frontend/src/lib/components/copilot/prompts/genPrompt.ts +++ b/frontend/src/lib/components/copilot/prompts/genPrompt.ts @@ -26,7 +26,7 @@ export const GEN_PROMPT = { "prompt": "\nYou have to write a statement for Snowflake. Arguments can be obtained directly in the statement with ?. Name the parameters by adding comments before the statement like that: `-- ? name1 ({type})` or `-- ? name2 ({type}) = default` (one per row)\n\nMy instructions: {description}" }, "mssql": { - "prompt": "\nYou have to write a statement for Microsoft SQL Server. Arguments can be obtained directly in the statement with @p1, @p2, etc.. Name the parameters by adding comments before the statement like that: `-- @p1 name1 ({type})` or `-- @p2 name2 ({type}) = default` (one per row)\n\nMy instructions: {description}" + "prompt": "\nYou have to write a statement for Microsoft SQL Server. Arguments can be obtained directly in the statement with @P1, @P2, etc.. Name the parameters by adding comments before the statement like that: `-- @P1 name1 ({type})` or `-- @P2 name2 ({type}) = default` (one per row)\n\nMy instructions: {description}" }, "graphql": { "prompt": "\nYou have to write a query for GraphQL. Add the needed arguments as query parameters.\n\nMy instructions: {description}" diff --git a/frontend/src/lib/script_helpers.ts b/frontend/src/lib/script_helpers.ts index c54f8540a5..5b99f3cf96 100644 --- a/frontend/src/lib/script_helpers.ts +++ b/frontend/src/lib/script_helpers.ts @@ -278,11 +278,11 @@ UPDATE demo SET col2 = ? WHERE col2 = ?; const MSSQL_INIT_CODE = `-- return_last_result -- to pin the database use '-- database f/your/path' --- @p1 name1 (varchar) = default arg --- @p2 name2 (int) --- @p3 name3 (int) -INSERT INTO demo VALUES (@p1, @p2); -UPDATE demo SET col2 = @p3 WHERE col2 = @p2; +-- @P1 name1 (varchar) = default arg +-- @P2 name2 (int) +-- @P3 name3 (int) +INSERT INTO demo VALUES (@P1, @P2); +UPDATE demo SET col2 = @P3 WHERE col2 = @P2; ` const GRAPHQL_INIT_CODE = `query($name4: String, $name2: Int, $name3: [String]) {