1{-# language DataKinds #-}
5 -- * String concatenation
8 -- * Regular expression operators
9 , (~.), (~*), (!~), (!~*)
11 -- * Standard SQL functions
12 , bitLength, charLength, lower, octetLength, upper
14 -- * PostgreSQL functions
15 , ascii, btrim, chr, convert, convertFrom, convertTo, decode, encode
16 , initcap, left, length, lengthEncoding, lpad, ltrim, md5
17 , pgClientEncoding, quoteIdent, quoteLiteral, quoteNullable, regexpReplace
18 , regexpSplitToArray, repeat, replace, reverse, right, rpad, rtrim
19 , splitPart, strpos, substr, translate
24import Data.Bool ( Bool )
25import Data.Int ( Int32 )
26import Data.Maybe ( Maybe( Nothing, Just ) )
30import Data.ByteString ( ByteString )
33import Rel8.Expr ( Expr )
34import Rel8.Expr.Function ( binaryOperator, function, nullaryFunction )
37import Data.Text (Text)
40-- | The PostgreSQL string concatenation operator.
41(++.) :: Expr Text -> Expr Text -> Expr Text
42(++.) = binaryOperator "||"
46-- * Regular expression operators
48-- See https://www.postgresql.org/docs/9.5/static/functions-matching.html#FUNCTIONS-POSIX-REGEXP
51-- | Matches regular expression, case sensitive
53-- Corresponds to the @~.@ operator.
54(~.) :: Expr Text -> Expr Text -> Expr Bool
55(~.) = binaryOperator "~."
59-- | Matches regular expression, case insensitive
61-- Corresponds to the @~*@ operator.
62(~*) :: Expr Text -> Expr Text -> Expr Bool
63(~*) = binaryOperator "~*"
67-- | Does not match regular expression, case sensitive
69-- Corresponds to the @!~@ operator.
70(!~) :: Expr Text -> Expr Text -> Expr Bool
71(!~) = binaryOperator "!~"
75-- | Does not match regular expression, case insensitive
77-- Corresponds to the @!~*@ operator.
78(!~*) :: Expr Text -> Expr Text -> Expr Bool
79(!~*) = binaryOperator "!~*"
83-- See https://www.postgresql.org/docs/9.5/static/functions-Expr.'PGHtml
85-- * Standard SQL functions
88-- | Corresponds to the @bit_length@ function.
89bitLength :: Expr Text -> Expr Int32
90bitLength = function "bit_length"
93-- | Corresponds to the @char_length@ function.
94charLength :: Expr Text -> Expr Int32
95charLength = function "char_length"
98-- | Corresponds to the @lower@ function.
99lower :: Expr Text -> Expr Text
100lower = function "lower"
103-- | Corresponds to the @octet_length@ function.
104octetLength :: Expr Text -> Expr Int32
105octetLength = function "octet_length"
108-- | Corresponds to the @upper@ function.
109upper :: Expr Text -> Expr Text
110upper = function "upper"
113-- | Corresponds to the @ascii@ function.
114ascii :: Expr Text -> Expr Int32
115ascii = function "ascii"
118-- | Corresponds to the @btrim@ function.
119btrim :: Expr Text -> Maybe (Expr Text) -> Expr Text
120btrim a (Just b) = function "btrim" a b
121btrim a Nothing = function "btrim" a
124-- | Corresponds to the @chr@ function.
125chr :: Expr Int32 -> Expr Text
129-- | Corresponds to the @convert@ function.
130convert :: Expr ByteString -> Expr Text -> Expr Text -> Expr ByteString
131convert = function "convert"
134-- | Corresponds to the @convert_from@ function.
135convertFrom :: Expr ByteString -> Expr Text -> Expr Text
136convertFrom = function "convert_from"
139-- | Corresponds to the @convert_to@ function.
140convertTo :: Expr Text -> Expr Text -> Expr ByteString
141convertTo = function "convert_to"
144-- | Corresponds to the @decode@ function.
145decode :: Expr Text -> Expr Text -> Expr ByteString
146decode = function "decode"
149-- | Corresponds to the @encode@ function.
150encode :: Expr ByteString -> Expr Text -> Expr Text
151encode = function "encode"
154-- | Corresponds to the @initcap@ function.
155initcap :: Expr Text -> Expr Text
156initcap = function "initcap"
159-- | Corresponds to the @left@ function.
160left :: Expr Text -> Expr Int32 -> Expr Text
161left = function "left"
164-- | Corresponds to the @length@ function.
165length :: Expr Text -> Expr Int32
166length = function "length"
169-- | Corresponds to the @length@ function.
170lengthEncoding :: Expr ByteString -> Expr Text -> Expr Int32
171lengthEncoding = function "length"
174-- | Corresponds to the @lpad@ function.
175lpad :: Expr Text -> Expr Int32 -> Maybe (Expr Text) -> Expr Text
176lpad a b (Just c) = function "lpad" a b c
177lpad a b Nothing = function "lpad" a b
180-- | Corresponds to the @ltrim@ function.
181ltrim :: Expr Text -> Maybe (Expr Text) -> Expr Text
182ltrim a (Just b) = function "ltrim" a b
183ltrim a Nothing = function "ltrim" a
186-- | Corresponds to the @md5@ function.
187md5 :: Expr Text -> Expr Text
191-- | Corresponds to the @pg_client_encoding()@ expression.
192pgClientEncoding :: Expr Text
193pgClientEncoding = nullaryFunction "pg_client_encoding"
196-- | Corresponds to the @quote_ident@ function.
197quoteIdent :: Expr Text -> Expr Text
198quoteIdent = function "quote_ident"
201-- | Corresponds to the @quote_literal@ function.
202quoteLiteral :: Expr Text -> Expr Text
203quoteLiteral = function "quote_literal"
206-- | Corresponds to the @quote_nullable@ function.
207quoteNullable :: Expr Text -> Expr Text
208quoteNullable = function "quote_nullable"
211-- | Corresponds to the @regexp_replace@ function.
213 => Expr Text -> Expr Text -> Expr Text -> Maybe (Expr Text) -> Expr Text
214regexpReplace a b c (Just d) = function "regexp_replace" a b c d
215regexpReplace a b c Nothing = function "regexp_replace" a b c
218-- | Corresponds to the @regexp_split_to_array@ function.
219regexpSplitToArray :: ()
220 => Expr Text -> Expr Text -> Maybe (Expr Text) -> Expr [Text]
221regexpSplitToArray a b (Just c) = function "regexp_split_to_array" a b c
222regexpSplitToArray a b Nothing = function "regexp_split_to_array" a b
225-- | Corresponds to the @repeat@ function.
226repeat :: Expr Text -> Expr Int32 -> Expr Text
227repeat = function "repeat"
230-- | Corresponds to the @replace@ function.
231replace :: Expr Text -> Expr Text -> Expr Text -> Expr Text
232replace = function "replace"
235-- | Corresponds to the @reverse@ function.
236reverse :: Expr Text -> Expr Text
237reverse = function "reverse"
240-- | Corresponds to the @right@ function.
241right :: Expr Text -> Expr Int32 -> Expr Text
242right = function "right"
245-- | Corresponds to the @rpad@ function.
246rpad :: Expr Text -> Expr Int32 -> Maybe (Expr Text) -> Expr Text
247rpad a b (Just c) = function "rpad" a b c
248rpad a b Nothing = function "rpad" a b
251-- | Corresponds to the @rtrim@ function.
252rtrim :: Expr Text -> Maybe (Expr Text) -> Expr Text
253rtrim a (Just b) = function "rtrim" a b
254rtrim a Nothing = function "rtrim" a
257-- | Corresponds to the @split_part@ function.
258splitPart :: Expr Text -> Expr Text -> Expr Int32 -> Expr Text
259splitPart = function "split_part"
262-- | Corresponds to the @strpos@ function.
263strpos :: Expr Text -> Expr Text -> Expr Int32
264strpos = function "strpos"
267-- | Corresponds to the @substr@ function.
268substr :: Expr Text -> Expr Int32 -> Maybe (Expr Int32) -> Expr Text
269substr a b (Just c) = function "substr" a b c
270substr a b Nothing = function "substr" a b
273-- | Corresponds to the @translate@ function.
274translate :: Expr Text -> Expr Text -> Expr Text -> Expr Text
275translate = function "translate"
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list