@@ -16,7 +16,7 @@ module Rel8.Expr.Text
16 , initcap, left, length, lengthEncoding, lpad, ltrim, md5
16 , initcap, left, length, lengthEncoding, lpad, ltrim, md5
17 , pgClientEncoding, quoteIdent, quoteLiteral, quoteNullable, regexpReplace
17 , pgClientEncoding, quoteIdent, quoteLiteral, quoteNullable, regexpReplace
18 , regexpSplitToArray, repeat, replace, reverse, right, rpad, rtrim
18 , regexpSplitToArray, repeat, replace, reverse, right, rpad, rtrim
19− , splitPart, strpos, substr, toAscii, toHex, translate
19+ , splitPart, strpos, substr, translate
@@ -50,24 +50,32 @@ infixr 6 ++.
52-- | Matches regular expression, case sensitive
52-- | Matches regular expression, case sensitive
54+-- Corresponds to the @~.@ operator.
53(~.) :: Expr Text -> Expr Text -> Expr Bool
55(~.) :: Expr Text -> Expr Text -> Expr Bool
54(~.) = binaryOperator "~."
56(~.) = binaryOperator "~."
58-- | Matches regular expression, case insensitive
60-- | Matches regular expression, case insensitive
62+-- Corresponds to the @~*@ operator.
59(~*) :: Expr Text -> Expr Text -> Expr Bool
63(~*) :: Expr Text -> Expr Text -> Expr Bool
60(~*) = binaryOperator "~*"
64(~*) = binaryOperator "~*"
64-- | Does not match regular expression, case sensitive
68-- | Does not match regular expression, case sensitive
70+-- Corresponds to the @!~@ operator.
65(!~) :: Expr Text -> Expr Text -> Expr Bool
71(!~) :: Expr Text -> Expr Text -> Expr Bool
66(!~) = binaryOperator "!~"
72(!~) = binaryOperator "!~"
70-- | Does not match regular expression, case insensitive
76-- | Does not match regular expression, case insensitive
78+-- Corresponds to the @!~*@ operator.
71(!~*) :: Expr Text -> Expr Text -> Expr Bool
79(!~*) :: Expr Text -> Expr Text -> Expr Bool
72(!~*) = binaryOperator "!~*"
80(!~*) = binaryOperator "!~*"
73infix 2 !~*
81infix 2 !~*
@@ -78,164 +86,191 @@ infix 2 !~*
78-- * Standard SQL functions
86-- * Standard SQL functions
89+-- | Corresponds to the @bit_length@ function.
81bitLength :: Expr Text -> Expr Int32
90bitLength :: Expr Text -> Expr Int32
82bitLength = function "bit_length"
91bitLength = function "bit_length"
94+-- | Corresponds to the @char_length@ function.
85charLength :: Expr Text -> Expr Int32
95charLength :: Expr Text -> Expr Int32
86charLength = function "char_length"
96charLength = function "char_length"
99+-- | Corresponds to the @lower@ function.
89lower :: Expr Text -> Expr Text
100lower :: Expr Text -> Expr Text
90lower = function "lower"
101lower = function "lower"
104+-- | Corresponds to the @octet_length@ function.
93octetLength :: Expr Text -> Expr Int32
105octetLength :: Expr Text -> Expr Int32
94octetLength = function "octet_length"
106octetLength = function "octet_length"
109+-- | Corresponds to the @upper@ function.
97upper :: Expr Text -> Expr Text
110upper :: Expr Text -> Expr Text
98upper = function "upper"
111upper = function "upper"
101−-- * PostgreSQL functions
114+-- | Corresponds to the @ascii@ function.
102ascii :: Expr Text -> Expr Int32
115ascii :: Expr Text -> Expr Int32
103ascii = function "ascii"
116ascii = function "ascii"
119+-- | Corresponds to the @btrim@ function.
106btrim :: Expr Text -> Maybe (Expr Text) -> Expr Text
120btrim :: Expr Text -> Maybe (Expr Text) -> Expr Text
107btrim a (Just b) = function "btrim" a b
121btrim a (Just b) = function "btrim" a b
108btrim a Nothing = function "btrim" a
122btrim a Nothing = function "btrim" a
125+-- | Corresponds to the @chr@ function.
111chr :: Expr Int32 -> Expr Text
126chr :: Expr Int32 -> Expr Text
112chr = function "chr"
127chr = function "chr"
130+-- | Corresponds to the @convert@ function.
115convert :: Expr ByteString -> Expr Text -> Expr Text -> Expr ByteString
131convert :: Expr ByteString -> Expr Text -> Expr Text -> Expr ByteString
116convert = function "convert"
132convert = function "convert"
135+-- | Corresponds to the @convert_from@ function.
119convertFrom :: Expr ByteString -> Expr Text -> Expr Text
136convertFrom :: Expr ByteString -> Expr Text -> Expr Text
120convertFrom = function "convert_from"
137convertFrom = function "convert_from"
140+-- | Corresponds to the @convert_to@ function.
123convertTo :: Expr Text -> Expr Text -> Expr ByteString
141convertTo :: Expr Text -> Expr Text -> Expr ByteString
124convertTo = function "convert_to"
142convertTo = function "convert_to"
145+-- | Corresponds to the @decode@ function.
127decode :: Expr Text -> Expr Text -> Expr ByteString
146decode :: Expr Text -> Expr Text -> Expr ByteString
128decode = function "decode"
147decode = function "decode"
150+-- | Corresponds to the @encode@ function.
131encode :: Expr ByteString -> Expr Text -> Expr Text
151encode :: Expr ByteString -> Expr Text -> Expr Text
132encode = function "encode"
152encode = function "encode"
155+-- | Corresponds to the @initcap@ function.
135initcap :: Expr Text -> Expr Text
156initcap :: Expr Text -> Expr Text
136initcap = function "initcap"
157initcap = function "initcap"
160+-- | Corresponds to the @left@ function.
139left :: Expr Text -> Expr Int32 -> Expr Text
161left :: Expr Text -> Expr Int32 -> Expr Text
140left = function "left"
162left = function "left"
165+-- | Corresponds to the @length@ function.
143length :: Expr Text -> Expr Int32
166length :: Expr Text -> Expr Int32
144length = function "length"
167length = function "length"
170+-- | Corresponds to the @length@ function.
147lengthEncoding :: Expr ByteString -> Expr Text -> Expr Int32
171lengthEncoding :: Expr ByteString -> Expr Text -> Expr Int32
148lengthEncoding = function "length"
172lengthEncoding = function "length"
175+-- | Corresponds to the @lpad@ function.
151lpad :: Expr Text -> Expr Int32 -> Maybe (Expr Text) -> Expr Text
176lpad :: Expr Text -> Expr Int32 -> Maybe (Expr Text) -> Expr Text
152lpad a b (Just c) = function "lpad" a b c
177lpad a b (Just c) = function "lpad" a b c
153lpad a b Nothing = function "lpad" a b
178lpad a b Nothing = function "lpad" a b
181+-- | Corresponds to the @ltrim@ function.
156ltrim :: Expr Text -> Maybe (Expr Text) -> Expr Text
182ltrim :: Expr Text -> Maybe (Expr Text) -> Expr Text
157ltrim a (Just b) = function "ltrim" a b
183ltrim a (Just b) = function "ltrim" a b
158ltrim a Nothing = function "ltrim" a
184ltrim a Nothing = function "ltrim" a
187+-- | Corresponds to the @md5@ function.
161md5 :: Expr Text -> Expr Text
188md5 :: Expr Text -> Expr Text
162md5 = function "md5"
189md5 = function "md5"
192+-- | Corresponds to the @pg_client_encoding()@ expression.
165pgClientEncoding :: Expr Text
193pgClientEncoding :: Expr Text
166pgClientEncoding = nullaryFunction "pg_client_encoding"
194pgClientEncoding = nullaryFunction "pg_client_encoding"
197+-- | Corresponds to the @quote_ident@ function.
169quoteIdent :: Expr Text -> Expr Text
198quoteIdent :: Expr Text -> Expr Text
170quoteIdent = function "quote_ident"
199quoteIdent = function "quote_ident"
202+-- | Corresponds to the @quote_literal@ function.
173quoteLiteral :: Expr Text -> Expr Text
203quoteLiteral :: Expr Text -> Expr Text
174quoteLiteral = function "quote_literal"
204quoteLiteral = function "quote_literal"
207+-- | Corresponds to the @quote_nullable@ function.
177quoteNullable :: Expr Text -> Expr Text
208quoteNullable :: Expr Text -> Expr Text
178quoteNullable = function "quote_nullable"
209quoteNullable = function "quote_nullable"
212+-- | Corresponds to the @regexp_replace@ function.
181regexpReplace :: ()
213regexpReplace :: ()
182 => Expr Text -> Expr Text -> Expr Text -> Maybe (Expr Text) -> Expr Text
214 => Expr Text -> Expr Text -> Expr Text -> Maybe (Expr Text) -> Expr Text
183regexpReplace a b c (Just d) = function "regexp_replace" a b c d
215regexpReplace a b c (Just d) = function "regexp_replace" a b c d
184regexpReplace a b c Nothing = function "regexp_replace" a b c
216regexpReplace a b c Nothing = function "regexp_replace" a b c
219+-- | Corresponds to the @regexp_split_to_array@ function.
187regexpSplitToArray :: ()
220regexpSplitToArray :: ()
188 => Expr Text -> Expr Text -> Maybe (Expr Text) -> Expr (Array1D Text)
221 => Expr Text -> Expr Text -> Maybe (Expr Text) -> Expr (Array1D Text)
189regexpSplitToArray a b (Just c) = function "regexp_split_to_array" a b c
222regexpSplitToArray a b (Just c) = function "regexp_split_to_array" a b c
190regexpSplitToArray a b Nothing = function "regexp_split_to_array" a b
223regexpSplitToArray a b Nothing = function "regexp_split_to_array" a b
226+-- | Corresponds to the @repeat@ function.
193repeat :: Expr Text -> Expr Int32 -> Expr Text
227repeat :: Expr Text -> Expr Int32 -> Expr Text
194repeat = function "repeat"
228repeat = function "repeat"
231+-- | Corresponds to the @replace@ function.
197replace :: Expr Text -> Expr Text -> Expr Text -> Expr Text
232replace :: Expr Text -> Expr Text -> Expr Text -> Expr Text
198replace = function "replace"
233replace = function "replace"
236+-- | Corresponds to the @reverse@ function.
201reverse :: Expr Text -> Expr Text
237reverse :: Expr Text -> Expr Text
202reverse = function "reverse"
238reverse = function "reverse"
241+-- | Corresponds to the @right@ function.
205right :: Expr Text -> Expr Int32 -> Expr Text
242right :: Expr Text -> Expr Int32 -> Expr Text
206right = function "right"
243right = function "right"
246+-- | Corresponds to the @rpad@ function.
209rpad :: Expr Text -> Expr Int32 -> Maybe (Expr Text) -> Expr Text
247rpad :: Expr Text -> Expr Int32 -> Maybe (Expr Text) -> Expr Text
210rpad a b (Just c) = function "rpad" a b c
248rpad a b (Just c) = function "rpad" a b c
211rpad a b Nothing = function "rpad" a b
249rpad a b Nothing = function "rpad" a b
252+-- | Corresponds to the @rtrim@ function.
214rtrim :: Expr Text -> Maybe (Expr Text) -> Expr Text
253rtrim :: Expr Text -> Maybe (Expr Text) -> Expr Text
215rtrim a (Just b) = function "rtrim" a b
254rtrim a (Just b) = function "rtrim" a b
216rtrim a Nothing = function "rtrim" a
255rtrim a Nothing = function "rtrim" a
258+-- | Corresponds to the @split_part@ function.
219splitPart :: Expr Text -> Expr Text -> Expr Int32 -> Expr Text
259splitPart :: Expr Text -> Expr Text -> Expr Int32 -> Expr Text
220splitPart = function "split_part"
260splitPart = function "split_part"
263+-- | Corresponds to the @strpos@ function.
223strpos :: Expr Text -> Expr Text -> Expr Int32
264strpos :: Expr Text -> Expr Text -> Expr Int32
224strpos = function "strpos"
265strpos = function "strpos"
268+-- | Corresponds to the @substr@ function.
227substr :: Expr Text -> Expr Int32 -> Maybe (Expr Int32) -> Expr Text
269substr :: Expr Text -> Expr Int32 -> Maybe (Expr Int32) -> Expr Text
228substr a b (Just c) = function "substr" a b c
270substr a b (Just c) = function "substr" a b c
229substr a b Nothing = function "substr" a b
271substr a b Nothing = function "substr" a b
232−toAscii :: Expr Text -> Expr Text -> Expr Text
274+-- | Corresponds to the @translate@ function.
233−toAscii = function "toAscii"
236−toHex :: Expr Int32 -> Expr Text
237−toHex = function "toHex"
240translate :: Expr Text -> Expr Text -> Expr Text -> Expr Text
275translate :: Expr Text -> Expr Text -> Expr Text -> Expr Text
241translate = function "translate"
276translate = function "translate"