Skip to content

Commit

Permalink
Hide deprecated deleteCascade functions for persistent >= 2.13
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonchinn178 committed Jun 4, 2021
1 parent c1cbda2 commit 99834dd
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions scripts/generate/persistent-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -416,13 +416,15 @@
# DeleteCascade

- name: deleteCascade
condition: '!MIN_VERSION_persistent(2,13,0)'
constraints:
- 'DeleteCascade record SqlBackend'
args:
- 'Key record'
result: '()'

- name: deleteCascadeWhere
condition: '!MIN_VERSION_persistent(2,13,0)'
constraints:
- 'DeleteCascade record SqlBackend'
args:
Expand Down
4 changes: 4 additions & 0 deletions src/Database/Persist/Monad/Shim.hs
Original file line number Diff line number Diff line change
Expand Up @@ -360,17 +360,21 @@ updateWhereCount
=> [Filter record] -> [Update record] -> m Int64
updateWhereCount a1 a2 = runQueryRep $ UpdateWhereCount a1 a2

#if !MIN_VERSION_persistent(2,13,0)
-- | The lifted version of 'Database.Persist.Sql.deleteCascade'
deleteCascade
:: (DeleteCascade record SqlBackend, Typeable record, MonadSqlQuery m)
=> Key record -> m ()
deleteCascade a1 = runQueryRep $ DeleteCascade a1
#endif

#if !MIN_VERSION_persistent(2,13,0)
-- | The lifted version of 'Database.Persist.Sql.deleteCascadeWhere'
deleteCascadeWhere
:: (DeleteCascade record SqlBackend, Typeable record, MonadSqlQuery m)
=> [Filter record] -> m ()
deleteCascadeWhere a1 = runQueryRep $ DeleteCascadeWhere a1
#endif

-- | The lifted version of 'Database.Persist.Sql.parseMigration'
parseMigration
Expand Down
12 changes: 12 additions & 0 deletions src/Database/Persist/Monad/SqlQueryRep.hs
Original file line number Diff line number Diff line change
Expand Up @@ -313,15 +313,19 @@ data SqlQueryRep record a where
:: (PersistRecordBackend record SqlBackend)
=> [Filter record] -> [Update record] -> SqlQueryRep record Int64

#if !MIN_VERSION_persistent(2,13,0)
-- | Constructor corresponding to 'Persist.deleteCascade'
DeleteCascade
:: (DeleteCascade record SqlBackend)
=> Key record -> SqlQueryRep record ()
#endif

#if !MIN_VERSION_persistent(2,13,0)
-- | Constructor corresponding to 'Persist.deleteCascadeWhere'
DeleteCascadeWhere
:: (DeleteCascade record SqlBackend)
=> [Filter record] -> SqlQueryRep record ()
#endif

-- | Constructor corresponding to 'Persist.parseMigration'
ParseMigration
Expand Down Expand Up @@ -507,8 +511,12 @@ instance Typeable record => Show (SqlQueryRep record a) where
DeleteWhere{} -> "DeleteWhere{..}" ++ record
DeleteWhereCount{} -> "DeleteWhereCount{..}" ++ record
UpdateWhereCount{} -> "UpdateWhereCount{..}" ++ record
#if !MIN_VERSION_persistent(2,13,0)
DeleteCascade{} -> "DeleteCascade{..}" ++ record
#endif
#if !MIN_VERSION_persistent(2,13,0)
DeleteCascadeWhere{} -> "DeleteCascadeWhere{..}" ++ record
#endif
ParseMigration{} -> "ParseMigration{..}" ++ record
ParseMigration'{} -> "ParseMigration'{..}" ++ record
PrintMigration{} -> "PrintMigration{..}" ++ record
Expand Down Expand Up @@ -619,8 +627,12 @@ runSqlQueryRep = \case
DeleteWhere a1 -> Persist.deleteWhere a1
DeleteWhereCount a1 -> Persist.deleteWhereCount a1
UpdateWhereCount a1 a2 -> Persist.updateWhereCount a1 a2
#if !MIN_VERSION_persistent(2,13,0)
DeleteCascade a1 -> Persist.deleteCascade a1
#endif
#if !MIN_VERSION_persistent(2,13,0)
DeleteCascadeWhere a1 -> Persist.deleteCascadeWhere a1
#endif
ParseMigration a1 -> Persist.parseMigration a1
ParseMigration' a1 -> Persist.parseMigration' a1
PrintMigration a1 -> Persist.printMigration a1
Expand Down
4 changes: 4 additions & 0 deletions test/Generated.hs
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,12 @@ allSqlQueryRepShowRepresentations =
, show (DeleteWhere undefined :: SqlQueryRep Person ())
, show (DeleteWhereCount undefined :: SqlQueryRep Person Int64)
, show (UpdateWhereCount undefined undefined :: SqlQueryRep Person Int64)
#if !MIN_VERSION_persistent(2,13,0)
, show (DeleteCascade undefined :: SqlQueryRep Person ())
#endif
#if !MIN_VERSION_persistent(2,13,0)
, show (DeleteCascadeWhere undefined :: SqlQueryRep Person ())
#endif
, show (ParseMigration undefined :: SqlQueryRep Void (Either [Text] CautiousMigration))
, show (ParseMigration' undefined :: SqlQueryRep Void CautiousMigration)
, show (PrintMigration undefined :: SqlQueryRep Void ())
Expand Down

0 comments on commit 99834dd

Please sign in to comment.