esqueleto-2.4.3-persistent-2.5.patch 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. From 675018c54227ce5db4a91a153092d5f4d06f9af0 Mon Sep 17 00:00:00 2001
  2. From: Paul Rouse <pgr@doynton.org>
  3. Date: Thu, 9 Jun 2016 20:25:34 +0100
  4. Subject: [PATCH 1/3] Changes for persistent-2.5
  5. ---
  6. esqueleto.cabal | 2 +-
  7. src/Database/Esqueleto.hs | 8 ++++----
  8. src/Database/Esqueleto/Internal/Language.hs | 15 +++++----------
  9. src/Database/Esqueleto/Internal/PersistentImport.hs | 12 +++++++++++-
  10. test/Test.hs | 8 ++++----
  11. 5 files changed, 25 insertions(+), 20 deletions(-)
  12. diff --git a/esqueleto.cabal b/esqueleto.cabal
  13. index 65aa237..1768d2d 100644
  14. --- a/esqueleto.cabal
  15. +++ b/esqueleto.cabal
  16. @@ -66,7 +66,7 @@ library
  17. base >= 4.5 && < 4.9
  18. , bytestring
  19. , text >= 0.11 && < 1.3
  20. - , persistent >= 2.1.1.7 && < 2.3
  21. + , persistent >= 2.1.1.7
  22. , transformers >= 0.2
  23. , unordered-containers >= 0.2
  24. , tagged >= 0.2
  25. diff --git a/src/Database/Esqueleto.hs b/src/Database/Esqueleto.hs
  26. index eb135c2..97e3211 100644
  27. --- a/src/Database/Esqueleto.hs
  28. +++ b/src/Database/Esqueleto.hs
  29. @@ -430,8 +430,8 @@ valJ = val . unValue
  30. -- | Synonym for 'Database.Persist.Store.delete' that does not
  31. -- clash with @esqueleto@'s 'delete'.
  32. -deleteKey :: ( PersistStore (PersistEntityBackend val)
  33. - , MonadIO m
  34. - , PersistEntity val )
  35. - => Key val -> ReaderT (PersistEntityBackend val) m ()
  36. +deleteKey :: ( PersistStore backend
  37. + , PersistRecordBackend val backend
  38. + , MonadIO m )
  39. + => Key val -> ReaderT backend m ()
  40. deleteKey = Database.Persist.delete
  41. diff --git a/src/Database/Esqueleto/Internal/Language.hs b/src/Database/Esqueleto/Internal/Language.hs
  42. index fbe88e2..ab18999 100644
  43. --- a/src/Database/Esqueleto/Internal/Language.hs
  44. +++ b/src/Database/Esqueleto/Internal/Language.hs
  45. @@ -74,13 +74,11 @@ class (Functor query, Applicative query, Monad query) =>
  46. -- In the end, 'fromFinish' is called to materialize the
  47. -- @JOIN@.
  48. fromStart
  49. - :: ( PersistEntity a
  50. - , PersistEntityBackend a ~ backend )
  51. + :: PersistRecordBackend a backend
  52. => query (expr (PreprocessedFrom (expr (Entity a))))
  53. -- | (Internal) Same as 'fromStart', but entity may be missing.
  54. fromStartMaybe
  55. - :: ( PersistEntity a
  56. - , PersistEntityBackend a ~ backend )
  57. + :: PersistRecordBackend a backend
  58. => query (expr (PreprocessedFrom (expr (Maybe (Entity a)))))
  59. -- | (Internal) Do a @JOIN@.
  60. fromJoin
  61. @@ -926,8 +924,7 @@ class ToBaseId ent where
  62. -- @
  63. -- person
  64. -- :: ( Esqueleto query expr backend
  65. --- , PersistEntity Person
  66. --- , PersistEntityBackend Person ~ backend
  67. +-- , PersistRecordBackend Person backend
  68. -- ) => expr (Entity Person)
  69. -- (person, blogPost)
  70. -- :: (...) => (expr (Entity Person), expr (Entity BlogPost))
  71. @@ -1054,14 +1051,12 @@ class Esqueleto query expr backend => FromPreprocess query expr backend a where
  72. fromPreprocess :: query (expr (PreprocessedFrom a))
  73. instance ( Esqueleto query expr backend
  74. - , PersistEntity val
  75. - , PersistEntityBackend val ~ backend
  76. + , PersistRecordBackend val backend
  77. ) => FromPreprocess query expr backend (expr (Entity val)) where
  78. fromPreprocess = fromStart
  79. instance ( Esqueleto query expr backend
  80. - , PersistEntity val
  81. - , PersistEntityBackend val ~ backend
  82. + , PersistRecordBackend val backend
  83. ) => FromPreprocess query expr backend (expr (Maybe (Entity val))) where
  84. fromPreprocess = fromStartMaybe
  85. diff --git a/src/Database/Esqueleto/Internal/PersistentImport.hs b/src/Database/Esqueleto/Internal/PersistentImport.hs
  86. index ad193e0..02fbd20 100644
  87. --- a/src/Database/Esqueleto/Internal/PersistentImport.hs
  88. +++ b/src/Database/Esqueleto/Internal/PersistentImport.hs
  89. @@ -1,7 +1,13 @@
  90. +{-# LANGUAGE CPP #-}
  91. +{-# LANGUAGE ConstraintKinds #-}
  92. +{-# LANGUAGE TypeFamilies #-}
  93. -- | Re-export "Database.Persist.Sql" without any clashes with
  94. -- @esqueleto@.
  95. module Database.Esqueleto.Internal.PersistentImport
  96. ( module Database.Persist.Sql
  97. +#if ! MIN_VERSION_persistent(2,5,0)
  98. + , PersistRecordBackend
  99. +#endif
  100. ) where
  101. import Database.Persist.Sql hiding
  102. @@ -10,4 +16,8 @@ import Database.Persist.Sql hiding
  103. , selectKeysList, deleteCascadeWhere, (=.), (+=.), (-=.), (*=.), (/=.)
  104. , (==.), (!=.), (<.), (>.), (<=.), (>=.), (<-.), (/<-.), (||.)
  105. , listToJSON, mapToJSON, getPersistMap, limitOffsetOrder, selectSource
  106. - , update )
  107. + , update, count )
  108. +
  109. +#if ! MIN_VERSION_persistent(2,5,0)
  110. +type PersistRecordBackend record backend = (PersistEntity record, PersistEntityBackend record ~ backend)
  111. +#endif
  112. diff --git a/test/Test.hs b/test/Test.hs
  113. index 80c6784..524bd7c 100644
  114. --- a/test/Test.hs
  115. +++ b/test/Test.hs
  116. @@ -1396,10 +1396,10 @@ main = do
  117. insert' :: ( Functor m
  118. - , PersistStore (PersistEntityBackend val)
  119. - , MonadIO m
  120. - , PersistEntity val )
  121. - => val -> ReaderT (PersistEntityBackend val) m (Entity val)
  122. + , PersistStore backend
  123. + , PersistRecordBackend val backend
  124. + , MonadIO m )
  125. + => val -> ReaderT backend m (Entity val)
  126. insert' v = flip Entity v <$> insert v
  127. --
  128. 2.9.0
  129. From 4c9ecd94f2748be52c50c85ca8ed7314e21b9e82 Mon Sep 17 00:00:00 2001
  130. From: Paul Rouse <pgr@doynton.org>
  131. Date: Thu, 9 Jun 2016 20:29:45 +0100
  132. Subject: [PATCH 2/3] Allow base-4.9 for GHC 8
  133. ---
  134. esqueleto.cabal | 2 +-
  135. 1 file changed, 1 insertion(+), 1 deletion(-)
  136. diff --git a/esqueleto.cabal b/esqueleto.cabal
  137. index 1768d2d..3b9efb9 100644
  138. --- a/esqueleto.cabal
  139. +++ b/esqueleto.cabal
  140. @@ -63,7 +63,7 @@ library
  141. other-modules:
  142. Database.Esqueleto.Internal.PersistentImport
  143. build-depends:
  144. - base >= 4.5 && < 4.9
  145. + base >= 4.5 && < 5
  146. , bytestring
  147. , text >= 0.11 && < 1.3
  148. , persistent >= 2.1.1.7 && < 2.6
  149. --
  150. 2.9.0