From 7bb0613eb62db961e37dfe7bb9b30c2e22efbde8 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 29 Jan 2026 15:00:33 +0000 Subject: [PATCH] Fix: improve SQL single-quote escaping guideline in AI prompt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous guideline only showed possessive examples ('Night''s watch') but didn't emphasize contractions which commonly appear in sample content. This led to syntax errors like "We'll" → syntax error near "ll". Changes: - Add **IMPORTANT** emphasis to make the rule more prominent - Include contraction examples (We''ll, don''t, it''s) - Add explicit reminder to check for apostrophes in sample data https://claude.ai/code/session_01Bss7JauWALKn8gR1dLvw9P --- apps/studio/lib/ai/prompts.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/studio/lib/ai/prompts.ts b/apps/studio/lib/ai/prompts.ts index 9c719bca9ec..cdc5cc17b4a 100644 --- a/apps/studio/lib/ai/prompts.ts +++ b/apps/studio/lib/ai/prompts.ts @@ -234,7 +234,7 @@ export const PG_BEST_PRACTICES = ` ## SQL Style Guidelines - Ensure all generated SQL is valid for Postgres. -- Always escape single quotes within strings using double apostrophes (e.g., \`'Night''s watch'\`). +- **IMPORTANT:** Always escape single quotes within strings using double apostrophes. This includes contractions (e.g., \`'We''ll'\`, \`'don''t'\`, \`'it''s'\`) and possessives (e.g., \`'Night''s watch'\`). When generating sample data or any text content, carefully check for apostrophes and escape them. - Always quote identifiers (table names, column names) with double quotes when they contain uppercase letters (e.g., \`SELECT "locationType" FROM "Locations"\`), are PostgreSQL reserved words (e.g., \`"order"\`, \`"select"\`, \`"table"\`), or have special characters like dashes or spaces (e.g., \`"user-name"\`, \`"created at"\`). PostgreSQL normalizes unquoted identifiers to lowercase and reserves certain keywords. - Terminate each SQL statement with a semicolon (` ;`).