@@ -125,6 +125,7 @@ numeric
125125refcursor
126126record
127127void
128+_record array_record
128129uuid
129130json
130131jsonb
@@ -187,6 +188,35 @@ renderElem byOid elemOid
187188 Nothing -> error ("oid not found: " ++ show elemOid)
188189 Just x -> "Just " ++ bs (typname x)
189190
191+renderTypeInfo :: OidMap -> TypeInfo -> TypeName -> Blaze.Builder
192+renderTypeInfo byOid info name
193+ | typcategory info == 'A' || typname info == "_record" =
194+ let (Just typelem_info) = Map.lookup (typelem info) byOid
195+ (Just typelem_hs_name) = lookup (typname typelem_info) typeNames
196+ in concat
197+ [ "\n"
198+ , bs (hs name), " :: TypeInfo\n"
199+ , bs (hs name), " = Array {\n"
200+ , " typoid = ", fromString (show (typoid info)), ",\n"
201+ , " typcategory = '", Blaze.fromChar (typcategory info), "',\n"
202+ , " typdelim = '", Blaze.fromChar (typdelim info), "',\n"
203+ , " typname = \"", bs (typname info), "\",\n"
204+ , " typelem = ", bs typelem_hs_name, "\n"
205+ , " }\n"
206+ ]
207+ | typcategory info == 'R' = undefined
208+ | otherwise =
209+ concat
210+ [ "\n"
211+ , bs (hs name), " :: TypeInfo\n"
212+ , bs (hs name), " = Basic {\n"
213+ , " typoid = ", fromString (show (typoid info)), ",\n"
214+ , " typcategory = '", Blaze.fromChar (typcategory info), "',\n"
215+ , " typdelim = '", Blaze.fromChar (typdelim info), "',\n"
216+ , " typname = \"", bs (typname info), "\"\n"
217+ , " }\n"
218+ ]
219+
190220-- FIXME: add in any names that we need that we didn't specify, (i.e.
191221-- the "unknowns" in getTypeInfos
192222-- and munge them into a valid haskell identifier if needed.
@@ -237,15 +267,6 @@ staticTypeInfo (Oid x) = case x of
237267 ++ [longstring|
238268 _ -> Nothing
239269|]
240− ++ concat [concat
241− [ "\n"
242− , bs (hs name), " :: TypeInfo\n"
243− , bs (hs name), " = Basic {\n"
244− , " typoid = ", fromString (show typoid), ",\n"
245− , " typcategory = '", Blaze.fromChar typcategory, "',\n"
246− , " typdelim = '", Blaze.fromChar typdelim, "',\n"
247− , " typname = \"", bs typname, "\"\n"
248− , " }\n"
249− ]
270+ ++ concat [ renderTypeInfo byOid typeInfo name
250271 | name <- getNames byName names
251− , let (Just (TypeInfo{..})) = Map.lookup (pg name) byName])
272+ , let (Just typeInfo) = Map.lookup (pg name) byName])