Compare commits

...

3 Commits

Author SHA1 Message Date
parsonsmatt
2fe75183ce changelog, vbump 2021-05-20 16:02:16 -06:00
parsonsmatt
8430785ae7 test case 2021-05-20 10:30:12 -06:00
parsonsmatt
79b4ade4a5 remove failing test with bad behavior 2021-05-20 10:20:10 -06:00
5 changed files with 23 additions and 22 deletions

View File

@ -1,3 +1,9 @@
3.4.2.2
=======
- @parsonsmatt
- [#255](https://github.com/bitemyapp/esqueleto/pull/255)
- Fix a bug where a composite primary key in a `groupBy` clause would break.
3.4.2.1 3.4.2.1
======= =======
- @parsonsmatt - @parsonsmatt

View File

@ -1,7 +1,7 @@
cabal-version: 1.12 cabal-version: 1.12
name: esqueleto name: esqueleto
version: 3.4.2.1 version: 3.4.2.2
synopsis: Type-safe EDSL for SQL queries on persistent backends. 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. 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.
. .

View File

@ -3003,7 +3003,7 @@ makeGroupBy info (GroupBy fields) = first ("\nGROUP BY " <>) build
match :: SomeValue -> (TLB.Builder, [PersistValue]) match :: SomeValue -> (TLB.Builder, [PersistValue])
match (SomeValue (ERaw _ f)) = f info match (SomeValue (ERaw _ f)) = f info
match (SomeValue (ECompositeKey f)) = (mconcat $ f info, mempty) match (SomeValue (ECompositeKey f)) = (uncommas $ f info, mempty)
match (SomeValue (EAliasedValue i _)) = aliasedValueIdentToRawSql i info match (SomeValue (EAliasedValue i _)) = aliasedValueIdentToRawSql i info
match (SomeValue (EValueReference i i')) = valueReferenceToRawSql i i' info match (SomeValue (EValueReference i i')) = valueReferenceToRawSql i i' info

View File

@ -1466,6 +1466,21 @@ testUpdate run = describe "update" $ do
, (Entity p1k p1, Value 3) , (Entity p1k p1, Value 3)
, (Entity p3k p3, Value 7) ] , (Entity p3k p3, Value 7) ]
it "GROUP BY works with composite primary key" $ run $ do
p1k <- insert $ Point 1 2 "asdf"
p2k <- insert $ Point 2 3 "asdf"
ret <-
selectRethrowingQuery $
from $ \point -> do
where_ $ point ^. PointName ==. val "asdf"
groupBy (point ^. PointId)
pure (point ^. PointId)
liftIO $ do
ret `shouldMatchList`
map Value [p1k, p2k]
it "GROUP BY works with COUNT and InnerJoin" $ run $ do it "GROUP BY works with COUNT and InnerJoin" $ run $ do
l1k <- insert l1 l1k <- insert l1
l3k <- insert l3 l3k <- insert l3

View File

@ -1423,26 +1423,6 @@ main = do
testJSONInsertions testJSONInsertions
testJSONOperators testJSONOperators
testLateralQuery 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 run, runSilent, runVerbose :: Run
runSilent act = runNoLoggingT $ run_worker act runSilent act = runNoLoggingT $ run_worker act