{-# language DataKinds #-}
{-# language OverloadedStrings #-}
module Rel8.Expr.Text
(
(++.)
, (~.), (~*), (!~), (!~*)
, bitLength, charLength, lower, octetLength, upper
, ascii, btrim, chr, convert, convertFrom, convertTo, decode, encode
, initcap, left, length, lengthEncoding, lpad, ltrim, md5
, pgClientEncoding, quoteIdent, quoteLiteral, quoteNullable, regexpReplace
, regexpSplitToArray, repeat, replace, reverse, right, rpad, rtrim
, splitPart, strpos, substr, translate
, like, ilike
)
where
import Data.Bool ( Bool )
import Data.Int ( Int32 )
import Data.Maybe ( Maybe( Nothing, Just ) )
import Prelude ( flip )
import Data.ByteString ( ByteString )
import qualified Opaleye.Internal.HaskellDB.PrimQuery as Opaleye
import Rel8.Expr ( Expr )
import Rel8.Expr.Function (binaryOperator, function)
import Rel8.Expr.Opaleye (zipPrimExprsWith)
import Data.Text (Text)
(++.) :: Expr Text -> Expr Text -> Expr Text
++. :: Expr Text -> Expr Text -> Expr Text
(++.) = QualifiedName -> Expr Text -> Expr Text -> Expr Text
forall c a b.
Sql DBType c =>
QualifiedName -> Expr a -> Expr b -> Expr c
binaryOperator QualifiedName
"||"
infixr 6 ++.
(~.) :: Expr Text -> Expr Text -> Expr Bool
~. :: Expr Text -> Expr Text -> Expr Bool
(~.) = QualifiedName -> Expr Text -> Expr Text -> Expr Bool
forall c a b.
Sql DBType c =>
QualifiedName -> Expr a -> Expr b -> Expr c
binaryOperator QualifiedName
"~."
infix 2 ~.
(~*) :: Expr Text -> Expr Text -> Expr Bool
~* :: Expr Text -> Expr Text -> Expr Bool
(~*) = QualifiedName -> Expr Text -> Expr Text -> Expr Bool
forall c a b.
Sql DBType c =>
QualifiedName -> Expr a -> Expr b -> Expr c
binaryOperator QualifiedName
"~*"
infix 2 ~*
(!~) :: Expr Text -> Expr Text -> Expr Bool
!~ :: Expr Text -> Expr Text -> Expr Bool
(!~) = QualifiedName -> Expr Text -> Expr Text -> Expr Bool
forall c a b.
Sql DBType c =>
QualifiedName -> Expr a -> Expr b -> Expr c
binaryOperator QualifiedName
"!~"
infix 2 !~
(!~*) :: Expr Text -> Expr Text -> Expr Bool
!~* :: Expr Text -> Expr Text -> Expr Bool
(!~*) = QualifiedName -> Expr Text -> Expr Text -> Expr Bool
forall c a b.
Sql DBType c =>
QualifiedName -> Expr a -> Expr b -> Expr c
binaryOperator QualifiedName
"!~*"
infix 2 !~*
bitLength :: Expr Text -> Expr Int32
bitLength :: Expr Text -> Expr Int32
bitLength = QualifiedName -> Expr Text -> Expr Int32
forall arguments a.
(Arguments arguments, Sql DBType a) =>
QualifiedName -> arguments -> Expr a
function QualifiedName
"bit_length"
charLength :: Expr Text -> Expr Int32
charLength :: Expr Text -> Expr Int32
charLength = QualifiedName -> Expr Text -> Expr Int32
forall arguments a.
(Arguments arguments, Sql DBType a) =>
QualifiedName -> arguments -> Expr a
function QualifiedName
"char_length"
lower :: Expr Text -> Expr Text
lower :: Expr Text -> Expr Text
lower = QualifiedName -> Expr Text -> Expr Text
forall arguments a.
(Arguments arguments, Sql DBType a) =>
QualifiedName -> arguments -> Expr a
function QualifiedName
"lower"
octetLength :: Expr Text -> Expr Int32
octetLength :: Expr Text -> Expr Int32
octetLength = QualifiedName -> Expr Text -> Expr Int32
forall arguments a.
(Arguments arguments, Sql DBType a) =>
QualifiedName -> arguments -> Expr a
function QualifiedName
"octet_length"
upper :: Expr Text -> Expr Text
upper :: Expr Text -> Expr Text
upper = QualifiedName -> Expr Text -> Expr Text
forall arguments a.
(Arguments arguments, Sql DBType a) =>
QualifiedName -> arguments -> Expr a
function QualifiedName
"upper"
ascii :: Expr Text -> Expr Int32
ascii :: Expr Text -> Expr Int32
ascii = QualifiedName -> Expr Text -> Expr Int32
forall arguments a.
(Arguments arguments, Sql DBType a) =>
QualifiedName -> arguments -> Expr a
function QualifiedName
"ascii"
btrim :: Expr Text -> Maybe (Expr Text) -> Expr Text
btrim :: Expr Text -> Maybe (Expr Text) -> Expr Text
btrim Expr Text
a (Just Expr Text
b) = QualifiedName -> (Expr Text, Expr Text) -> Expr Text
forall arguments a.
(Arguments arguments, Sql DBType a) =>
QualifiedName -> arguments -> Expr a
function QualifiedName
"btrim" (Expr Text
a, Expr Text
b)
btrim Expr Text
a Maybe (Expr Text)
Nothing = QualifiedName -> Expr Text -> Expr Text
forall arguments a.
(Arguments arguments, Sql DBType a) =>
QualifiedName -> arguments -> Expr a
function QualifiedName
"btrim" Expr Text
a
chr :: Expr Int32 -> Expr Text
chr :: Expr Int32 -> Expr Text
chr = QualifiedName -> Expr Int32 -> Expr Text
forall arguments a.
(Arguments arguments, Sql DBType a) =>
QualifiedName -> arguments -> Expr a
function QualifiedName
"chr"
convert :: Expr ByteString -> Expr Text -> Expr Text -> Expr ByteString
convert :: Expr ByteString -> Expr Text -> Expr Text -> Expr ByteString
convert Expr ByteString
a Expr Text
b Expr Text
c = QualifiedName
-> (Expr ByteString, Expr Text, Expr Text) -> Expr ByteString
forall arguments a.
(Arguments arguments, Sql DBType a) =>
QualifiedName -> arguments -> Expr a
function QualifiedName
"convert" (Expr ByteString
a, Expr Text
b, Expr Text
c)
convertFrom :: Expr ByteString -> Expr Text -> Expr Text
convertFrom :: Expr ByteString -> Expr Text -> Expr Text
convertFrom Expr ByteString
a Expr Text
b = QualifiedName -> (Expr ByteString, Expr Text) -> Expr Text
forall arguments a.
(Arguments arguments, Sql DBType a) =>
QualifiedName -> arguments -> Expr a
function QualifiedName
"convert_from" (Expr ByteString
a, Expr Text
b)
convertTo :: Expr Text -> Expr Text -> Expr ByteString
convertTo :: Expr Text -> Expr Text -> Expr ByteString
convertTo Expr Text
a Expr Text
b = QualifiedName -> (Expr Text, Expr Text) -> Expr ByteString
forall arguments a.
(Arguments arguments, Sql DBType a) =>
QualifiedName -> arguments -> Expr a
function QualifiedName
"convert_to" (Expr Text
a, Expr Text
b)
decode :: Expr Text -> Expr Text -> Expr ByteString
decode :: Expr Text -> Expr Text -> Expr ByteString
decode Expr Text
a Expr Text
b = QualifiedName -> (Expr Text, Expr Text) -> Expr ByteString
forall arguments a.
(Arguments arguments, Sql DBType a) =>
QualifiedName -> arguments -> Expr a
function QualifiedName
"decode" (Expr Text
a, Expr Text
b)
encode :: Expr ByteString -> Expr Text -> Expr Text
encode :: Expr ByteString -> Expr Text -> Expr Text
encode Expr ByteString
a Expr Text
b = QualifiedName -> (Expr ByteString, Expr Text) -> Expr Text
forall arguments a.
(Arguments arguments, Sql DBType a) =>
QualifiedName -> arguments -> Expr a
function QualifiedName
"encode" (Expr ByteString
a, Expr Text
b)
initcap :: Expr Text -> Expr Text
initcap :: Expr Text -> Expr Text
initcap = QualifiedName -> Expr Text -> Expr Text
forall arguments a.
(Arguments arguments, Sql DBType a) =>
QualifiedName -> arguments -> Expr a
function QualifiedName
"initcap"
left :: Expr Text -> Expr Int32 -> Expr Text
left :: Expr Text -> Expr Int32 -> Expr Text
left Expr Text
a Expr Int32
b = QualifiedName -> (Expr Text, Expr Int32) -> Expr Text
forall arguments a.
(Arguments arguments, Sql DBType a) =>
QualifiedName -> arguments -> Expr a
function QualifiedName
"left" (Expr Text
a, Expr Int32
b)
length :: Expr Text -> Expr Int32
length :: Expr Text -> Expr Int32
length = QualifiedName -> Expr Text -> Expr Int32
forall arguments a.
(Arguments arguments, Sql DBType a) =>
QualifiedName -> arguments -> Expr a
function QualifiedName
"length"
lengthEncoding :: Expr ByteString -> Expr Text -> Expr Int32
lengthEncoding :: Expr ByteString -> Expr Text -> Expr Int32
lengthEncoding Expr ByteString
a Expr Text
b = QualifiedName -> (Expr ByteString, Expr Text) -> Expr Int32
forall arguments a.
(Arguments arguments, Sql DBType a) =>
QualifiedName -> arguments -> Expr a
function QualifiedName
"length" (Expr ByteString
a, Expr Text
b)
lpad :: Expr Text -> Expr Int32 -> Maybe (Expr Text) -> Expr Text
lpad :: Expr Text -> Expr Int32 -> Maybe (Expr Text) -> Expr Text
lpad Expr Text
a Expr Int32
b (Just Expr Text
c) = QualifiedName -> (Expr Text, Expr Int32, Expr Text) -> Expr Text
forall arguments a.
(Arguments arguments, Sql DBType a) =>
QualifiedName -> arguments -> Expr a
function QualifiedName
"lpad" (Expr Text
a, Expr Int32
b, Expr Text
c)
lpad Expr Text
a Expr Int32
b Maybe (Expr Text)
Nothing = QualifiedName -> (Expr Text, Expr Int32) -> Expr Text
forall arguments a.
(Arguments arguments, Sql DBType a) =>
QualifiedName -> arguments -> Expr a
function QualifiedName
"lpad" (Expr Text
a, Expr Int32
b)
ltrim :: Expr Text -> Maybe (Expr Text) -> Expr Text
ltrim :: Expr Text -> Maybe (Expr Text) -> Expr Text
ltrim Expr Text
a (Just Expr Text
b) = QualifiedName -> (Expr Text, Expr Text) -> Expr Text
forall arguments a.
(Arguments arguments, Sql DBType a) =>
QualifiedName -> arguments -> Expr a
function QualifiedName
"ltrim" (Expr Text
a, Expr Text
b)
ltrim Expr Text
a Maybe (Expr Text)
Nothing = QualifiedName -> Expr Text -> Expr Text
forall arguments a.
(Arguments arguments, Sql DBType a) =>
QualifiedName -> arguments -> Expr a
function QualifiedName
"ltrim" Expr Text
a
md5 :: Expr Text -> Expr Text
md5 :: Expr Text -> Expr Text
md5 = QualifiedName -> Expr Text -> Expr Text
forall arguments a.
(Arguments arguments, Sql DBType a) =>
QualifiedName -> arguments -> Expr a
function QualifiedName
"md5"
pgClientEncoding :: Expr Text
pgClientEncoding :: Expr Text
pgClientEncoding = QualifiedName -> () -> Expr Text
forall arguments a.
(Arguments arguments, Sql DBType a) =>
QualifiedName -> arguments -> Expr a
function QualifiedName
"pg_client_encoding" ()
quoteIdent :: Expr Text -> Expr Text
quoteIdent :: Expr Text -> Expr Text
quoteIdent = QualifiedName -> Expr Text -> Expr Text
forall arguments a.
(Arguments arguments, Sql DBType a) =>
QualifiedName -> arguments -> Expr a
function QualifiedName
"quote_ident"
quoteLiteral :: Expr Text -> Expr Text
quoteLiteral :: Expr Text -> Expr Text
quoteLiteral = QualifiedName -> Expr Text -> Expr Text
forall arguments a.
(Arguments arguments, Sql DBType a) =>
QualifiedName -> arguments -> Expr a
function QualifiedName
"quote_literal"
quoteNullable :: Expr Text -> Expr Text
quoteNullable :: Expr Text -> Expr Text
quoteNullable = QualifiedName -> Expr Text -> Expr Text
forall arguments a.
(Arguments arguments, Sql DBType a) =>
QualifiedName -> arguments -> Expr a
function QualifiedName
"quote_nullable"
regexpReplace :: ()
=> Expr Text -> Expr Text -> Expr Text -> Maybe (Expr Text) -> Expr Text
regexpReplace :: Expr Text
-> Expr Text -> Expr Text -> Maybe (Expr Text) -> Expr Text
regexpReplace Expr Text
a Expr Text
b Expr Text
c (Just Expr Text
d) = QualifiedName
-> (Expr Text, Expr Text, Expr Text, Expr Text) -> Expr Text
forall arguments a.
(Arguments arguments, Sql DBType a) =>
QualifiedName -> arguments -> Expr a
function QualifiedName
"regexp_replace" (Expr Text
a, Expr Text
b, Expr Text
c, Expr Text
d)
regexpReplace Expr Text
a Expr Text
b Expr Text
c Maybe (Expr Text)
Nothing = QualifiedName -> (Expr Text, Expr Text, Expr Text) -> Expr Text
forall arguments a.
(Arguments arguments, Sql DBType a) =>
QualifiedName -> arguments -> Expr a
function QualifiedName
"regexp_replace" (Expr Text
a, Expr Text
b, Expr Text
c)
regexpSplitToArray :: ()
=> Expr Text -> Expr Text -> Maybe (Expr Text) -> Expr [Text]
regexpSplitToArray :: Expr Text -> Expr Text -> Maybe (Expr Text) -> Expr [Text]
regexpSplitToArray Expr Text
a Expr Text
b (Just Expr Text
c) = QualifiedName -> (Expr Text, Expr Text, Expr Text) -> Expr [Text]
forall arguments a.
(Arguments arguments, Sql DBType a) =>
QualifiedName -> arguments -> Expr a
function QualifiedName
"regexp_split_to_array" (Expr Text
a, Expr Text
b, Expr Text
c)
regexpSplitToArray Expr Text
a Expr Text
b Maybe (Expr Text)
Nothing = QualifiedName -> (Expr Text, Expr Text) -> Expr [Text]
forall arguments a.
(Arguments arguments, Sql DBType a) =>
QualifiedName -> arguments -> Expr a
function QualifiedName
"regexp_split_to_array" (Expr Text
a, Expr Text
b)
repeat :: Expr Text -> Expr Int32 -> Expr Text
repeat :: Expr Text -> Expr Int32 -> Expr Text
repeat Expr Text
a Expr Int32
b = QualifiedName -> (Expr Text, Expr Int32) -> Expr Text
forall arguments a.
(Arguments arguments, Sql DBType a) =>
QualifiedName -> arguments -> Expr a
function QualifiedName
"repeat" (Expr Text
a, Expr Int32
b)
replace :: Expr Text -> Expr Text -> Expr Text -> Expr Text
replace :: Expr Text -> Expr Text -> Expr Text -> Expr Text
replace Expr Text
a Expr Text
b Expr Text
c = QualifiedName -> (Expr Text, Expr Text, Expr Text) -> Expr Text
forall arguments a.
(Arguments arguments, Sql DBType a) =>
QualifiedName -> arguments -> Expr a
function QualifiedName
"replace" (Expr Text
a, Expr Text
b, Expr Text
c)
reverse :: Expr Text -> Expr Text
reverse :: Expr Text -> Expr Text
reverse = QualifiedName -> Expr Text -> Expr Text
forall arguments a.
(Arguments arguments, Sql DBType a) =>
QualifiedName -> arguments -> Expr a
function QualifiedName
"reverse"
right :: Expr Text -> Expr Int32 -> Expr Text
right :: Expr Text -> Expr Int32 -> Expr Text
right Expr Text
a Expr Int32
b = QualifiedName -> (Expr Text, Expr Int32) -> Expr Text
forall arguments a.
(Arguments arguments, Sql DBType a) =>
QualifiedName -> arguments -> Expr a
function QualifiedName
"right" (Expr Text
a, Expr Int32
b)
rpad :: Expr Text -> Expr Int32 -> Maybe (Expr Text) -> Expr Text
rpad :: Expr Text -> Expr Int32 -> Maybe (Expr Text) -> Expr Text
rpad Expr Text
a Expr Int32
b (Just Expr Text
c) = QualifiedName -> (Expr Text, Expr Int32, Expr Text) -> Expr Text
forall arguments a.
(Arguments arguments, Sql DBType a) =>
QualifiedName -> arguments -> Expr a
function QualifiedName
"rpad" (Expr Text
a, Expr Int32
b, Expr Text
c)
rpad Expr Text
a Expr Int32
b Maybe (Expr Text)
Nothing = QualifiedName -> (Expr Text, Expr Int32) -> Expr Text
forall arguments a.
(Arguments arguments, Sql DBType a) =>
QualifiedName -> arguments -> Expr a
function QualifiedName
"rpad" (Expr Text
a, Expr Int32
b)
rtrim :: Expr Text -> Maybe (Expr Text) -> Expr Text
rtrim :: Expr Text -> Maybe (Expr Text) -> Expr Text
rtrim Expr Text
a (Just Expr Text
b) = QualifiedName -> (Expr Text, Expr Text) -> Expr Text
forall arguments a.
(Arguments arguments, Sql DBType a) =>
QualifiedName -> arguments -> Expr a
function QualifiedName
"rtrim" (Expr Text
a, Expr Text
b)
rtrim Expr Text
a Maybe (Expr Text)
Nothing = QualifiedName -> Expr Text -> Expr Text
forall arguments a.
(Arguments arguments, Sql DBType a) =>
QualifiedName -> arguments -> Expr a
function QualifiedName
"rtrim" Expr Text
a
splitPart :: Expr Text -> Expr Text -> Expr Int32 -> Expr Text
splitPart :: Expr Text -> Expr Text -> Expr Int32 -> Expr Text
splitPart Expr Text
a Expr Text
b Expr Int32
c = QualifiedName -> (Expr Text, Expr Text, Expr Int32) -> Expr Text
forall arguments a.
(Arguments arguments, Sql DBType a) =>
QualifiedName -> arguments -> Expr a
function QualifiedName
"split_part" (Expr Text
a, Expr Text
b, Expr Int32
c)
strpos :: Expr Text -> Expr Text -> Expr Int32
strpos :: Expr Text -> Expr Text -> Expr Int32
strpos Expr Text
a Expr Text
b = QualifiedName -> (Expr Text, Expr Text) -> Expr Int32
forall arguments a.
(Arguments arguments, Sql DBType a) =>
QualifiedName -> arguments -> Expr a
function QualifiedName
"strpos" (Expr Text
a, Expr Text
b)
substr :: Expr Text -> Expr Int32 -> Maybe (Expr Int32) -> Expr Text
substr :: Expr Text -> Expr Int32 -> Maybe (Expr Int32) -> Expr Text
substr Expr Text
a Expr Int32
b (Just Expr Int32
c) = QualifiedName -> (Expr Text, Expr Int32, Expr Int32) -> Expr Text
forall arguments a.
(Arguments arguments, Sql DBType a) =>
QualifiedName -> arguments -> Expr a
function QualifiedName
"substr" (Expr Text
a, Expr Int32
b, Expr Int32
c)
substr Expr Text
a Expr Int32
b Maybe (Expr Int32)
Nothing = QualifiedName -> (Expr Text, Expr Int32) -> Expr Text
forall arguments a.
(Arguments arguments, Sql DBType a) =>
QualifiedName -> arguments -> Expr a
function QualifiedName
"substr" (Expr Text
a, Expr Int32
b)
translate :: Expr Text -> Expr Text -> Expr Text -> Expr Text
translate :: Expr Text -> Expr Text -> Expr Text -> Expr Text
translate Expr Text
a Expr Text
b Expr Text
c = QualifiedName -> (Expr Text, Expr Text, Expr Text) -> Expr Text
forall arguments a.
(Arguments arguments, Sql DBType a) =>
QualifiedName -> arguments -> Expr a
function QualifiedName
"translate" (Expr Text
a, Expr Text
b, Expr Text
c)
like :: Expr Text -> Expr Text -> Expr Bool
like :: Expr Text -> Expr Text -> Expr Bool
like = (Expr Text -> Expr Text -> Expr Bool)
-> Expr Text -> Expr Text -> Expr Bool
forall a b c. (a -> b -> c) -> b -> a -> c
flip ((PrimExpr -> PrimExpr -> PrimExpr)
-> Expr Text -> Expr Text -> Expr Bool
forall a b c.
(PrimExpr -> PrimExpr -> PrimExpr) -> Expr a -> Expr b -> Expr c
zipPrimExprsWith (BinOp -> PrimExpr -> PrimExpr -> PrimExpr
Opaleye.BinExpr BinOp
Opaleye.OpLike))
ilike :: Expr Text -> Expr Text -> Expr Bool
ilike :: Expr Text -> Expr Text -> Expr Bool
ilike = (Expr Text -> Expr Text -> Expr Bool)
-> Expr Text -> Expr Text -> Expr Bool
forall a b c. (a -> b -> c) -> b -> a -> c
flip ((PrimExpr -> PrimExpr -> PrimExpr)
-> Expr Text -> Expr Text -> Expr Bool
forall a b c.
(PrimExpr -> PrimExpr -> PrimExpr) -> Expr a -> Expr b -> Expr c
zipPrimExprsWith (BinOp -> PrimExpr -> PrimExpr -> PrimExpr
Opaleye.BinExpr BinOp
Opaleye.OpILike))