bitemyapp / esqueleto

New home of Esqueleto, please file issues so we can get things caught up!
BSD 3-Clause "New" or "Revised" License
370 stars 107 forks source link

`GROUP BY` is missing commas for a composite primary key #253

Closed parsonsmatt closed 3 years ago

parsonsmatt commented 3 years ago

Offending code:

makeGroupBy :: IdentInfo -> GroupByClause -> (TLB.Builder, [PersistValue])
makeGroupBy _ (GroupBy []) = (mempty, [])
makeGroupBy info (GroupBy fields) = first ("\nGROUP BY " <>) build
  where
    build :: (TLB.Builder, [PersistValue])
    build = uncommas' $ map match fields

    match :: SomeValue -> (TLB.Builder, [PersistValue])
    match (SomeValue (ERaw _ f)) = f info
    match (SomeValue (ECompositeKey f)) = (mconcat $ f info, mempty)
    match (SomeValue (EAliasedValue i _)) = aliasedValueIdentToRawSql i info
    match (SomeValue (EValueReference i i')) = valueReferenceToRawSql i i' info

The match (SomeValue (ECompositeKey f)) = (mconcat $ f info, mempty) appears to be the problem. Need something to intersperse commans in there.

belevy commented 3 years ago

Does this work correctly now? Can we close this issue?

parsonsmatt commented 3 years ago

Oh, yeah - I fixed that for a prior PR and I think you said the changes you made also fixed it. There's a test now for it.