@@ -58,6 +58,8 @@ module Squeal.PostgreSQL.Expression
59 -- ** Collections
59 -- ** Collections
61 , cardinality
63 , cardinality
@@ -576,8 +578,58 @@ array
576 :: [Expression outer grp commons schemas params from ty]
578 :: [Expression outer grp commons schemas params from ty]
577 -- ^ array elements
579 -- ^ array elements
578 -> Expression outer grp commons schemas params from (null ('PGvararray ty))
580 -> Expression outer grp commons schemas params from (null ('PGvararray ty))
579−array xs = UnsafeExpression $
581+array xs = UnsafeExpression $ "ARRAY" <>
580− "ARRAY[" <> commaSeparated (renderSQL <$> xs) <> "]"
582+ bracketed (commaSeparated (renderSQL <$> xs))
584+{- | construct a 1-dimensional fixed length array
586+>>> printSQL $ array1 (null_ :* false *: true)
587+ARRAY[NULL, FALSE, TRUE]
589+>>> :type array1 (null_ :* false *: true)
590+array1 (null_ :* false *: true)
598+ (null ('PGfixarray '[3] ('Null 'PGbool)))
601+ :: (n ~ Length tys, SOP.All ((~) ty) tys)
602+ => NP (Expression outer grp commons schemas params from) tys
603+ -> Expression outer grp commons schemas params from (null ('PGfixarray '[n] ty))
604+array1 xs = UnsafeExpression $ "ARRAY" <>
605+ bracketed (renderCommaSeparated renderSQL xs)
607+{- | construct a 1-dimensional fixed length array
609+>>> printSQL $ array2 ((null_ :* false *: true) *: (false :* null_ *: true))
610+ARRAY[[NULL, FALSE, TRUE], [FALSE, NULL, TRUE]]
612+>>> :type array2 ((null_ :* false *: true) *: (false :* null_ *: true))
613+array2 ((null_ :* false *: true) *: (false :* null_ *: true))
621+ (null ('PGfixarray '[2, 3] ('Null 'PGbool)))
624+ :: ( SOP.All ((~) tys) tyss
625+ , SOP.All SOP.SListI tyss
627+ , SOP.All ((~) ty) tys
629+ => NP (NP (Expression outer grp commons schemas params from)) tyss
630+ -> Expression outer grp commons schemas params from (null ('PGfixarray '[n1,n2] ty))
631+array2 xss = UnsafeExpression $ "ARRAY" <>
632+ bracketed (renderCommaSeparatedConstraint @SOP.SListI (bracketed . renderCommaSeparated renderSQL) xss)
582-- | >>> printSQL $ cardinality (array [null_, false, true])
634-- | >>> printSQL $ cardinality (array [null_, false, true])
583-- cardinality(ARRAY[NULL, FALSE, TRUE])
635-- cardinality(ARRAY[NULL, FALSE, TRUE])