{-# LANGUAGE
DeriveGeneric
, DerivingStrategies
, FlexibleContexts
, FlexibleInstances
, GADTs
, GeneralizedNewtypeDeriving
, LambdaCase
, MultiParamTypeClasses
, OverloadedStrings
, PatternSynonyms
, QuantifiedConstraints
, RankNTypes
, ScopedTypeVariables
, TypeApplications
, TypeFamilies
, DataKinds
, PolyKinds
, TypeOperators
, UndecidableInstances
#-}
module Squeal.PostgreSQL.Manipulation.Call
(
call
, unsafeCall
, callN
, unsafeCallN
) where
import Data.ByteString hiding (foldr)
import Generics.SOP (SListI)
import Squeal.PostgreSQL.Type.Alias
import Squeal.PostgreSQL.Expression
import Squeal.PostgreSQL.Manipulation
import Squeal.PostgreSQL.Type.List
import Squeal.PostgreSQL.Render
import Squeal.PostgreSQL.Type.Schema
unsafeCall
:: ByteString
-> Expression 'Ungrouped '[] with db params '[] x
-> Manipulation with db params '[]
unsafeCall :: forall (with :: FromType) (db :: SchemasType)
(params :: [NullType]) (x :: NullType).
ByteString
-> Expression 'Ungrouped '[] with db params '[] x
-> Manipulation with db params '[]
unsafeCall ByteString
pro Expression 'Ungrouped '[] with db params '[] x
x = forall (with :: FromType) (db :: SchemasType)
(params :: [NullType]) (columns :: RowType).
ByteString -> Manipulation with db params columns
UnsafeManipulation forall a b. (a -> b) -> a -> b
$
ByteString
"CALL" ByteString -> ByteString -> ByteString
<+> ByteString
pro forall a. Semigroup a => a -> a -> a
<> ByteString -> ByteString
parenthesized (forall sql. RenderSQL sql => sql -> ByteString
renderSQL Expression 'Ungrouped '[] with db params '[] x
x)
call
:: ( Has sch db schema
, Has pro schema ('Procedure '[x]) )
=> QualifiedAlias sch pro
-> Expression 'Ungrouped '[] with db params '[] x
-> Manipulation with db params '[]
call :: forall (sch :: Symbol) (db :: SchemasType)
(schema :: [(Symbol, SchemumType)]) (pro :: Symbol) (x :: NullType)
(with :: FromType) (params :: [NullType]).
(Has sch db schema, Has pro schema ('Procedure '[x])) =>
QualifiedAlias sch pro
-> Expression 'Ungrouped '[] with db params '[] x
-> Manipulation with db params '[]
call = forall (with :: FromType) (db :: SchemasType)
(params :: [NullType]) (x :: NullType).
ByteString
-> Expression 'Ungrouped '[] with db params '[] x
-> Manipulation with db params '[]
unsafeCall forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall sql. RenderSQL sql => sql -> ByteString
renderSQL
unsafeCallN
:: SListI xs
=> ByteString
-> NP (Expression 'Ungrouped '[] with db params '[]) xs
-> Manipulation with db params '[]
unsafeCallN :: forall (xs :: [NullType]) (with :: FromType) (db :: SchemasType)
(params :: [NullType]).
SListI xs =>
ByteString
-> NP (Expression 'Ungrouped '[] with db params '[]) xs
-> Manipulation with db params '[]
unsafeCallN ByteString
pro NP (Expression 'Ungrouped '[] with db params '[]) xs
xs = forall (with :: FromType) (db :: SchemasType)
(params :: [NullType]) (columns :: RowType).
ByteString -> Manipulation with db params columns
UnsafeManipulation forall a b. (a -> b) -> a -> b
$
ByteString
"CALL" ByteString -> ByteString -> ByteString
<+> ByteString
pro forall a. Semigroup a => a -> a -> a
<> ByteString -> ByteString
parenthesized (forall {k} (xs :: [k]) (expression :: k -> *).
SListI xs =>
(forall (x :: k). expression x -> ByteString)
-> NP expression xs -> ByteString
renderCommaSeparated forall sql. RenderSQL sql => sql -> ByteString
renderSQL NP (Expression 'Ungrouped '[] with db params '[]) xs
xs)
callN
:: ( Has sch db schema
, Has pro schema ('Procedure xs)
, SListI xs )
=> QualifiedAlias sch pro
-> NP (Expression 'Ungrouped '[] with db params '[]) xs
-> Manipulation with db params '[]
callN :: forall (sch :: Symbol) (db :: SchemasType)
(schema :: [(Symbol, SchemumType)]) (pro :: Symbol)
(xs :: [NullType]) (with :: FromType) (params :: [NullType]).
(Has sch db schema, Has pro schema ('Procedure xs), SListI xs) =>
QualifiedAlias sch pro
-> NP (Expression 'Ungrouped '[] with db params '[]) xs
-> Manipulation with db params '[]
callN = forall (xs :: [NullType]) (with :: FromType) (db :: SchemasType)
(params :: [NullType]).
SListI xs =>
ByteString
-> NP (Expression 'Ungrouped '[] with db params '[]) xs
-> Manipulation with db params '[]
unsafeCallN forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall sql. RenderSQL sql => sql -> ByteString
renderSQL