on dev help sign in
more renderSQL
commitdbb403c5ef7d73577a5a439640cc733032d88cd9 authorEitan Chatav <eitan.chatav@gmail.com> dateFri 7 Dec 2018, 15:13 (8 years ago) parent16b71bf
4 files changed+71−72
squeal-postgresql/src/Squeal/PostgreSQL/Definition.hs+7−7 squeal-postgresql/src/Squeal/PostgreSQL/Expression.hs+37−32 squeal-postgresql/src/Squeal/PostgreSQL/Query.hs+22−22 squeal-postgresql/src/Squeal/PostgreSQL/Schema.hs+5−11
squeal-postgresql/src/Squeal/PostgreSQL/Definition.hs+7−7
@@ -331,7 +331,7 @@ unique
331331 -- ^ specify subcolumns which together are unique for each row
332332 -> TableConstraintExpression sch tab schemas ('Unique aliases)
333333unique columns = UnsafeTableConstraintExpression $
334− "UNIQUE" <+> parenthesized (commaSeparated (renderAliases columns))
334+ "UNIQUE" <+> parenthesized (renderSQL columns)
335335
336336{-| A `primaryKey` constraint indicates that a column, or group of columns,
337337can be used as a unique identifier for rows in the table.
@@ -366,7 +366,7 @@ primaryKey
366366 -- ^ specify the subcolumns which together form a primary key.
367367 -> TableConstraintExpression sch tab schemas ('PrimaryKey aliases)
368368primaryKey columns = UnsafeTableConstraintExpression $
369− "PRIMARY KEY" <+> parenthesized (commaSeparated (renderAliases columns))
369+ "PRIMARY KEY" <+> parenthesized (renderSQL columns)
370370
371371{-| A `foreignKey` specifies that the values in a column
372372(or a group of columns) must match the values appearing in some row of
@@ -460,9 +460,9 @@ foreignKey
460460 -> TableConstraintExpression sch child schemas
461461 ('ForeignKey columns parent refcolumns)
462462foreignKey keys parent refs ondel onupd = UnsafeTableConstraintExpression $
463− "FOREIGN KEY" <+> parenthesized (commaSeparated (renderAliases keys))
463+ "FOREIGN KEY" <+> parenthesized (renderSQL keys)
464464 <+> "REFERENCES" <+> renderSQL parent
465− <+> parenthesized (commaSeparated (renderAliases refs))
465+ <+> parenthesized (renderSQL refs)
466466 <+> renderSQL ondel
467467 <+> renderSQL onupd
468468
@@ -935,7 +935,7 @@ createTypeComposite ty fields = UnsafeDefinition $
935935 where
936936 renderField :: Aliased (TypeExpression schemas) x -> ByteString
937937 renderField (typ `As` alias) =
938− renderSQL alias <+> renderTypeExpression typ
938+ renderSQL alias <+> renderSQL typ
939939
940940-- | Composite types can also be generated from a Haskell type, for example
941941--
@@ -995,14 +995,14 @@ instance RenderSQL (ColumnTypeExpression schemas ty) where
995995nullable
996996 :: TypeExpression schemas (nullity ty)
997997 -> ColumnTypeExpression schemas ('NoDef :=> 'Null ty)
998−nullable ty = UnsafeColumnTypeExpression $ renderTypeExpression ty <+> "NULL"
998+nullable ty = UnsafeColumnTypeExpression $ renderSQL ty <+> "NULL"
999999
10001000-- | used in `createTable` commands as a column constraint to ensure
10011001-- @NULL@ is not present in a column
10021002notNullable
10031003 :: TypeExpression schemas (nullity ty)
10041004 -> ColumnTypeExpression schemas ('NoDef :=> 'NotNull ty)
1005−notNullable ty = UnsafeColumnTypeExpression $ renderTypeExpression ty <+> "NOT NULL"
1005+notNullable ty = UnsafeColumnTypeExpression $ renderSQL ty <+> "NOT NULL"
10061006
10071007-- | used in `createTable` commands as a column constraint to give a default
10081008default_
squeal-postgresql/src/Squeal/PostgreSQL/Expression.hs+37−32
@@ -31,7 +31,7 @@ Squeal expressions are the atoms used to build statements.
3131
3232module Squeal.PostgreSQL.Expression
3333 ( -- * Expression
34− Expression (UnsafeExpression, renderExpression)
34+ Expression (..)
3535 , HasParameter (parameter)
3636 , param
3737 -- ** Null
@@ -142,8 +142,8 @@ module Squeal.PostgreSQL.Expression
142142 , every, everyDistinct
143143 , max_, maxDistinct, min_, minDistinct
144144 -- * Types
145− , TypeExpression (UnsafeTypeExpression, renderTypeExpression)
146− , PGTyped (pgtype)
145+ , TypeExpression (..)
146+ , PGTyped (..)
147147 , typedef
148148 , typetable
149149 , typeview
@@ -252,7 +252,7 @@ class KnownNat n => HasParameter
252252 -> Expression (commons :=> schemas) params grp from ty
253253 parameter ty = UnsafeExpression $ parenthesized $
254254 "$" <> renderNat @n <+> "::"
255− <+> renderTypeExpression ty
255+ <+> renderSQL ty
256256instance {-# OVERLAPPING #-} HasParameter 1 (ty1:tys) ty1
257257instance {-# OVERLAPPABLE #-} (KnownNat n, HasParameter (n-1) params ty)
258258 => HasParameter n (ty' : params) ty
@@ -357,7 +357,7 @@ null_ = UnsafeExpression "NULL"
357357notNull
358358 :: Expression db rels grouping params ('NotNull ty)
359359 -> Expression db rels grouping params ('Null ty)
360−notNull = UnsafeExpression . renderExpression
360+notNull = UnsafeExpression . renderSQL
361361
362362-- | return the leftmost value which is not NULL
363363--
@@ -371,7 +371,7 @@ coalesce
371371 -> Expression db params grp from ('NotNull ty)
372372coalesce nullxs notNullx = UnsafeExpression $
373373 "COALESCE" <> parenthesized (commaSeparated
374− ((renderExpression <$> nullxs) <> [renderExpression notNullx]))
374+ ((renderSQL <$> nullxs) <> [renderSQL notNullx]))
375375
376376-- | analagous to `Data.Maybe.fromMaybe` using @COALESCE@
377377--
@@ -390,7 +390,7 @@ isNull
390390 :: Expression db params grp from ('Null ty)
391391 -- ^ possibly @NULL@
392392 -> Condition db params grp from
393−isNull x = UnsafeExpression $ renderExpression x <+> "IS NULL"
393+isNull x = UnsafeExpression $ renderSQL x <+> "IS NULL"
394394
395395-- | >>> printSQL $ null_ & isNotNull
396396-- NULL IS NOT NULL
@@ -398,7 +398,7 @@ isNotNull
398398 :: Expression db params grp from ('Null ty)
399399 -- ^ possibly @NULL@
400400 -> Condition db params grp from
401−isNotNull x = UnsafeExpression $ renderExpression x <+> "IS NOT NULL"
401+isNotNull x = UnsafeExpression $ renderSQL x <+> "IS NOT NULL"
402402
403403-- | analagous to `maybe` using @IS NULL@
404404--
@@ -413,7 +413,7 @@ matchNull
413413 -> Expression db params grp from ('Null ty)
414414 -> Expression db params grp from (nullty)
415415matchNull y f x = ifThenElse (isNull x) y
416− (f (UnsafeExpression (renderExpression x)))
416+ (f (UnsafeExpression (renderSQL x)))
417417
418418{-| right inverse to `fromNull`, if its arguments are equal then
419419`nullIf` gives @NULL@.
@@ -430,7 +430,7 @@ nullIf
430430 -- ^ @NULL@ is absent
431431 -> Expression db params grp from ('Null ty)
432432nullIf x y = UnsafeExpression $ "NULL IF" <+> parenthesized
433− (renderExpression x <> ", " <> renderExpression y)
433+ (renderSQL x <> ", " <> renderSQL y)
434434
435435-- | >>> printSQL $ array [null_, false, true]
436436-- ARRAY[NULL, FALSE, TRUE]
@@ -439,7 +439,7 @@ array
439439 -- ^ array elements
440440 -> Expression db params grp from (nullity ('PGvararray ty))
441441array xs = UnsafeExpression $
442− "ARRAY[" <> commaSeparated (renderExpression <$> xs) <> "]"
442+ "ARRAY[" <> commaSeparated (renderSQL <$> xs) <> "]"
443443
444444-- | >>> printSQL $ array [null_, false, true] & index 2
445445-- (ARRAY[NULL, FALSE, TRUE])[2]
@@ -448,7 +448,7 @@ index
448448 -> Expression db params grp from (nullity ('PGvararray ty)) -- ^ array
449449 -> Expression db params grp from (NullifyType ty)
450450index n expr = UnsafeExpression $
451− parenthesized (renderExpression expr) <> "[" <> fromString (show n) <> "]"
451+ parenthesized (renderSQL expr) <> "[" <> fromString (show n) <> "]"
452452
453453instance (KnownSymbol label, label `In` labels) => IsPGlabel label
454454 (Expression db params grp from (nullity ('PGenum labels))) where
@@ -472,7 +472,7 @@ row
472472 -- ^ zero or more expressions for the row field values
473473 -> Expression db params grp from (nullity ('PGcomposite row))
474474row exprs = UnsafeExpression $ "ROW" <> parenthesized
475− (renderCommaSeparated (\ (expr `As` _) -> renderExpression expr) exprs)
475+ (renderCommaSeparated (\ (expr `As` _) -> renderSQL expr) exprs)
476476
477477-- | >>> :{
478478-- type Complex = 'PGcomposite
@@ -494,7 +494,7 @@ field
494494 -> Expression (commons :=> schemas) params grp from ('NotNull ('PGcomposite row))
495495 -> Expression (commons :=> schemas) params grp from ty
496496field td fld expr = UnsafeExpression $
497− parenthesized (renderExpression expr <> "::" <> renderQualifiedAlias td)
497+ parenthesized (renderSQL expr <> "::" <> renderQualifiedAlias td)
498498 <> "." <> renderSQL fld
499499
500500instance Semigroup
@@ -516,7 +516,7 @@ greatest
516516 -- ^ or more
517517 -> Expression db params grp from (nullty)
518518greatest x xs = UnsafeExpression $ "GREATEST("
519− <> commaSeparated (renderExpression <$> (x:xs)) <> ")"
519+ <> commaSeparated (renderSQL <$> (x:xs)) <> ")"
520520
521521-- | >>> printSQL $ least currentTimestamp [null_]
522522-- LEAST(CURRENT_TIMESTAMP, NULL)
@@ -527,7 +527,7 @@ least
527527 -- ^ or more
528528 -> Expression db params grp from (nullty)
529529least x xs = UnsafeExpression $ "LEAST("
530− <> commaSeparated (renderExpression <$> (x:xs)) <> ")"
530+ <> commaSeparated (renderSQL <$> (x:xs)) <> ")"
531531
532532-- | >>> printSQL $ unsafeBinaryOp "OR" true false
533533-- (TRUE OR FALSE)
@@ -538,7 +538,7 @@ unsafeBinaryOp
538538 -> Expression db params grp from (ty1)
539539 -> Expression db params grp from (ty2)
540540unsafeBinaryOp op x y = UnsafeExpression $ parenthesized $
541− renderExpression x <+> op <+> renderExpression y
541+ renderSQL x <+> op <+> renderSQL y
542542
543543-- | >>> printSQL $ unsafeUnaryOp "NOT" true
544544-- (NOT TRUE)
@@ -548,7 +548,7 @@ unsafeUnaryOp
548548 -> Expression db params grp from (ty0)
549549 -> Expression db params grp from (ty1)
550550unsafeUnaryOp op x = UnsafeExpression $ parenthesized $
551− op <+> renderExpression x
551+ op <+> renderSQL x
552552
553553-- | >>> printSQL $ unsafeFunction "f" true
554554-- f(TRUE)
@@ -558,7 +558,7 @@ unsafeFunction
558558 -> Expression db params grp from (xty)
559559 -> Expression db params grp from (yty)
560560unsafeFunction fun x = UnsafeExpression $
561− fun <> parenthesized (renderExpression x)
561+ fun <> parenthesized (renderSQL x)
562562
563563-- | Helper for defining variadic functions.
564564unsafeVariadicFunction
@@ -568,7 +568,7 @@ unsafeVariadicFunction
568568 -> NP (Expression db params grp from) elems
569569 -> Expression db params grp from ret
570570unsafeVariadicFunction fun x = UnsafeExpression $
571− fun <> parenthesized (commaSeparated (hcollapse (hmap (K . renderExpression) x)))
571+ fun <> parenthesized (commaSeparated (hcollapse (hmap (K . renderSQL) x)))
572572
573573instance ty `In` PGNum
574574 => Num (Expression db params grp from (nullity ty)) where
@@ -594,7 +594,7 @@ instance (ty `In` PGNum, ty `In` PGFloating) => Floating
594594 log = unsafeFunction "ln"
595595 sqrt = unsafeFunction "sqrt"
596596 b ** x = UnsafeExpression $
597− "power(" <> renderExpression b <> ", " <> renderExpression x <> ")"
597+ "power(" <> renderSQL b <> ", " <> renderSQL x <> ")"
598598 logBase b y = log y / log b
599599 sin = unsafeFunction "sin"
600600 cos = unsafeFunction "cos"
@@ -624,7 +624,7 @@ atan2_
624624 -- ^ denominator
625625 -> Expression db params grp from (nullity float)
626626atan2_ y x = UnsafeExpression $
627− "atan2(" <> renderExpression y <> ", " <> renderExpression x <> ")"
627+ "atan2(" <> renderSQL y <> ", " <> renderSQL x <> ")"
628628
629629-- When a `cast` is applied to an `Expression` of a known type, it
630630-- represents a run-time type conversion. The cast will succeed only if a
@@ -639,7 +639,7 @@ cast
639639 -- ^ value to convert
640640 -> Expression (commons :=> schemas) params grp from ty1
641641cast ty x = UnsafeExpression $ parenthesized $
642− renderExpression x <+> "::" <+> renderTypeExpression ty
642+ renderSQL x <+> "::" <+> renderSQL ty
643643
644644-- | integer division, truncates the result
645645--
@@ -779,12 +779,12 @@ caseWhenThenElse whenThens else_ = UnsafeExpression $ mconcat
779779 [ "CASE"
780780 , mconcat
781781 [ mconcat
782− [ " WHEN ", renderExpression when_
783− , " THEN ", renderExpression then_
782+ [ " WHEN ", renderSQL when_
783+ , " THEN ", renderSQL then_
784784 ]
785785 | (when_,then_) <- whenThens
786786 ]
787− , " ELSE ", renderExpression else_
787+ , " ELSE ", renderSQL else_
788788 , " END"
789789 ]
790790
@@ -1173,7 +1173,10 @@ unsafeRowFunction
11731173unsafeRowFunction =
11741174 (`appEndo` []) . hcfoldMap (Proxy :: Proxy Top)
11751175 (\(col `As` name) -> Endo $ \xs ->
1176− renderAliasString name : renderExpression col : xs)
1176+ renderAliasString name : renderSQL col : xs)
1177+ where
1178+ renderAliasString :: KnownSymbol alias => Alias alias -> ByteString
1179+ renderAliasString = singleQuotedText . fromString . symbolVal
11771180
11781181-- | Builds a possibly-heterogeneously-typed JSON object out of a variadic
11791182-- argument list. The elements of the argument list must alternate between text
@@ -1381,7 +1384,7 @@ unsafeAggregate
13811384 -> Expression db from 'Ungrouped params (xty)
13821385 -> Expression db from ('Grouped bys) params (yty)
13831386unsafeAggregate fun x = UnsafeExpression $ mconcat
1384− [fun, "(", renderExpression x, ")"]
1387+ [fun, "(", renderSQL x, ")"]
13851388
13861389-- | escape hatch to define aggregate functions over distinct values
13871390unsafeAggregateDistinct
@@ -1389,7 +1392,7 @@ unsafeAggregateDistinct
13891392 -> Expression db from 'Ungrouped params (xty)
13901393 -> Expression db from ('Grouped bys) params (yty)
13911394unsafeAggregateDistinct fun x = UnsafeExpression $ mconcat
1392− [fun, "(DISTINCT ", renderExpression x, ")"]
1395+ [fun, "(DISTINCT ", renderSQL x, ")"]
13931396
13941397-- | >>> :{
13951398-- let
@@ -1626,6 +1629,8 @@ type expressions
16261629newtype TypeExpression (schemas :: SchemasType) (ty :: NullityType)
16271630 = UnsafeTypeExpression { renderTypeExpression :: ByteString }
16281631 deriving (GHC.Generic,Show,Eq,Ord,NFData)
1632+instance RenderSQL (TypeExpression schemas ty) where
1633+ renderSQL = renderTypeExpression
16291634
16301635-- | The enum or composite type in a `Typedef` can be expressed by its alias.
16311636typedef
@@ -1730,17 +1735,17 @@ jsonb = UnsafeTypeExpression "jsonb"
17301735vararray
17311736 :: TypeExpression schemas pg
17321737 -> TypeExpression schemas (nullity ('PGvararray pg))
1733−vararray ty = UnsafeTypeExpression $ renderTypeExpression ty <> "[]"
1738+vararray ty = UnsafeTypeExpression $ renderSQL ty <> "[]"
17341739-- | fixed length array
17351740--
1736−-- >>> renderTypeExpression (fixarray @2 json)
1741+-- >>> renderSQL (fixarray @2 json)
17371742-- "json[2]"
17381743fixarray
17391744 :: forall n schemas nullity pg. KnownNat n
17401745 => TypeExpression schemas pg
17411746 -> TypeExpression schemas (nullity ('PGfixarray n pg))
17421747fixarray ty = UnsafeTypeExpression $
1743− renderTypeExpression ty <> "[" <> renderNat @n <> "]"
1748+ renderSQL ty <> "[" <> renderNat @n <> "]"
17441749
17451750-- | `pgtype` is a demoted version of a `PGType`
17461751class PGTyped schemas (ty :: NullityType) where
squeal-postgresql/src/Squeal/PostgreSQL/Query.hs+22−22
@@ -439,7 +439,7 @@ instance
439439
440440instance RenderSQL (Selection db params grp from row) where
441441 renderSQL = \case
442− List list -> renderCommaSeparated (renderAliasedAs renderExpression) list
442+ List list -> renderCommaSeparated (renderAliasedAs renderSQL) list
443443 Star -> "*"
444444 DotStar tab -> renderSQL tab <> ".*"
445445 Also right left -> renderSQL left <> ", " <> renderSQL right
@@ -519,7 +519,7 @@ values rw rws = UnsafeQuery $ "SELECT * FROM"
519519 renderSQLPart, renderValuePart
520520 :: Aliased (Expression db params 'Ungrouped '[] ) ty -> ByteString
521521 renderSQLPart (_ `As` name) = renderSQL name
522− renderValuePart (value `As` _) = renderExpression value
522+ renderValuePart (value `As` _) = renderSQL value
523523
524524-- | `values_` computes a row value or set of row values
525525-- specified by value expressions.
@@ -604,8 +604,8 @@ renderTableExpression
604604 where
605605 renderWheres = \case
606606 [] -> ""
607− wh:[] -> " WHERE" <+> renderExpression wh
608− wh:whs -> " WHERE" <+> renderExpression (foldr (.&&) wh whs)
607+ wh:[] -> " WHERE" <+> renderSQL wh
608+ wh:whs -> " WHERE" <+> renderSQL (foldr (.&&) wh whs)
609609 renderOrderByClause = \case
610610 [] -> ""
611611 srts -> " ORDER BY"
@@ -695,7 +695,7 @@ unsafeSetOfFunction
695695 -> Expression db params 'Ungrouped '[] ty
696696 -> Query db params row
697697unsafeSetOfFunction fun expr = UnsafeQuery $
698− "SELECT * FROM " <> fun <> "(" <> renderExpression expr <> ")"
698+ "SELECT * FROM " <> fun <> "(" <> renderSQL expr <> ")"
699699
700700-- | Expands the outermost JSON object into a set of key/value pairs.
701701jsonEach
@@ -744,8 +744,8 @@ unsafePopulateFunction
744744 -> Query (commons :=> schemas) params row
745745unsafePopulateFunction fun ty expr = UnsafeQuery $
746746 "SELECT * FROM " <> fun <> "("
747− <> "null::" <> renderTypeExpression ty <> ", "
748− <> renderExpression expr <> ")"
747+ <> "null::" <> renderSQL ty <> ", "
748+ <> renderSQL expr <> ")"
749749
750750-- | Expands the JSON expression to a row whose columns match the record
751751-- type defined by the given table.
@@ -788,12 +788,12 @@ unsafeRecordFunction
788788 -> Query (commons :=> schemas) params record
789789unsafeRecordFunction fun expr types = UnsafeQuery $
790790 "SELECT * FROM " <> fun <> "("
791− <> renderExpression expr <> ")"
791+ <> renderSQL expr <> ")"
792792 <+> "AS" <+> "x" <> parenthesized (renderCommaSeparated renderTy types)
793793 where
794794 renderTy :: Aliased (TypeExpression db) ty -> ByteString
795795 renderTy (ty `As` alias) =
796− renderSQL alias <+> renderTypeExpression ty
796+ renderSQL alias <+> renderSQL ty
797797
798798-- | Builds an arbitrary record from a JSON object.
799799jsonToRecord
@@ -896,7 +896,7 @@ innerJoin
896896 -> FromClause db params (Join left right)
897897innerJoin right on left = UnsafeFromClause $
898898 renderFromClause left <+> "INNER JOIN" <+> renderFromClause right
899− <+> "ON" <+> renderExpression on
899+ <+> "ON" <+> renderSQL on
900900
901901{- | @left & leftOuterJoin right on@. First, an inner join is performed.
902902 Then, for each row in @left@ that does not satisfy the @on@ condition with
@@ -913,7 +913,7 @@ leftOuterJoin
913913 -> FromClause db params (Join left (NullifyFrom right))
914914leftOuterJoin right on left = UnsafeFromClause $
915915 renderFromClause left <+> "LEFT OUTER JOIN" <+> renderFromClause right
916− <+> "ON" <+> renderExpression on
916+ <+> "ON" <+> renderSQL on
917917
918918{- | @left & rightOuterJoin right on@. First, an inner join is performed.
919919 Then, for each row in @right@ that does not satisfy the @on@ condition with
@@ -931,7 +931,7 @@ rightOuterJoin
931931 -> FromClause db params (Join (NullifyFrom left) right)
932932rightOuterJoin right on left = UnsafeFromClause $
933933 renderFromClause left <+> "RIGHT OUTER JOIN" <+> renderFromClause right
934− <+> "ON" <+> renderExpression on
934+ <+> "ON" <+> renderSQL on
935935
936936{- | @left & fullOuterJoin right on@. First, an inner join is performed.
937937 Then, for each row in @left@ that does not satisfy the @on@ condition with
@@ -951,7 +951,7 @@ fullOuterJoin
951951 (Join (NullifyFrom left) (NullifyFrom right))
952952fullOuterJoin right on left = UnsafeFromClause $
953953 renderFromClause left <+> "FULL OUTER JOIN" <+> renderFromClause right
954− <+> "ON" <+> renderExpression on
954+ <+> "ON" <+> renderSQL on
955955
956956{-----------------------------------------
957957Grouping
@@ -1033,7 +1033,7 @@ renderHavingClause = \case
10331033 NoHaving -> ""
10341034 Having [] -> ""
10351035 Having conditions ->
1036− " HAVING" <+> commaSeparated (renderExpression <$> conditions)
1036+ " HAVING" <+> commaSeparated (renderSQL <$> conditions)
10371037
10381038{-----------------------------------------
10391039Sorting
@@ -1071,14 +1071,14 @@ deriving instance Show (SortExpression db params grp from)
10711071-- | Render a `SortExpression`.
10721072renderSortExpression :: SortExpression db params grp from -> ByteString
10731073renderSortExpression = \case
1074− Asc expression -> renderExpression expression <+> "ASC"
1075− Desc expression -> renderExpression expression <+> "DESC"
1076− AscNullsFirst expression -> renderExpression expression
1074+ Asc expression -> renderSQL expression <+> "ASC"
1075+ Desc expression -> renderSQL expression <+> "DESC"
1076+ AscNullsFirst expression -> renderSQL expression
10771077 <+> "ASC NULLS FIRST"
1078− DescNullsFirst expression -> renderExpression expression
1078+ DescNullsFirst expression -> renderSQL expression
10791079 <+> "DESC NULLS FIRST"
1080− AscNullsLast expression -> renderExpression expression <+> "ASC NULLS LAST"
1081− DescNullsLast expression -> renderExpression expression <+> "DESC NULLS LAST"
1080+ AscNullsLast expression -> renderSQL expression <+> "ASC NULLS LAST"
1081+ DescNullsLast expression -> renderSQL expression <+> "DESC NULLS LAST"
10821082
10831083unsafeSubqueryExpression
10841084 :: ByteString
@@ -1086,7 +1086,7 @@ unsafeSubqueryExpression
10861086 -> Query db params '[alias ::: ty]
10871087 -> Expression db params grp from (nullity 'PGbool)
10881088unsafeSubqueryExpression op x q = UnsafeExpression $
1089− renderExpression x <+> op <+> parenthesized (renderQuery q)
1089+ renderSQL x <+> op <+> parenthesized (renderQuery q)
10901090
10911091unsafeRowSubqueryExpression
10921092 :: SListI row
@@ -1095,7 +1095,7 @@ unsafeRowSubqueryExpression
10951095 -> Query db params row
10961096 -> Expression db params grp from (nullity 'PGbool)
10971097unsafeRowSubqueryExpression op xs q = UnsafeExpression $
1098− renderExpression (row xs) <+> op <+> parenthesized (renderQuery q)
1098+ renderSQL (row xs) <+> op <+> parenthesized (renderQuery q)
10991099
11001100-- | The right-hand side is a sub`Query`, which must return exactly one column.
11011101-- The left-hand expression is evaluated and compared to each row of the
squeal-postgresql/src/Squeal/PostgreSQL/Schema.hs+5−11
@@ -68,8 +68,6 @@ module Squeal.PostgreSQL.Schema
6868 , (:::)
6969 , Alias (..)
7070 , IsLabel (..)
71− , renderAliasString
72− , renderAliases
7371 , Aliased (As)
7472 , Aliasable (as)
7573 , renderAliasedAs
@@ -381,18 +379,14 @@ instance aliases ~ '[alias] => IsLabel alias (NP Alias aliases) where
381379instance KnownSymbol alias => RenderSQL (Alias alias) where
382380 renderSQL = doubleQuoted . fromString . symbolVal
383381
384−-- | >>> renderAliasString #ohmahgerd
385−-- "'ohmahgerd'"
386−renderAliasString :: KnownSymbol alias => Alias alias -> ByteString
387−renderAliasString = singleQuotedText . fromString . symbolVal
388−
389382-- | >>> import Generics.SOP (NP(..))
390383-- >>> renderAliases (#jimbob :* #kandi)
391384-- ["\"jimbob\"","\"kandi\""]
392−renderAliases
393− :: All KnownSymbol aliases => NP Alias aliases -> [ByteString]
394−renderAliases = hcollapse
395− . hcmap (Proxy @KnownSymbol) (K . renderSQL)
385+instance All KnownSymbol aliases => RenderSQL (NP Alias aliases) where
386+ renderSQL
387+ = commaSeparated
388+ . hcollapse
389+ . hcmap (Proxy @KnownSymbol) (K . renderSQL)
396390
397391-- | The `As` operator is used to name an expression. `As` is like a demoted
398392-- version of `:::`.