From b2608a863580f0003bf13ee81f33a21d833abcca Mon Sep 17 00:00:00 2001 From: Tony AVERTY Date: Thu, 22 Oct 2026 13:08:04 +0200 Subject: [PATCH] =?UTF-8?q?fix(projects):=20upsert=20des=20mod=C3=A8les=20?= =?UTF-8?q?de=20mail=20dans=20la=20forme=20commune=20aux=20deux=20moteurs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/projects.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/projects.js b/src/projects.js index 51ddaef..4ebbcef 100644 --- a/src/projects.js +++ b/src/projects.js @@ -107,8 +107,8 @@ export async function getTemplate(db, projectId, kind, { validatedOnly = false } export async function saveTemplate(db, projectId, kind, { subject = '', subjectB = null, body, status = 'draft' }) { if (!TEMPLATE_KINDS.includes(kind)) throw new HttpError(400, 'Type de modèle inconnu'); await db.prepare(`INSERT INTO templates(project_id, kind, subject, subject_b, body, status, updated_at) VALUES(?, ?, ?, ?, ?, ?, ?) - ON DUPLICATE KEY UPDATE subject = VALUES(subject), subject_b = VALUES(subject_b), - body = VALUES(body), status = VALUES(status), updated_at = VALUES(updated_at)`) + ON CONFLICT(project_id, kind) DO UPDATE SET subject = excluded.subject, subject_b = excluded.subject_b, + body = excluded.body, status = excluded.status, updated_at = excluded.updated_at`) .run(projectId, kind, subject, kind === 'initial' ? (subjectB || null) : null, body, status, now()); }