esqueleto 3.5.10.1 → 3.5.10.2
raw patch · 4 files changed
+32/−7 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- changelog.md +13/−0
- esqueleto.cabal +1/−1
- src/Database/Esqueleto/Internal/Internal.hs +13/−3
- test/Common/Test.hs +5/−3
changelog.md view
@@ -1,3 +1,16 @@+3.5.10.2+========+- @parsonsmatt+ - [#376](https://github.com/bitemyapp/esqueleto/pull/376)+ - When using Postgres 15, `LIMIT`, and the `locking` functions, you+ could accidentally construct SQL code like:++ > ... LIMIT 1FOR UPDATE ...++ This parsed on Postgres <15, but the new Postgres parser is more+ strict, and fails to parse. This PR introduces newlines between each+ query chunk, which fixes the issue.+ 3.5.10.1 ======== - @9999years
esqueleto.cabal view
@@ -2,7 +2,7 @@ name: esqueleto -version: 3.5.10.1+version: 3.5.10.2 synopsis: Type-safe EDSL for SQL queries on persistent backends. description: @esqueleto@ is a bare bones, type-safe EDSL for SQL queries that works with unmodified @persistent@ SQL backends. Its language closely resembles SQL, so you don't have to learn new concepts, just new syntax, and it's fairly easy to predict the generated SQL and optimize it for your backend. Most kinds of errors committed when writing SQL are caught as compile-time errors---although it is possible to write type-checked @esqueleto@ queries that fail at runtime. .
src/Database/Esqueleto/Internal/Internal.hs view
@@ -2963,6 +2963,15 @@ flip S.runState firstIdentState $ W.runWriterT $ unQ query+ deleteRepeatedNewlines txt =+ let+ (preNewlines, rest) = TL.break (== '\n') txt+ (_, rest') = TL.break (/= '\n') rest+ in+ if TL.null rest'+ then preNewlines <> "\n"+ else preNewlines <> "\n" <> deleteRepeatedNewlines rest'+ SideData distinctClause fromClauses setClauses@@ -2978,7 +2987,7 @@ -- that no name clashes will occur on subqueries that may -- appear on the expressions below. info = (projectBackend conn, finalIdentState)- in mconcat+ in (\(x, t) -> (TLB.fromLazyText $ deleteRepeatedNewlines $ TL.strip $ TLB.toLazyText x, t)) $ mconcat $ intersperse ("\n", []) [ makeCte info cteClause , makeInsertInto info mode ret , makeSelect info mode distinctClause ret@@ -2992,6 +3001,7 @@ , makeLocking info lockingClause ] + -- | Renders a 'SqlQuery' into a 'Text' value along with the list of -- 'PersistValue's that would be supplied to the database for @?@ placeholders. --@@ -3213,11 +3223,11 @@ makeOrderBy _ [] = mempty makeOrderBy info is = let (tlb, vals) = makeOrderByNoNewline info is- in ("\n" <> tlb, vals)+ in (tlb, vals) makeLimit :: IdentInfo -> LimitClause -> (TLB.Builder, [PersistValue]) makeLimit (conn, _) (Limit ml mo) =- let limitRaw = getConnLimitOffset (v ml, v mo) "\n" conn+ let limitRaw = getConnLimitOffset (v ml, v mo) "" conn v :: Maybe Int64 -> Int v = maybe 0 fromIntegral in (TLB.fromText limitRaw, mempty)
test/Common/Test.hs view
@@ -1652,9 +1652,11 @@ [complex, with1, with2, with3] <- return $ map (toText conn) [complexQuery, queryWithClause1, queryWithClause2, queryWithClause3]- let expected = complex <> "\n" <> syntax- asserting $- (with1, with2, with3) `shouldBe` (expected, expected, expected)+ let expected = complex <> syntax <> "\n"+ asserting $ do+ with1 `shouldBe` expected+ with2 `shouldBe` expected+ with3 `shouldBe` expected itDb "looks sane for ForUpdate" $ sanityCheck ForUpdate "FOR UPDATE" itDb "looks sane for ForUpdateSkipLocked" $ sanityCheck ForUpdateSkipLocked "FOR UPDATE SKIP LOCKED" itDb "looks sane for ForShare" $ sanityCheck ForShare "FOR SHARE"