Skip to content

Commit

Permalink
Simplify deleteRecordByIds
Browse files Browse the repository at this point in the history
  • Loading branch information
MonaMayrhofer committed Mar 26, 2024
1 parent 3da73f7 commit 84b309b
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions IHP/ModelSupport.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()
Expand Down

0 comments on commit 84b309b

Please sign in to comment.