@@ -243,6 +243,28 @@ instance (HasOid pg, ToParam x pg)
243 => ToParam (Vector x) ('PGvararray ('NotNull pg)) where
243 => ToParam (Vector x) ('PGvararray ('NotNull pg)) where
244 toParam = K . Encoding.array_vector
244 toParam = K . Encoding.array_vector
245 (oid @pg) (unK . toParam @x @pg)
245 (oid @pg) (unK . toParam @x @pg)
246+toVector :: (All ((~) x) xs) => NP I xs -> Vector x
249+ I x :* xs -> Vector.singleton x <> toVector xs
253+ , IsProductType hask xs
256+ ) => ToParam hask ('PGfixarray len ('NotNull pg)) where
257+ toParam = K . Encoding.array_vector
258+ (oid @pg) (unK . toParam @x @pg) . toVector . unZ . unSOP . from
262+ , IsProductType hask xs
263+ , All ((~) (Maybe x)) xs
265+ ) => ToParam hask ('PGfixarray len ('Null pg)) where
266+ toParam = K . Encoding.nullableArray_vector
267+ (oid @pg) (unK . toParam @x @pg) . toVector . unZ . unSOP . from
247 ( IsEnumType x
269 ( IsEnumType x
248 , HasDatatypeInfo x
270 , HasDatatypeInfo x
@@ -388,16 +410,39 @@ instance FromValue pg y
388 fromValue = Decoding.array
410 fromValue = Decoding.array
389 (Decoding.dimensionArray Vector.replicateM
411 (Decoding.dimensionArray Vector.replicateM
390 (Decoding.valueArray (fromValue @pg)))
412 (Decoding.valueArray (fromValue @pg)))
391−instance FromValue pg y
413+fromVector
392− => FromValue ('PGfixarray n ('Null pg)) (Vector (Maybe y)) where
414+ :: forall x xs. (All ((~) x) xs, SListI xs)
393− fromValue = Decoding.array
415+ => Vector x
394− (Decoding.dimensionArray Vector.replicateM
416+ -> Decoding.Value (NP I xs)
395− (Decoding.nullableValueArray (fromValue @pg)))
417+fromVector vec = case fromList (Vector.toList vec) of
418+ Nothing -> failure "fromVector: unexpected length"
419+ Just xs -> return $ hcmap (Proxy :: Proxy ((~) x)) (I . unK) xs
421+ ( IsProductType hask ys
396−instance FromValue pg y
424+ , FromValue pg y
397− => FromValue ('PGfixarray n ('NotNull pg)) (Vector y) where
425+ ) => FromValue ('PGfixarray len ('NotNull pg)) hask where
398− fromValue = Decoding.array
426+ fromValue =
428+ vectorValue = Decoding.array
399− (Decoding.dimensionArray Vector.replicateM
429+ (Decoding.dimensionArray Vector.replicateM
400− (Decoding.valueArray (fromValue @pg)))
430+ (Decoding.valueArray (fromValue @pg)))
432+ fmap (to . SOP . Z) (fromVector @y =<< vectorValue)
434+ ( IsProductType hask ys
435+ , All ((~) (Maybe y)) ys
438+ ) => FromValue ('PGfixarray len ('Null pg)) hask where
441+ vectorValue = Decoding.array
442+ (Decoding.dimensionArray Vector.replicateM
443+ (Decoding.nullableValueArray (fromValue @pg)))
445+ fmap (to . SOP . Z) (fromVector @(Maybe y) =<< vectorValue)
402 ( IsEnumType y
447 ( IsEnumType y
403 , HasDatatypeInfo y
448 , HasDatatypeInfo y