From 84b309b2a49defb4d9eeb7d0b93a9eed22ba590f Mon Sep 17 00:00:00 2001 From: Mona Mayrhofer Date: Tue, 26 Mar 2024 18:24:31 +0100 Subject: [PATCH] Simplify deleteRecordByIds --- IHP/ModelSupport.hs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/IHP/ModelSupport.hs b/IHP/ModelSupport.hs index 6ddc11470..efd7e90b7 100644 --- a/IHP/ModelSupport.hs +++ b/IHP/ModelSupport.hs @@ -689,11 +689,8 @@ deleteRecords records = -- DELETE FROM projects WHERE id IN ('..') -- deleteRecordByIds :: forall record table. (?modelContext :: ModelContext, Show (PrimaryKey table), Table record, GetTableName record ~ table, record ~ GetModelByTableName table) => [Id' table] -> IO () -deleteRecordByIds [] = do - pure () -- If there are no ids, we wouldn't even know the pkCols, so we just don't do anything, as nothing happens anyways -deleteRecordByIds ids@(firstId : _) = do +deleteRecordByIds ids = do let theQuery = "DELETE FROM " <> tableNameByteString @record <> " WHERE " <> (primaryKeyConditionColumnSelector @record) <> " IN ?" - let theParameters = PG.Only $ PG.In $ map (primaryKeyConditionForId @record) ids sqlExec (PG.Query $! theQuery) theParameters pure ()