diff --git a/esqueleto.cabal b/esqueleto.cabal index 4a7c434..0ab7d11 100644 --- a/esqueleto.cabal +++ b/esqueleto.cabal @@ -47,7 +47,7 @@ library build-depends: base >=4.8 && <5.0 , aeson >=1.0 - , attoparsec >= 0.13 && < 0.14 + , attoparsec >= 0.13 && < 0.15 , blaze-html , bytestring , conduit >=1.3 diff --git a/stack-8.10.yaml b/stack-8.10.yaml index 0728340..82d1ac7 100644 --- a/stack-8.10.yaml +++ b/stack-8.10.yaml @@ -6,6 +6,7 @@ packages: extra-deps: - lift-type-0.1.0.1 +- attoparsec-0.14.1 - persistent-2.13.0.0 - persistent-sqlite-2.13.0.0 - persistent-mysql-2.13.0.0 diff --git a/test/Common/Test.hs b/test/Common/Test.hs index 74469f7..f7c4b09 100644 --- a/test/Common/Test.hs +++ b/test/Common/Test.hs @@ -34,6 +34,8 @@ module Common.Test , cleanUniques , RunDbMonad , Run + , updateRethrowingQuery + , selectRethrowingQuery , p1, p2, p3, p4, p5 , l1, l2, l3 , u1, u2, u3, u4 @@ -2578,3 +2580,17 @@ selectRethrowingQuery query = `catch` \(SomeException e) -> do (text, _) <- renderQuerySelect query liftIO . throwIO . userError $ Text.unpack text <> "\n\n" <> show e + +updateRethrowingQuery + :: + ( MonadUnliftIO m + , PersistEntity val + , BackendCompatible SqlBackend (PersistEntityBackend val) + ) + => (SqlExpr (Entity val) -> SqlQuery ()) + -> SqlWriteT m () +updateRethrowingQuery k = + update k + `catch` \(SomeException e) -> do + (text, _) <- renderQueryUpdate (from k) + liftIO . throwIO . userError $ Text.unpack text <> "\n\n" <> show e diff --git a/test/PostgreSQL/Test.hs b/test/PostgreSQL/Test.hs index d36ebf8..c13cbd9 100644 --- a/test/PostgreSQL/Test.hs +++ b/test/PostgreSQL/Test.hs @@ -1423,6 +1423,26 @@ main = do testJSONInsertions testJSONOperators testLateralQuery + testUpdateWithExperimental + +testUpdateWithExperimental :: Spec +testUpdateWithExperimental = fdescribe "Update/Experimental" $ do + it "works" $ do + run $ do + p1k <- insert p1 + updateRethrowingQuery $ \p -> do + (p0 :& p1) <- Experimental.from $ + Table @Person + `InnerJoin` + Table @Person + `Experimental.on` do + \(p0 :& p1) -> + p0 ^. PersonName ==. p1 ^. PersonName + + set p [ PersonName =. val "asdf" ] + where_ $ p0 ^. PersonName ==. p ^. PersonName + + run, runSilent, runVerbose :: Run runSilent act = runNoLoggingT $ run_worker act