Fix Postgres prompt seed crashing on CASE WHEN 0/1.
Some checks failed
Deploy Development / deploy (push) Successful in 50s
Test Suite / backend-sqlite (push) Failing after 3s
Test Suite / frontend-build (push) Successful in 15s

SQLite treats integers as booleans; a backend recreate after the API key was added hit that on every start.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Lars 2026-09-07 12:35:22 +02:00
parent 07479f6a9f
commit 9d5befdde9
2 changed files with 4 additions and 1 deletions

View File

@ -307,7 +307,7 @@ def _seed_prompts(conn: Any) -> None:
SET name = ?, description = ?, category = ?, prompt_type = ?, SET name = ?, description = ?, category = ?, prompt_type = ?,
required_feature = ?, is_system_default = 1, default_template = ?, required_feature = ?, is_system_default = 1, default_template = ?,
seed_revision = ?, seed_revision = ?,
template = CASE WHEN ? THEN ? ELSE template END, template = CASE WHEN ? = 1 THEN ? ELSE template END,
updated = datetime('now') updated = datetime('now')
WHERE slug = ? WHERE slug = ?
""", """,

View File

@ -57,6 +57,9 @@ def main() -> None:
expect("'?'" in quoted, "question mark inside quotes kept") expect("'?'" in quoted, "question mark inside quotes kept")
expect(quoted.endswith("%s") or quoted.rstrip().endswith("%s"), "trailing placeholder converted") expect(quoted.endswith("%s") or quoted.rstrip().endswith("%s"), "trailing placeholder converted")
case_sql = adapt_sql("UPDATE t SET x = CASE WHEN ? = 1 THEN ? ELSE x END")
expect("CASE WHEN %s = 1 THEN %s ELSE x END" in case_sql, "boolean-safe case placeholder")
parts = split_sql("CREATE TABLE a (id TEXT); CREATE TABLE b (id TEXT);") parts = split_sql("CREATE TABLE a (id TEXT); CREATE TABLE b (id TEXT);")
expect(parts == ["CREATE TABLE a (id TEXT)", "CREATE TABLE b (id TEXT)"], "split two statements") expect(parts == ["CREATE TABLE a (id TEXT)", "CREATE TABLE b (id TEXT)"], "split two statements")
schema = (ROOT / "schema.sql").read_text(encoding="utf-8") schema = (ROOT / "schema.sql").read_text(encoding="utf-8")