Open tomjaguarpaw opened 2 years ago
What version of PostgreSQL are you on? We somewhat know about this, and afaik it works on newer PostgreSQL versions. On older ones, the fix is to use castTable
with many
. Can you share the Haskell that produced this crashing query?
It fails in every version of Postgres on DB Fiddle. In fact it seems that .f1
syntax for extracting fields of anonymous rows was first supported in v13, yet v13 doesn't support this particular usage (which is a flaw of Postgres I think).
The Haskell is in my post above:
do { q1 <- many (many (values [1 , 2 :: Expr Int16])); q2 <- catListTable q1; catListTable q2 }
Thanks, I missed that this was in GHCI. Can you try changing some many x
to many <$> x
? I'll have a play soon myself
Here is a full program that demonstrates the problem (requiring the hasql
and tmp-postgres
packages). castTable
doesn't seem to help, but I'm not sure I'm using it right.
import Rel8
import Data.Int
import Hasql.Statement
import Hasql.Session
import Hasql.Connection
import Database.Postgres.Temp
import Data.Text (Text)
main = Database.Postgres.Temp.with $ \db -> do
Right conn <- acquire (toConnectionString db)
flip run conn $ statement () $ select $ do
q1 <- castTable <$> many (castTable <$> many (values [1 , 2 :: Expr Int16]))
q2 <- catListTable q1
catListTable q2
Can you try changing some
many x
tomany <$> x
?
That doesn't seem to type check.
Sorry, I meant many x
to many $ castTable <$> x
I made that change, but it still crashes with the same error:
module Main where
import Rel8
import Data.Int
import Hasql.Statement
import Hasql.Session
import Hasql.Connection
import Database.Postgres.Temp
main = Database.Postgres.Temp.with $ \db -> do
Right conn <- acquire (toConnectionString db)
flip run conn $ statement () $ select $ do
q1 <- many (castTable <$> (many (castTable <$> (values [1 , 2 :: Expr Int16]))))
q2 <- catListTable q1
catListTable q2
Is this possibly related to #219?
Consider the following Rel8 program. It produces SQL which crashes.
Is this known/expected?
The ultimate problem is that
.f1
,.f2
, etc. for accessing fields ofROW
s don't really work "through" SELECTs.