{-# LANGUAGE FlexibleContexts, ScopedTypeVariables #-}
module Opaleye.Sql (
showSql,
showSqlUnopt,
showSqlExplicit,
showSqlUnoptExplicit,
) where
import qualified Opaleye.Internal.Unpackspec as U
import qualified Opaleye.Internal.Print as Pr
import qualified Opaleye.Internal.Optimize as Op
import Opaleye.Internal.Helpers ((.:), atSameType)
import qualified Opaleye.Internal.QueryArr as Q
import qualified Opaleye.Select as S
import qualified Data.Profunctor.Product.Default as D
showSql :: D.Default U.Unpackspec fields fields
=> S.Select fields
-> Maybe String
showSql :: forall fields.
Default Unpackspec fields fields =>
Select fields -> Maybe String
showSql = forall fields b.
Unpackspec fields b -> Select fields -> Maybe String
showSqlExplicit (forall (p :: * -> * -> *) a. p a a -> p a a
atSameType forall (p :: * -> * -> *) a b. Default p a b => p a b
D.def)
showSqlUnopt :: D.Default U.Unpackspec fields fields
=> S.Select fields
-> Maybe String
showSqlUnopt :: forall fields.
Default Unpackspec fields fields =>
Select fields -> Maybe String
showSqlUnopt = forall fields b.
Unpackspec fields b -> Select fields -> Maybe String
showSqlUnoptExplicit (forall (p :: * -> * -> *) a. p a a -> p a a
atSameType forall (p :: * -> * -> *) a b. Default p a b => p a b
D.def)
showSqlExplicit :: U.Unpackspec fields b -> S.Select fields -> Maybe String
showSqlExplicit :: forall fields b.
Unpackspec fields b -> Select fields -> Maybe String
showSqlExplicit = forall a. ([PrimExpr], PrimQuery' a, Tag) -> Maybe String
Pr.formatAndShowSQL
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (\([PrimExpr]
x, PrimQuery' ()
y, Tag
z) -> ([PrimExpr]
x, forall a. PrimQuery' a -> PrimQuery' a
Op.optimize PrimQuery' ()
y, Tag
z))
forall r z a b. (r -> z) -> (a -> b -> r) -> a -> b -> z
.: forall a b.
Unpackspec a b -> Query a -> ([PrimExpr], PrimQuery' (), Tag)
Q.runQueryArrUnpack
showSqlUnoptExplicit :: U.Unpackspec fields b -> S.Select fields -> Maybe String
showSqlUnoptExplicit :: forall fields b.
Unpackspec fields b -> Select fields -> Maybe String
showSqlUnoptExplicit = forall a. ([PrimExpr], PrimQuery' a, Tag) -> Maybe String
Pr.formatAndShowSQL forall r z a b. (r -> z) -> (a -> b -> r) -> a -> b -> z
.: forall a b.
Unpackspec a b -> Query a -> ([PrimExpr], PrimQuery' (), Tag)
Q.runQueryArrUnpack