Copyright | (c) Eitan Chatav 2019 |
---|---|
Maintainer | eitan@morphism.tech |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
text functions and operators
Synopsis
- lower :: null 'PGtext --> null 'PGtext
- upper :: null 'PGtext --> null 'PGtext
- charLength :: null 'PGtext --> null 'PGint4
- like :: Operator (null 'PGtext) (null 'PGtext) ('Null 'PGbool)
- ilike :: Operator (null 'PGtext) (null 'PGtext) ('Null 'PGbool)
- replace :: '[null 'PGtext, null 'PGtext, null 'PGtext] ---> null 'PGtext
- strpos :: '[null 'PGtext, null 'PGtext] ---> null 'PGint4
Text Function
lower :: null 'PGtext --> null 'PGtext Source #
>>>
printSQL $ lower "ARRRGGG"
lower((E'ARRRGGG' :: text))
charLength :: null 'PGtext --> null 'PGint4 Source #
>>>
printSQL $ charLength "four"
char_length((E'four' :: text))
like :: Operator (null 'PGtext) (null 'PGtext) ('Null 'PGbool) Source #
The like
expression returns true if the string
matches
the supplied pattern
. If pattern
does not contain percent signs
or underscores, then the pattern only represents the string itself;
in that case like
acts like the equals operator. An underscore (_)
in pattern stands for (matches) any single character; a percent sign (%)
matches any sequence of zero or more characters.
>>>
printSQL $ "abc" `like` "a%"
((E'abc' :: text) LIKE (E'a%' :: text))
ilike :: Operator (null 'PGtext) (null 'PGtext) ('Null 'PGbool) Source #
The key word ILIKE can be used instead of LIKE to make the match case-insensitive according to the active locale.
>>>
printSQL $ "abc" `ilike` "a%"
((E'abc' :: text) ILIKE (E'a%' :: text))
replace :: '[null 'PGtext, null 'PGtext, null 'PGtext] ---> null 'PGtext Source #
Over the string in the first argument, replace all occurrences of the second argument with the third and return the modified string.
>>>
printSQL $ replace ("string" :* "from" *: "to")
replace((E'string' :: text), (E'from' :: text), (E'to' :: text))
strpos :: '[null 'PGtext, null 'PGtext] ---> null 'PGint4 Source #
Determines the location of the substring match using the strpos
function. Returns the 1-based index of the first match, if no
match exists the function returns (0).
>>>
printSQL $ strpos ("string" *: "substring")
strpos((E'string' :: text), (E'substring' :: text))