on dev help sign in
encoding instances
commit6cccbf34b0601ccef726313df5d66c3adad5e347 authorEitan Chatav <eitan.chatav@gmail.com> dateWed 16 Jan 2019, 11:15 (8 years ago) parent0bbafcc
1 file changed+19
squeal-postgresql/src/Squeal/PostgreSQL/Binary.hs+19
squeal-postgresql/src/Squeal/PostgreSQL/Binary.hs+19
@@ -306,6 +306,25 @@ instance Aeson.ToJSON x => ToParam (Json x) 'PGjson where
306306instance Aeson.ToJSON x => ToParam (Jsonb x) 'PGjsonb where
307307 toParam = K . Encoding.jsonb_bytes
308308 . Lazy.ByteString.toStrict . Aeson.encode . getJsonb
309+instance (ToNullityParam x ty, ty ~ nullity pg, HasOid pg)
310+ => ToParam (VarArray [x]) ('PGvararray ty) where
311+ toParam = K
312+ . Encoding.array_foldable (oid @pg) (unK . toNullityParam @x @ty)
313+ . getVarArray
314+instance (ToParam x pg, HasOid pg)
315+ => ToParam (VarArray (Vector x)) ('PGvararray ('NotNull pg)) where
316+ toParam = K
317+ . Encoding.array_vector (oid @pg) (unK . toParam @x @pg)
318+ . getVarArray
319+instance (ToParam x pg, HasOid pg)
320+ => ToParam (VarArray (Vector (Maybe x))) ('PGvararray ('Null pg)) where
321+ toParam = K
322+ . Encoding.nullableArray_vector (oid @pg) (unK . toParam @x @pg)
323+ . getVarArray
324+instance (ToFixArray x dims ty, ty ~ nullity pg, HasOid pg)
325+ => ToParam (FixArray x) ('PGfixarray_ dims ty) where
326+ toParam = K . Encoding.array (oid @pg)
327+ . unK . unK . toFixArray @x @dims @ty . getFixArray
309328instance ToArray x ('NotNull ('PGvararray ty))
310329 => ToParam x ('PGvararray ty) where
311330 toParam