feat: Add saveDraftChanges API endpoint to update product drafts and correctly set codeGammeInit using COALESCE.

This commit is contained in:
Michael committed 2026-03-11 14:45:47 +01:00
1 parent 54a4e7f4d1
commit 6529b2fe15
2 files changed
+21 -16

No files matched your search

+5 -2
View File
@@ -2,7 +2,7 @@
import { db } from "@/db";
import { ventesProduits } from "@/db/schema";
import { eq, and } from "drizzle-orm";
import { eq, and, sql } from "drizzle-orm";
import { z } from "zod";
import { revalidatePath } from "next/cache";
@@ -39,7 +39,10 @@ export async function saveDraftChanges(
return db
.update(ventesProduits)
.set({ codeGamme })
.set({
codeGamme,
codeGammeInit: sql`COALESCE(ventes_produits.code_gamme_init, ventes_produits.code_gamme)`
})
.where(and(...whereClause));
})
);