Skip to content

Commit b0fadac

Browse files
committed
Fixed type inference of delete functions
1 parent 315f50a commit b0fadac

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

IHP/ModelSupport.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ logQuery query parameters time = do
578578
-- DELETE FROM projects WHERE id = '..'
579579
--
580580
-- Use 'deleteRecords' if you want to delete multiple records.
581-
deleteRecord :: forall record id. (?modelContext :: ModelContext, Show id, Table record, HasField "id" record id, ToField id) => record -> IO ()
581+
deleteRecord :: forall record table. (?modelContext :: ModelContext, Show (PrimaryKey table), Table record, HasField "id" record (Id' table), ToField (PrimaryKey table), GetModelByTableName table ~ record, Show (PrimaryKey table), ToField (PrimaryKey table)) => record -> IO ()
582582
deleteRecord record =
583583
deleteRecordById @record (get #id record)
584584
{-# INLINABLE deleteRecord #-}
@@ -589,7 +589,7 @@ deleteRecord record =
589589
-- >>> delete projectId
590590
-- DELETE FROM projects WHERE id = '..'
591591
--
592-
deleteRecordById :: forall record id. (?modelContext :: ModelContext, Show id, Table record, ToField id) => id -> IO ()
592+
deleteRecordById :: forall record table. (?modelContext :: ModelContext, Table record, ToField (PrimaryKey table), Show (PrimaryKey table), record ~ GetModelByTableName table) => Id' table -> IO ()
593593
deleteRecordById id = do
594594
let theQuery = "DELETE FROM " <> tableName @record <> " WHERE id = ?"
595595
let theParameters = PG.Only id
@@ -602,7 +602,7 @@ deleteRecordById id = do
602602
-- >>> let projects :: [Project] = ...
603603
-- >>> deleteRecords projects
604604
-- DELETE FROM projects WHERE id IN (..)
605-
deleteRecords :: forall record id. (?modelContext :: ModelContext, Show id, Table record, HasField "id" record id, ToField id) => [record] -> IO ()
605+
deleteRecords :: forall record table. (?modelContext :: ModelContext, Show (PrimaryKey table), Table record, HasField "id" record (Id' table), ToField (PrimaryKey table), record ~ GetModelByTableName table) => [record] -> IO ()
606606
deleteRecords records =
607607
deleteRecordByIds @record (ids records)
608608
{-# INLINABLE deleteRecords #-}
@@ -613,7 +613,7 @@ deleteRecords records =
613613
-- >>> delete projectIds
614614
-- DELETE FROM projects WHERE id IN ('..')
615615
--
616-
deleteRecordByIds :: forall record id. (?modelContext :: ModelContext, Show id, Table record, ToField id) => [id] -> IO ()
616+
deleteRecordByIds :: forall record table. (?modelContext :: ModelContext, Show (PrimaryKey table), Table record, ToField (PrimaryKey table), record ~ GetModelByTableName table) => [Id' table] -> IO ()
617617
deleteRecordByIds ids = do
618618
let theQuery = "DELETE FROM " <> tableName @record <> " WHERE id IN ?"
619619
let theParameters = (PG.Only (PG.In ids))

0 commit comments

Comments
 (0)