This commit is contained in:
seb
2026-10-04 16:22:23 +02:00
parent 54398d90f2
commit 9a1c19cf60
2 changed files with 18 additions and 1 deletions

View File

@@ -47,6 +47,16 @@ export default function update(provider) {
const sort = input.sort !== undefined && Number.isInteger(input.sort) ? input.sort : existing.rows[0].sort;
const exclusive = input.exclusive !== undefined ? (Boolean(input.exclusive) ? 1 : 0) : existing.rows[0].exclusive;
if (exclusive && !existing.rows[0].exclusive) {
const multi = await runner.query(
`SELECT article_id FROM articleproperty WHERE property_id = @id GROUP BY article_id HAVING COUNT(*) > 1`,
{ id },
);
if (multi.rows.length > 0) {
throw new Error(`Cannot set property exclusive: ${multi.rows.length} article(s) have multiple values`);
}
}
await runner.query(updateSql, {
id,
companyId,