on dev help sign in
functions
4a99bc9Eitan Chatav
squeal-postgresql/src/Squeal/PostgreSQL/Expression.hs+68−2
@@ -58,6 +58,7 @@ module Squeal.PostgreSQL.Expression
58 , unsafeBinaryOp
58 , unsafeBinaryOp
59 , unsafeUnaryOp
59 , unsafeUnaryOp
60 , unsafeFunction
60 , unsafeFunction
61+ , unsafeFunction2
61 , unsafeVariadicFunction
62 , unsafeVariadicFunction
62 , atan2_
63 , atan2_
63 , cast
64 , cast
@@ -222,6 +223,11 @@ module Squeal.PostgreSQL.Expression
222 , fixarray
223 , fixarray
223 , tsvector
224 , tsvector
224 , tsquery
225 , tsquery
226+ , arrayToTSvector
227+ , tsvectorLength
228+ , numnode
229+ , plainToTSquery
230+ , phraseToTSquery
225 -- * Re-export
231 -- * Re-export
226 , (&)
232 , (&)
227 , NP (..)
233 , NP (..)
@@ -646,11 +652,20 @@ unsafeUnaryOp op x = UnsafeExpression $ parenthesized $
646unsafeFunction
652unsafeFunction
647 :: ByteString
653 :: ByteString
648 -- ^ function
654 -- ^ function
649− -> Expression outer grp commons schemas params from (xty)
655+ -> Expression outer grp commons schemas params from xty
650− -> Expression outer grp commons schemas params from (yty)
656+ -> Expression outer grp commons schemas params from yty
651unsafeFunction fun x = UnsafeExpression $
657unsafeFunction fun x = UnsafeExpression $
652 fun <> parenthesized (renderSQL x)
658 fun <> parenthesized (renderSQL x)
653
659
660+unsafeFunction2
661+ :: ByteString
662+ -- ^ function
663+ -> Expression outer grp commons schemas params from ty1
664+ -> Expression outer grp commons schemas params from ty2
665+ -> Expression outer grp commons schemas params from ty
666+unsafeFunction2 fun x1 x2 = UnsafeExpression $
667+ fun <> parenthesized (commaSeparated [renderSQL x1, renderSQL x2])
668+
654-- | Helper for defining variadic functions.
669-- | Helper for defining variadic functions.
655unsafeVariadicFunction
670unsafeVariadicFunction
656 :: SListI elems
671 :: SListI elems
@@ -1625,6 +1640,57 @@ jsonbPretty = unsafeFunction "jsonb_pretty"
1625(<->) :: Operator (nullity 'PGtsquery) (nullity 'PGtsquery) (nullity 'PGtsquery)
1640(<->) :: Operator (nullity 'PGtsquery) (nullity 'PGtsquery) (nullity 'PGtsquery)
1626(<->) = unsafeBinaryOp "<->"
1641(<->) = unsafeBinaryOp "<->"
1627
1642
1643+arrayToTSvector
1644+ :: Expression outer grp commons schemas params from (nullity ('PGvararray ('NotNull 'PGtext)))
1645+ -> Expression outer grp commons schemas params from (nullity 'PGtsvector)
1646+arrayToTSvector = unsafeFunction "array_to_tsvector"
1647+
1648+tsvectorLength
1649+ :: Expression outer grp commons schemas params from (nullity 'PGtsvector)
1650+ -> Expression outer grp commons schemas params from (nullity 'PGint4)
1651+tsvectorLength = unsafeFunction "length"
1652+
1653+numnode
1654+ :: Expression outer grp commons schemas params from (nullity 'PGtsquery)
1655+ -> Expression outer grp commons schemas params from (nullity 'PGint4)
1656+numnode = unsafeFunction "numnode"
1657+
1658+plainToTSquery
1659+ :: Expression outer grp commons schemas params from (nullity 'PGtext)
1660+ -> Expression outer grp commons schemas params from (nullity 'PGtext)
1661+ -> Expression outer grp commons schemas params from (nullity 'PGtsquery)
1662+plainToTSquery = unsafeFunction2 "plainto_tsquery"
1663+
1664+phraseToTSquery
1665+ :: Expression outer grp commons schemas params from (nullity 'PGtext)
1666+ -> Expression outer grp commons schemas params from (nullity 'PGtext)
1667+ -> Expression outer grp commons schemas params from (nullity 'PGtsquery)
1668+phraseToTSquery = unsafeFunction2 "phraseto_tsquery"
1669+
1670+websearchToTSquery
1671+ :: Expression outer grp commons schemas params from (nullity 'PGtext)
1672+ -> Expression outer grp commons schemas params from (nullity 'PGtext)
1673+ -> Expression outer grp commons schemas params from (nullity 'PGtsquery)
1674+websearchToTSquery = unsafeFunction2 "websearch_to_tsquery"
1675+
1676+queryTree
1677+ :: Expression outer grp commons schemas params from (nullity 'PGtsquery)
1678+ -> Expression outer grp commons schemas params from (nullity 'PGtext)
1679+queryTree = unsafeFunction "query_tree"
1680+
1681+toTSquery
1682+ :: Expression outer grp commons schemas params from (nullity 'PGtext)
1683+ -> Expression outer grp commons schemas params from (nullity 'PGtext)
1684+ -> Expression outer grp commons schemas params from (nullity 'PGtsquery)
1685+toTSquery = unsafeFunction2 "to_tsquery"
1686+
1687+toTSvector
1688+ :: ty `In` '[ 'PGtext, 'PGjson, 'PGjsonb]
1689+ => Expression outer grp commons schemas params from (nullity 'PGtext)
1690+ -> Expression outer grp commons schemas params from (nullity ty)
1691+ -> Expression outer grp commons schemas params from (nullity 'PGtsquery)
1692+toTSvector = unsafeFunction2 "to_tsvector"
1693+
1628{-----------------------------------------
1694{-----------------------------------------
1629aggregation
1695aggregation
1630-----------------------------------------}
1696-----------------------------------------}