@@ -15,6 +15,11 @@ import qualified Data.Map.Strict as Map
15
15
import Data.Text (Text )
16
16
import qualified Data.Text as Text
17
17
import Data.Typeable (Typeable )
18
+ #if MIN_VERSION_esqueleto(3,5,0)
19
+ import qualified Database.Esqueleto.Experimental as E
20
+ #else
21
+ import qualified Database.Esqueleto as E
22
+ #endif
18
23
import Database.Persist.Sql
19
24
( Entity (.. )
20
25
, Migration
@@ -48,6 +53,7 @@ import Control.Monad.IO.Rerunnable (MonadRerunnableIO, rerunnableIO)
48
53
import Database.Persist.Monad
49
54
import Example
50
55
import TestUtils.DB (BackendType (.. ), allBackendTypes )
56
+ import TestUtils.Esqueleto (esqueletoSelect )
51
57
import TestUtils.Match (Match (.. ), (@?~) )
52
58
53
59
tests :: TestTree
@@ -59,6 +65,7 @@ testsWithBackend backendType = testGroup (show backendType)
59
65
[ testWithTransaction backendType
60
66
, testComposability backendType
61
67
, testPersistentAPI backendType
68
+ , testInterop backendType
62
69
]
63
70
64
71
testWithTransaction :: BackendType -> TestTree
@@ -822,6 +829,21 @@ testPersistentAPI backendType = testGroup "Persistent API"
822
829
#endif
823
830
]
824
831
832
+ testInterop :: BackendType -> TestTree
833
+ testInterop backendType = testGroup " Interop with third-party Persistent libraries"
834
+ [ testCase " unsafeLiftSql" $ do
835
+ let alice = person " Alice"
836
+ result <- runTestApp backendType $ do
837
+ insert_ alice
838
+ esqueletoSelect $
839
+ #if MIN_VERSION_esqueleto(3,5,0)
840
+ E. from $ E. table @ Person
841
+ #else
842
+ E. from $ \ p -> return p
843
+ #endif
844
+ result @?= [Entity 1 alice]
845
+ ]
846
+
825
847
{- Persistent helpers -}
826
848
827
849
fromPersistValue' :: PersistField a => PersistValue -> a
0 commit comments