-
Notifications
You must be signed in to change notification settings - Fork 33
Description
Hi Eitan,
I’m currently doing a big migration from Squeal 0.5.1.0 → 0.9.1.3 and I love it overall, especially how EncodeParams + DecodeRows gets rid of so much boilerplate.
Problem
I was able to figure out 95% of the work, but I get stuck on turning this query that used to take an arbitrary (generic?) parameter (using ToParam), that can convert to a PostgreSQL type, to a Statement with EncodeParams + DecodeRow. I had to revert and hard-code it to PGtext + Text which broke some of my queries that need PGtimestampz + UTCTime:
Statement: selectContentBy
Usage: getBy
I tried the following without luck:
selectContentBy ::
(ToParam Schemas pgty hsty, SOP.Generic hsty) =>
( TableExpression 'Ungrouped '[] '[] Schemas '[pgty] from ->
TableExpression 'Ungrouped '[] '[] Schemas '[pgty] from
) ->
Statement Schemas hsty Content
selectContentBy clauses = Query encode decode sql
where
encode :: EncodeParams Schemas pgty hsty
encode = aParam
decode = decodeContentWithImage
sql = -- ...as I get this error ❌:
zoomhub/src/ZoomHub/Storage/PostgreSQL/Internal.hs:180:33: error: [GHC-18872]
• Couldn't match kind ‘NullType’ with ‘*’
When matching types
pgty0 :: [*]
'[pgty] :: [NullType]
Expected: EncodeParams
'["public"
::: [ZoomHub.Storage.PostgreSQL.Schema.Schema0.ConfigTable0,
ZoomHub.Storage.PostgreSQL.Schema.Schema3.ContentTable3,
ZoomHub.Storage.PostgreSQL.Schema.Schema0.ImageTable0,
ZoomHub.Storage.PostgreSQL.Schema.Schema0.FlickrTable0]]
'[pgty]
hsty
Actual: EncodeParams Schemas pgty0 hsty
• In the first argument of ‘Query’, namely ‘encode’
In the expression: Query encode decode sql
In an equation for ‘selectContentBy’:
selectContentBy clauses
= Query encode decode sql
where
encode :: EncodeParams Schemas pgty hsty
encode = aParam
decode = decodeContentWithImage
sql = -- ...
I was thinking it might be something obvious you could spot right away. If not, I’m happy to go back and do the work to create a minimally reproducing example.
I appreciate your help 😄