From af1cca7d83486aa823f9e0f212e2726fc393b139 Mon Sep 17 00:00:00 2001 From: Eike Kettner Date: Sat, 21 Nov 2020 21:22:12 +0100 Subject: [PATCH] Fix condition for deleting custom field value --- .../src/main/scala/docspell/backend/ops/OCustomFields.scala | 1 + .../scala/docspell/store/records/RCustomFieldValue.scala | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/backend/src/main/scala/docspell/backend/ops/OCustomFields.scala b/modules/backend/src/main/scala/docspell/backend/ops/OCustomFields.scala index 8f6179d0..bdec0212 100644 --- a/modules/backend/src/main/scala/docspell/backend/ops/OCustomFields.scala +++ b/modules/backend/src/main/scala/docspell/backend/ops/OCustomFields.scala @@ -161,6 +161,7 @@ object OCustomFields { val update = for { field <- OptionT(RCustomField.findByIdOrName(in.field, in.collective)) + _ <- OptionT.liftF(logger.debug(s"Field found by '${in.field}': $field")) n <- OptionT.liftF(RCustomFieldValue.deleteValue(field.id, in.item)) } yield n diff --git a/modules/store/src/main/scala/docspell/store/records/RCustomFieldValue.scala b/modules/store/src/main/scala/docspell/store/records/RCustomFieldValue.scala index 53356233..8830dc58 100644 --- a/modules/store/src/main/scala/docspell/store/records/RCustomFieldValue.scala +++ b/modules/store/src/main/scala/docspell/store/records/RCustomFieldValue.scala @@ -60,5 +60,8 @@ object RCustomFieldValue { deleteFrom(table, Columns.itemId.is(item)).update.run def deleteValue(fieldId: Ident, items: NonEmptyList[Ident]): ConnectionIO[Int] = - deleteFrom(table, and(Columns.id.is(fieldId), Columns.itemId.isIn(items))).update.run + deleteFrom( + table, + and(Columns.field.is(fieldId), Columns.itemId.isIn(items)) + ).update.run }