{-# LANGUAGE FlexibleContexts, ScopedTypeVariables #-}
module Opaleye.Sql (
showSql,
showSqlUnopt,
showSqlExplicit,
showSqlUnoptExplicit,
showSqlForPostgres,
showSqlForPostgresUnopt,
showSqlForPostgresExplicit,
showSqlForPostgresUnoptExplicit,
) 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 :: Select fields -> Maybe String
showSql = Unpackspec fields fields -> Select fields -> Maybe String
forall fields b.
Unpackspec fields b -> Select fields -> Maybe String
showSqlExplicit (Unpackspec fields fields -> Unpackspec fields fields
forall (p :: * -> * -> *) a. p a a -> p a a
atSameType Unpackspec fields fields
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 :: Select fields -> Maybe String
showSqlUnopt = Unpackspec fields fields -> Select fields -> Maybe String
forall fields b.
Unpackspec fields b -> Select fields -> Maybe String
showSqlUnoptExplicit (Unpackspec fields fields -> Unpackspec fields fields
forall (p :: * -> * -> *) a. p a a -> p a a
atSameType Unpackspec fields fields
forall (p :: * -> * -> *) a b. Default p a b => p a b
D.def)
showSqlExplicit :: U.Unpackspec fields b -> S.Select fields -> Maybe String
showSqlExplicit :: Unpackspec fields b -> Select fields -> Maybe String
showSqlExplicit = ([PrimExpr], PrimQuery' (), Tag) -> Maybe String
forall a. ([PrimExpr], PrimQuery' a, Tag) -> Maybe String
Pr.formatAndShowSQL
(([PrimExpr], PrimQuery' (), Tag) -> Maybe String)
-> (([PrimExpr], PrimQuery' (), Tag)
-> ([PrimExpr], PrimQuery' (), Tag))
-> ([PrimExpr], PrimQuery' (), Tag)
-> Maybe String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (\([PrimExpr]
x, PrimQuery' ()
y, Tag
z) -> ([PrimExpr]
x, PrimQuery' () -> PrimQuery' ()
forall a. PrimQuery' a -> PrimQuery' a
Op.optimize PrimQuery' ()
y, Tag
z))
(([PrimExpr], PrimQuery' (), Tag) -> Maybe String)
-> (Unpackspec fields b
-> Select fields -> ([PrimExpr], PrimQuery' (), Tag))
-> Unpackspec fields b
-> Select fields
-> Maybe String
forall r z a b. (r -> z) -> (a -> b -> r) -> a -> b -> z
.: Unpackspec fields b
-> Select fields -> ([PrimExpr], PrimQuery' (), Tag)
forall a b.
Unpackspec a b -> Query a -> ([PrimExpr], PrimQuery' (), Tag)
Q.runQueryArrUnpack
showSqlUnoptExplicit :: U.Unpackspec fields b -> S.Select fields -> Maybe String
showSqlUnoptExplicit :: Unpackspec fields b -> Select fields -> Maybe String
showSqlUnoptExplicit = ([PrimExpr], PrimQuery' (), Tag) -> Maybe String
forall a. ([PrimExpr], PrimQuery' a, Tag) -> Maybe String
Pr.formatAndShowSQL (([PrimExpr], PrimQuery' (), Tag) -> Maybe String)
-> (Unpackspec fields b
-> Select fields -> ([PrimExpr], PrimQuery' (), Tag))
-> Unpackspec fields b
-> Select fields
-> Maybe String
forall r z a b. (r -> z) -> (a -> b -> r) -> a -> b -> z
.: Unpackspec fields b
-> Select fields -> ([PrimExpr], PrimQuery' (), Tag)
forall a b.
Unpackspec a b -> Query a -> ([PrimExpr], PrimQuery' (), Tag)
Q.runQueryArrUnpack
{-# DEPRECATED showSqlForPostgres "Will be removed in version 0.8. Use 'showSql' instead." #-}
showSqlForPostgres :: forall columns . D.Default U.Unpackspec columns columns =>
S.Select columns -> Maybe String
showSqlForPostgres :: Select columns -> Maybe String
showSqlForPostgres = Select columns -> Maybe String
forall fields.
Default Unpackspec fields fields =>
Select fields -> Maybe String
showSql
{-# DEPRECATED showSqlForPostgresUnopt "Will be removed in version 0.8. Use 'showSqlUnopt' instead." #-}
showSqlForPostgresUnopt :: forall columns . D.Default U.Unpackspec columns columns =>
S.Select columns -> Maybe String
showSqlForPostgresUnopt :: Select columns -> Maybe String
showSqlForPostgresUnopt = Select columns -> Maybe String
forall fields.
Default Unpackspec fields fields =>
Select fields -> Maybe String
showSqlUnopt
{-# DEPRECATED showSqlForPostgresExplicit "Will be removed in version 0.8. Use 'showSqlExplicit' instead." #-}
showSqlForPostgresExplicit :: U.Unpackspec columns b -> S.Select columns -> Maybe String
showSqlForPostgresExplicit :: Unpackspec columns b -> Select columns -> Maybe String
showSqlForPostgresExplicit = Unpackspec columns b -> Select columns -> Maybe String
forall fields b.
Unpackspec fields b -> Select fields -> Maybe String
showSqlExplicit
{-# DEPRECATED showSqlForPostgresUnoptExplicit "Will be removed in version 0.8. Use 'showSqlUnoptExplicit' instead." #-}
showSqlForPostgresUnoptExplicit :: U.Unpackspec columns b -> S.Select columns -> Maybe String
showSqlForPostgresUnoptExplicit :: Unpackspec columns b -> Select columns -> Maybe String
showSqlForPostgresUnoptExplicit = Unpackspec columns b -> Select columns -> Maybe String
forall fields b.
Unpackspec fields b -> Select fields -> Maybe String
showSqlUnoptExplicit