From f38f30a2e2b01c6b41d05a7b79c0f89b06e6e000 Mon Sep 17 00:00:00 2001 From: Shane O'Brien Date: Wed, 3 Nov 2021 11:32:04 +0000 Subject: [PATCH] Add a `castTable` call to `each` If a `Table`'s types line up exactly with Postgres' types, which in they should, then this is a no-op, but if they don't, this makes things a bit safer. In particular, arrays of custom domain types only became possible in Postgres 11. This change makes `some` and `many` somewhat usable on tables containing such types in earlier versions of Postgres. --- src/Rel8/Query/Each.hs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Rel8/Query/Each.hs b/src/Rel8/Query/Each.hs index 930c102..37e37bd 100644 --- a/src/Rel8/Query/Each.hs +++ b/src/Rel8/Query/Each.hs @@ -17,16 +17,14 @@ import Rel8.Query ( Query ) import Rel8.Query.Opaleye ( fromOpaleye ) import Rel8.Schema.Name ( Selects ) import Rel8.Schema.Table ( TableSchema ) -import Rel8.Table.Cols ( fromCols, toCols ) -import Rel8.Table.Opaleye ( table, unpackspec ) +import Rel8.Table.Opaleye ( castTable, table, unpackspec ) -- | Select each row from a table definition. This is equivalent to @FROM -- table@. each :: Selects names exprs => TableSchema names -> Query exprs each = - fmap fromCols . + fmap castTable . fromOpaleye . Opaleye.selectTableExplicit unpackspec . - table . - fmap toCols + table