on dev help sign in
add coalesce
280400eEitan Chatav
squeel-postgresql/src/Squeel/PostgreSQL/Statement.hs+11
@@ -129,6 +129,17 @@ instance Boolean (Expression params tables ('NotNull 'PGBool)) where
129type instance BooleanOf (Expression params tables ty) =
129type instance BooleanOf (Expression params tables ty) =
130 Expression params tables ('NotNull 'PGBool)
130 Expression params tables ('NotNull 'PGBool)
131
131
132+coalesce
133+ :: [Expression params tables ('Null x)]
134+ -> Expression params tables ('NotNull x)
135+ -> Expression params tables ('NotNull x)
136+coalesce nulls notNull = UnsafeExpression $ mconcat
137+ [ "COALESCE("
138+ , ByteString.intercalate ", " $ map renderExpression nulls
139+ , ", ", renderExpression notNull
140+ , ")"
141+ ]
142+
132caseWhenThenElse
143caseWhenThenElse
133 :: [(Expression params tables ('NotNull 'PGBool), Expression params tables ty)]
144 :: [(Expression params tables ('NotNull 'PGBool), Expression params tables ty)]
134 -> Expression params tables ty
145 -> Expression params tables ty