{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -Wwarn=redundant-constraints #-}
module Hasura.RQL.Types.SchemaCache
( SchemaCache (..),
SchemaCacheVer,
initSchemaCacheVer,
incSchemaCacheVer,
TableConfig (..),
emptyTableConfig,
getAllRemoteSchemas,
unsafeFunctionCache,
unsafeFunctionInfo,
unsafeTableCache,
unsafeTableInfo,
askSourceInfo,
askSourceConfig,
askTableCache,
askTableInfo,
askTableCoreInfo,
askTableFieldInfoMap,
askTableMetadata,
askFunctionInfo,
askFieldInfoMapSource,
TableCoreCache,
TableCache,
ActionCache,
InheritedRolesCache,
TableCoreInfoG (..),
TableCoreInfo,
tciName,
tciDescription,
tciFieldInfoMap,
tciPrimaryKey,
tciUniqueConstraints,
tciForeignKeys,
tciViewInfo,
tciEnumValues,
tciCustomConfig,
tciUniqueOrPrimaryKeyConstraints,
TableInfo (..),
tiCoreInfo,
tiRolePermInfoMap,
tiEventTriggerInfoMap,
ViewInfo (..),
isMutable,
IntrospectionResult (..),
RemoteSchemaCustomizer (..),
remoteSchemaCustomizeTypeName,
remoteSchemaCustomizeFieldName,
RemoteSchemaRelationships,
RemoteSchemaCtx (..),
getIntrospectionResult,
rscName,
rscInfo,
rscIntroOriginal,
rscRawIntrospectionResult,
rscPermissions,
rscRemoteRelationships,
RemoteSchemaMap,
DepMap,
WithDeps,
SourceM (..),
SourceT (..),
TableCoreInfoRM (..),
TableCoreCacheRT (..),
TableInfoRM (..),
TableCacheRT (..),
CacheRM (..),
FieldInfoMap,
FieldInfo (..),
_FIColumn,
_FIRelationship,
_FIComputedField,
fieldInfoName,
fieldInfoGraphQLNames,
getCols,
getRels,
getComputedFieldInfos,
RolePermInfoMap,
InsPermInfo (..),
UpdPermInfo (..),
DelPermInfo (..),
PreSetColsPartial,
EventTriggerInfo (..),
EventTriggerInfoMap,
TableObjId (..),
SchemaObjId (..),
reportSchemaObj,
reportSchemaObjs,
DependencyReason (..),
SchemaDependency (..),
mkParentDep,
mkColDep,
mkComputedFieldDep,
getDependentObjs,
getDependentObjsWith,
getRemoteDependencies,
FunctionVolatility (..),
FunctionArgName (..),
FunctionInfo (..),
FunctionCache,
CronTriggerInfo (..),
MetadataResourceVersion (..),
initialResourceVersion,
getBoolExpDeps,
InlinedAllowlist,
BoolExpM (..),
BoolExpCtx (..),
getOpExpDeps,
)
where
import Control.Lens (Traversal', at, makeLenses, preview, (^.))
import Data.Aeson
import Data.Aeson.TH
import Data.ByteString.Lazy qualified as BL
import Data.HashMap.Strict qualified as M
import Data.HashSet qualified as HS
import Data.Int (Int64)
import Data.Text.Extended
import Database.MSSQL.Transaction qualified as MSSQL
import Database.PG.Query qualified as Q
import Hasura.Backends.Postgres.Connection qualified as PG
import Hasura.Base.Error
import Hasura.GraphQL.Context (GQLContext, RoleContext)
import Hasura.GraphQL.Schema.Options qualified as Options
import Hasura.Incremental
( Cacheable,
Dependency,
MonadDepend (..),
selectKeyD,
)
import Hasura.Prelude
import Hasura.RQL.DDL.Webhook.Transform
import Hasura.RQL.IR.BoolExp
import Hasura.RQL.Types.Action
import Hasura.RQL.Types.Allowlist
import Hasura.RQL.Types.ApiLimit
import Hasura.RQL.Types.Backend
import Hasura.RQL.Types.Column
import Hasura.RQL.Types.Common
import Hasura.RQL.Types.ComputedField
import Hasura.RQL.Types.Endpoint
import Hasura.RQL.Types.EventTrigger
import Hasura.RQL.Types.Function
import Hasura.RQL.Types.GraphqlSchemaIntrospection
import Hasura.RQL.Types.Metadata
import Hasura.RQL.Types.Metadata.Object
import Hasura.RQL.Types.Network (TlsAllow)
import Hasura.RQL.Types.QueryCollection
import Hasura.RQL.Types.Relationships.Local
import Hasura.RQL.Types.Relationships.Remote
import Hasura.RQL.Types.RemoteSchema
import Hasura.RQL.Types.ScheduledTrigger
import Hasura.RQL.Types.SchemaCacheTypes
import Hasura.RQL.Types.Source
import Hasura.RQL.Types.Table
import Hasura.SQL.AnyBackend qualified as AB
import Hasura.Server.Types
import Hasura.Session
import Hasura.Tracing (TraceT)
import Language.GraphQL.Draft.Syntax qualified as G
import System.Cron.Types
newtype MetadataResourceVersion = MetadataResourceVersion
{ MetadataResourceVersion -> Int64
getMetadataResourceVersion :: Int64
}
deriving (Int -> MetadataResourceVersion -> ShowS
[MetadataResourceVersion] -> ShowS
MetadataResourceVersion -> String
(Int -> MetadataResourceVersion -> ShowS)
-> (MetadataResourceVersion -> String)
-> ([MetadataResourceVersion] -> ShowS)
-> Show MetadataResourceVersion
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MetadataResourceVersion] -> ShowS
$cshowList :: [MetadataResourceVersion] -> ShowS
show :: MetadataResourceVersion -> String
$cshow :: MetadataResourceVersion -> String
showsPrec :: Int -> MetadataResourceVersion -> ShowS
$cshowsPrec :: Int -> MetadataResourceVersion -> ShowS
Show, MetadataResourceVersion -> MetadataResourceVersion -> Bool
(MetadataResourceVersion -> MetadataResourceVersion -> Bool)
-> (MetadataResourceVersion -> MetadataResourceVersion -> Bool)
-> Eq MetadataResourceVersion
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MetadataResourceVersion -> MetadataResourceVersion -> Bool
$c/= :: MetadataResourceVersion -> MetadataResourceVersion -> Bool
== :: MetadataResourceVersion -> MetadataResourceVersion -> Bool
$c== :: MetadataResourceVersion -> MetadataResourceVersion -> Bool
Eq, Integer -> MetadataResourceVersion
MetadataResourceVersion -> MetadataResourceVersion
MetadataResourceVersion
-> MetadataResourceVersion -> MetadataResourceVersion
(MetadataResourceVersion
-> MetadataResourceVersion -> MetadataResourceVersion)
-> (MetadataResourceVersion
-> MetadataResourceVersion -> MetadataResourceVersion)
-> (MetadataResourceVersion
-> MetadataResourceVersion -> MetadataResourceVersion)
-> (MetadataResourceVersion -> MetadataResourceVersion)
-> (MetadataResourceVersion -> MetadataResourceVersion)
-> (MetadataResourceVersion -> MetadataResourceVersion)
-> (Integer -> MetadataResourceVersion)
-> Num MetadataResourceVersion
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
fromInteger :: Integer -> MetadataResourceVersion
$cfromInteger :: Integer -> MetadataResourceVersion
signum :: MetadataResourceVersion -> MetadataResourceVersion
$csignum :: MetadataResourceVersion -> MetadataResourceVersion
abs :: MetadataResourceVersion -> MetadataResourceVersion
$cabs :: MetadataResourceVersion -> MetadataResourceVersion
negate :: MetadataResourceVersion -> MetadataResourceVersion
$cnegate :: MetadataResourceVersion -> MetadataResourceVersion
* :: MetadataResourceVersion
-> MetadataResourceVersion -> MetadataResourceVersion
$c* :: MetadataResourceVersion
-> MetadataResourceVersion -> MetadataResourceVersion
- :: MetadataResourceVersion
-> MetadataResourceVersion -> MetadataResourceVersion
$c- :: MetadataResourceVersion
-> MetadataResourceVersion -> MetadataResourceVersion
+ :: MetadataResourceVersion
-> MetadataResourceVersion -> MetadataResourceVersion
$c+ :: MetadataResourceVersion
-> MetadataResourceVersion -> MetadataResourceVersion
Num, Value -> Parser [MetadataResourceVersion]
Value -> Parser MetadataResourceVersion
(Value -> Parser MetadataResourceVersion)
-> (Value -> Parser [MetadataResourceVersion])
-> FromJSON MetadataResourceVersion
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [MetadataResourceVersion]
$cparseJSONList :: Value -> Parser [MetadataResourceVersion]
parseJSON :: Value -> Parser MetadataResourceVersion
$cparseJSON :: Value -> Parser MetadataResourceVersion
FromJSON, [MetadataResourceVersion] -> Value
[MetadataResourceVersion] -> Encoding
MetadataResourceVersion -> Value
MetadataResourceVersion -> Encoding
(MetadataResourceVersion -> Value)
-> (MetadataResourceVersion -> Encoding)
-> ([MetadataResourceVersion] -> Value)
-> ([MetadataResourceVersion] -> Encoding)
-> ToJSON MetadataResourceVersion
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [MetadataResourceVersion] -> Encoding
$ctoEncodingList :: [MetadataResourceVersion] -> Encoding
toJSONList :: [MetadataResourceVersion] -> Value
$ctoJSONList :: [MetadataResourceVersion] -> Value
toEncoding :: MetadataResourceVersion -> Encoding
$ctoEncoding :: MetadataResourceVersion -> Encoding
toJSON :: MetadataResourceVersion -> Value
$ctoJSON :: MetadataResourceVersion -> Value
ToJSON)
initialResourceVersion :: MetadataResourceVersion
initialResourceVersion :: MetadataResourceVersion
initialResourceVersion = Int64 -> MetadataResourceVersion
MetadataResourceVersion Int64
0
mkParentDep ::
forall b.
Backend b =>
SourceName ->
TableName b ->
SchemaDependency
mkParentDep :: SourceName -> TableName b -> SchemaDependency
mkParentDep SourceName
s TableName b
tn =
SchemaObjId -> DependencyReason -> SchemaDependency
SchemaDependency (SourceName -> AnyBackend SourceObjId -> SchemaObjId
SOSourceObj SourceName
s (AnyBackend SourceObjId -> SchemaObjId)
-> AnyBackend SourceObjId -> SchemaObjId
forall a b. (a -> b) -> a -> b
$ SourceObjId b -> AnyBackend SourceObjId
forall (b :: BackendType) (i :: BackendType -> *).
HasTag b =>
i b -> AnyBackend i
AB.mkAnyBackend @b (TableName b -> SourceObjId b
forall (b :: BackendType). TableName b -> SourceObjId b
SOITable TableName b
tn)) DependencyReason
DRTable
mkColDep ::
forall b.
(Backend b) =>
DependencyReason ->
SourceName ->
TableName b ->
Column b ->
SchemaDependency
mkColDep :: DependencyReason
-> SourceName -> TableName b -> Column b -> SchemaDependency
mkColDep DependencyReason
reason SourceName
source TableName b
tn Column b
col =
(SchemaObjId -> DependencyReason -> SchemaDependency)
-> DependencyReason -> SchemaObjId -> SchemaDependency
forall a b c. (a -> b -> c) -> b -> a -> c
flip SchemaObjId -> DependencyReason -> SchemaDependency
SchemaDependency DependencyReason
reason
(SchemaObjId -> SchemaDependency)
-> (TableObjId b -> SchemaObjId)
-> TableObjId b
-> SchemaDependency
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SourceName -> AnyBackend SourceObjId -> SchemaObjId
SOSourceObj SourceName
source
(AnyBackend SourceObjId -> SchemaObjId)
-> (TableObjId b -> AnyBackend SourceObjId)
-> TableObjId b
-> SchemaObjId
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SourceObjId b -> AnyBackend SourceObjId
forall (b :: BackendType) (i :: BackendType -> *).
HasTag b =>
i b -> AnyBackend i
AB.mkAnyBackend
(SourceObjId b -> AnyBackend SourceObjId)
-> (TableObjId b -> SourceObjId b)
-> TableObjId b
-> AnyBackend SourceObjId
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TableName b -> TableObjId b -> SourceObjId b
forall (b :: BackendType).
TableName b -> TableObjId b -> SourceObjId b
SOITableObj @b TableName b
tn
(TableObjId b -> SchemaDependency)
-> TableObjId b -> SchemaDependency
forall a b. (a -> b) -> a -> b
$ Column b -> TableObjId b
forall (b :: BackendType). Column b -> TableObjId b
TOCol @b Column b
col
mkComputedFieldDep ::
forall b.
(Backend b) =>
DependencyReason ->
SourceName ->
TableName b ->
ComputedFieldName ->
SchemaDependency
mkComputedFieldDep :: DependencyReason
-> SourceName
-> TableName b
-> ComputedFieldName
-> SchemaDependency
mkComputedFieldDep DependencyReason
reason SourceName
s TableName b
tn ComputedFieldName
computedField =
(SchemaObjId -> DependencyReason -> SchemaDependency)
-> DependencyReason -> SchemaObjId -> SchemaDependency
forall a b c. (a -> b -> c) -> b -> a -> c
flip SchemaObjId -> DependencyReason -> SchemaDependency
SchemaDependency DependencyReason
reason
(SchemaObjId -> SchemaDependency)
-> (TableObjId b -> SchemaObjId)
-> TableObjId b
-> SchemaDependency
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SourceName -> AnyBackend SourceObjId -> SchemaObjId
SOSourceObj SourceName
s
(AnyBackend SourceObjId -> SchemaObjId)
-> (TableObjId b -> AnyBackend SourceObjId)
-> TableObjId b
-> SchemaObjId
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SourceObjId b -> AnyBackend SourceObjId
forall (b :: BackendType) (i :: BackendType -> *).
HasTag b =>
i b -> AnyBackend i
AB.mkAnyBackend
(SourceObjId b -> AnyBackend SourceObjId)
-> (TableObjId b -> SourceObjId b)
-> TableObjId b
-> AnyBackend SourceObjId
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TableName b -> TableObjId b -> SourceObjId b
forall (b :: BackendType).
TableName b -> TableObjId b -> SourceObjId b
SOITableObj @b TableName b
tn
(TableObjId b -> SchemaDependency)
-> TableObjId b -> SchemaDependency
forall a b. (a -> b) -> a -> b
$ ComputedFieldName -> TableObjId b
forall (b :: BackendType). ComputedFieldName -> TableObjId b
TOComputedField ComputedFieldName
computedField
type WithDeps a = (a, [SchemaDependency])
data IntrospectionResult = IntrospectionResult
{ IntrospectionResult -> RemoteSchemaIntrospection
irDoc :: RemoteSchemaIntrospection,
IntrospectionResult -> Name
irQueryRoot :: G.Name,
IntrospectionResult -> Maybe Name
irMutationRoot :: Maybe G.Name,
IntrospectionResult -> Maybe Name
irSubscriptionRoot :: Maybe G.Name
}
deriving (Int -> IntrospectionResult -> ShowS
[IntrospectionResult] -> ShowS
IntrospectionResult -> String
(Int -> IntrospectionResult -> ShowS)
-> (IntrospectionResult -> String)
-> ([IntrospectionResult] -> ShowS)
-> Show IntrospectionResult
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IntrospectionResult] -> ShowS
$cshowList :: [IntrospectionResult] -> ShowS
show :: IntrospectionResult -> String
$cshow :: IntrospectionResult -> String
showsPrec :: Int -> IntrospectionResult -> ShowS
$cshowsPrec :: Int -> IntrospectionResult -> ShowS
Show, IntrospectionResult -> IntrospectionResult -> Bool
(IntrospectionResult -> IntrospectionResult -> Bool)
-> (IntrospectionResult -> IntrospectionResult -> Bool)
-> Eq IntrospectionResult
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IntrospectionResult -> IntrospectionResult -> Bool
$c/= :: IntrospectionResult -> IntrospectionResult -> Bool
== :: IntrospectionResult -> IntrospectionResult -> Bool
$c== :: IntrospectionResult -> IntrospectionResult -> Bool
Eq, (forall x. IntrospectionResult -> Rep IntrospectionResult x)
-> (forall x. Rep IntrospectionResult x -> IntrospectionResult)
-> Generic IntrospectionResult
forall x. Rep IntrospectionResult x -> IntrospectionResult
forall x. IntrospectionResult -> Rep IntrospectionResult x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep IntrospectionResult x -> IntrospectionResult
$cfrom :: forall x. IntrospectionResult -> Rep IntrospectionResult x
Generic)
instance Cacheable IntrospectionResult
type RemoteSchemaRelationships =
InsOrdHashMap G.Name (InsOrdHashMap RelName (RemoteFieldInfo G.Name))
data RemoteSchemaCtx = RemoteSchemaCtx
{ RemoteSchemaCtx -> RemoteSchemaName
_rscName :: RemoteSchemaName,
RemoteSchemaCtx -> IntrospectionResult
_rscIntroOriginal :: IntrospectionResult,
RemoteSchemaCtx -> RemoteSchemaInfo
_rscInfo :: RemoteSchemaInfo,
RemoteSchemaCtx -> ByteString
_rscRawIntrospectionResult :: BL.ByteString,
RemoteSchemaCtx -> HashMap RoleName IntrospectionResult
_rscPermissions :: M.HashMap RoleName IntrospectionResult,
RemoteSchemaCtx -> RemoteSchemaRelationships
_rscRemoteRelationships :: RemoteSchemaRelationships
}
getIntrospectionResult :: Options.RemoteSchemaPermissions -> RoleName -> RemoteSchemaCtx -> Maybe IntrospectionResult
getIntrospectionResult :: RemoteSchemaPermissions
-> RoleName -> RemoteSchemaCtx -> Maybe IntrospectionResult
getIntrospectionResult RemoteSchemaPermissions
remoteSchemaPermsCtx RoleName
role RemoteSchemaCtx
remoteSchemaContext =
if
|
RoleName
role RoleName -> RoleName -> Bool
forall a. Eq a => a -> a -> Bool
== RoleName
adminRoleName ->
IntrospectionResult -> Maybe IntrospectionResult
forall (f :: * -> *) a. Applicative f => a -> f a
pure (IntrospectionResult -> Maybe IntrospectionResult)
-> IntrospectionResult -> Maybe IntrospectionResult
forall a b. (a -> b) -> a -> b
$ RemoteSchemaCtx -> IntrospectionResult
_rscIntroOriginal RemoteSchemaCtx
remoteSchemaContext
|
RemoteSchemaPermissions
remoteSchemaPermsCtx RemoteSchemaPermissions -> RemoteSchemaPermissions -> Bool
forall a. Eq a => a -> a -> Bool
== RemoteSchemaPermissions
Options.DisableRemoteSchemaPermissions ->
IntrospectionResult -> Maybe IntrospectionResult
forall (f :: * -> *) a. Applicative f => a -> f a
pure (IntrospectionResult -> Maybe IntrospectionResult)
-> IntrospectionResult -> Maybe IntrospectionResult
forall a b. (a -> b) -> a -> b
$ RemoteSchemaCtx -> IntrospectionResult
_rscIntroOriginal RemoteSchemaCtx
remoteSchemaContext
|
Bool
otherwise ->
RoleName
-> HashMap RoleName IntrospectionResult
-> Maybe IntrospectionResult
forall k v. (Eq k, Hashable k) => k -> HashMap k v -> Maybe v
M.lookup RoleName
role (RemoteSchemaCtx -> HashMap RoleName IntrospectionResult
_rscPermissions RemoteSchemaCtx
remoteSchemaContext)
$(makeLenses ''RemoteSchemaCtx)
instance ToJSON RemoteSchemaCtx where
toJSON :: RemoteSchemaCtx -> Value
toJSON RemoteSchemaCtx {ByteString
HashMap RoleName IntrospectionResult
RemoteSchemaRelationships
RemoteSchemaName
RemoteSchemaInfo
IntrospectionResult
_rscRemoteRelationships :: RemoteSchemaRelationships
_rscPermissions :: HashMap RoleName IntrospectionResult
_rscRawIntrospectionResult :: ByteString
_rscInfo :: RemoteSchemaInfo
_rscIntroOriginal :: IntrospectionResult
_rscName :: RemoteSchemaName
_rscRemoteRelationships :: RemoteSchemaCtx -> RemoteSchemaRelationships
_rscPermissions :: RemoteSchemaCtx -> HashMap RoleName IntrospectionResult
_rscRawIntrospectionResult :: RemoteSchemaCtx -> ByteString
_rscInfo :: RemoteSchemaCtx -> RemoteSchemaInfo
_rscIntroOriginal :: RemoteSchemaCtx -> IntrospectionResult
_rscName :: RemoteSchemaCtx -> RemoteSchemaName
..} =
[Pair] -> Value
object ([Pair] -> Value) -> [Pair] -> Value
forall a b. (a -> b) -> a -> b
$
[ Key
"name" Key -> RemoteSchemaName -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= RemoteSchemaName
_rscName,
Key
"info" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= RemoteSchemaInfo -> Value
forall a. ToJSON a => a -> Value
toJSON RemoteSchemaInfo
_rscInfo
]
type RemoteSchemaMap = M.HashMap RemoteSchemaName RemoteSchemaCtx
type DepMap = M.HashMap SchemaObjId (HS.HashSet SchemaDependency)
data CronTriggerInfo = CronTriggerInfo
{ CronTriggerInfo -> TriggerName
ctiName :: TriggerName,
CronTriggerInfo -> CronSchedule
ctiSchedule :: CronSchedule,
CronTriggerInfo -> Maybe Value
ctiPayload :: Maybe Value,
CronTriggerInfo -> STRetryConf
ctiRetryConf :: STRetryConf,
CronTriggerInfo -> EnvRecord ResolvedWebhook
ctiWebhookInfo :: EnvRecord ResolvedWebhook,
:: [EventHeaderInfo],
:: Maybe Text,
CronTriggerInfo -> Maybe RequestTransform
ctiRequestTransform :: Maybe RequestTransform,
CronTriggerInfo -> Maybe MetadataResponseTransform
ctiResponseTransform :: Maybe MetadataResponseTransform
}
deriving (Int -> CronTriggerInfo -> ShowS
[CronTriggerInfo] -> ShowS
CronTriggerInfo -> String
(Int -> CronTriggerInfo -> ShowS)
-> (CronTriggerInfo -> String)
-> ([CronTriggerInfo] -> ShowS)
-> Show CronTriggerInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CronTriggerInfo] -> ShowS
$cshowList :: [CronTriggerInfo] -> ShowS
show :: CronTriggerInfo -> String
$cshow :: CronTriggerInfo -> String
showsPrec :: Int -> CronTriggerInfo -> ShowS
$cshowsPrec :: Int -> CronTriggerInfo -> ShowS
Show, CronTriggerInfo -> CronTriggerInfo -> Bool
(CronTriggerInfo -> CronTriggerInfo -> Bool)
-> (CronTriggerInfo -> CronTriggerInfo -> Bool)
-> Eq CronTriggerInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CronTriggerInfo -> CronTriggerInfo -> Bool
$c/= :: CronTriggerInfo -> CronTriggerInfo -> Bool
== :: CronTriggerInfo -> CronTriggerInfo -> Bool
$c== :: CronTriggerInfo -> CronTriggerInfo -> Bool
Eq)
$(deriveToJSON hasuraJSON ''CronTriggerInfo)
newtype SchemaCacheVer = SchemaCacheVer {SchemaCacheVer -> Word64
unSchemaCacheVer :: Word64}
deriving (Int -> SchemaCacheVer -> ShowS
[SchemaCacheVer] -> ShowS
SchemaCacheVer -> String
(Int -> SchemaCacheVer -> ShowS)
-> (SchemaCacheVer -> String)
-> ([SchemaCacheVer] -> ShowS)
-> Show SchemaCacheVer
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SchemaCacheVer] -> ShowS
$cshowList :: [SchemaCacheVer] -> ShowS
show :: SchemaCacheVer -> String
$cshow :: SchemaCacheVer -> String
showsPrec :: Int -> SchemaCacheVer -> ShowS
$cshowsPrec :: Int -> SchemaCacheVer -> ShowS
Show, SchemaCacheVer -> SchemaCacheVer -> Bool
(SchemaCacheVer -> SchemaCacheVer -> Bool)
-> (SchemaCacheVer -> SchemaCacheVer -> Bool) -> Eq SchemaCacheVer
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SchemaCacheVer -> SchemaCacheVer -> Bool
$c/= :: SchemaCacheVer -> SchemaCacheVer -> Bool
== :: SchemaCacheVer -> SchemaCacheVer -> Bool
$c== :: SchemaCacheVer -> SchemaCacheVer -> Bool
Eq, Eq SchemaCacheVer
Eq SchemaCacheVer
-> (SchemaCacheVer -> SchemaCacheVer -> Ordering)
-> (SchemaCacheVer -> SchemaCacheVer -> Bool)
-> (SchemaCacheVer -> SchemaCacheVer -> Bool)
-> (SchemaCacheVer -> SchemaCacheVer -> Bool)
-> (SchemaCacheVer -> SchemaCacheVer -> Bool)
-> (SchemaCacheVer -> SchemaCacheVer -> SchemaCacheVer)
-> (SchemaCacheVer -> SchemaCacheVer -> SchemaCacheVer)
-> Ord SchemaCacheVer
SchemaCacheVer -> SchemaCacheVer -> Bool
SchemaCacheVer -> SchemaCacheVer -> Ordering
SchemaCacheVer -> SchemaCacheVer -> SchemaCacheVer
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: SchemaCacheVer -> SchemaCacheVer -> SchemaCacheVer
$cmin :: SchemaCacheVer -> SchemaCacheVer -> SchemaCacheVer
max :: SchemaCacheVer -> SchemaCacheVer -> SchemaCacheVer
$cmax :: SchemaCacheVer -> SchemaCacheVer -> SchemaCacheVer
>= :: SchemaCacheVer -> SchemaCacheVer -> Bool
$c>= :: SchemaCacheVer -> SchemaCacheVer -> Bool
> :: SchemaCacheVer -> SchemaCacheVer -> Bool
$c> :: SchemaCacheVer -> SchemaCacheVer -> Bool
<= :: SchemaCacheVer -> SchemaCacheVer -> Bool
$c<= :: SchemaCacheVer -> SchemaCacheVer -> Bool
< :: SchemaCacheVer -> SchemaCacheVer -> Bool
$c< :: SchemaCacheVer -> SchemaCacheVer -> Bool
compare :: SchemaCacheVer -> SchemaCacheVer -> Ordering
$ccompare :: SchemaCacheVer -> SchemaCacheVer -> Ordering
$cp1Ord :: Eq SchemaCacheVer
Ord, Int -> SchemaCacheVer -> Int
SchemaCacheVer -> Int
(Int -> SchemaCacheVer -> Int)
-> (SchemaCacheVer -> Int) -> Hashable SchemaCacheVer
forall a. (Int -> a -> Int) -> (a -> Int) -> Hashable a
hash :: SchemaCacheVer -> Int
$chash :: SchemaCacheVer -> Int
hashWithSalt :: Int -> SchemaCacheVer -> Int
$chashWithSalt :: Int -> SchemaCacheVer -> Int
Hashable, [SchemaCacheVer] -> Value
[SchemaCacheVer] -> Encoding
SchemaCacheVer -> Value
SchemaCacheVer -> Encoding
(SchemaCacheVer -> Value)
-> (SchemaCacheVer -> Encoding)
-> ([SchemaCacheVer] -> Value)
-> ([SchemaCacheVer] -> Encoding)
-> ToJSON SchemaCacheVer
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [SchemaCacheVer] -> Encoding
$ctoEncodingList :: [SchemaCacheVer] -> Encoding
toJSONList :: [SchemaCacheVer] -> Value
$ctoJSONList :: [SchemaCacheVer] -> Value
toEncoding :: SchemaCacheVer -> Encoding
$ctoEncoding :: SchemaCacheVer -> Encoding
toJSON :: SchemaCacheVer -> Value
$ctoJSON :: SchemaCacheVer -> Value
ToJSON, Value -> Parser [SchemaCacheVer]
Value -> Parser SchemaCacheVer
(Value -> Parser SchemaCacheVer)
-> (Value -> Parser [SchemaCacheVer]) -> FromJSON SchemaCacheVer
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [SchemaCacheVer]
$cparseJSONList :: Value -> Parser [SchemaCacheVer]
parseJSON :: Value -> Parser SchemaCacheVer
$cparseJSON :: Value -> Parser SchemaCacheVer
FromJSON)
initSchemaCacheVer :: SchemaCacheVer
initSchemaCacheVer :: SchemaCacheVer
initSchemaCacheVer = Word64 -> SchemaCacheVer
SchemaCacheVer Word64
0
incSchemaCacheVer :: SchemaCacheVer -> SchemaCacheVer
incSchemaCacheVer :: SchemaCacheVer -> SchemaCacheVer
incSchemaCacheVer (SchemaCacheVer Word64
prev) =
Word64 -> SchemaCacheVer
SchemaCacheVer (Word64 -> SchemaCacheVer) -> Word64 -> SchemaCacheVer
forall a b. (a -> b) -> a -> b
$ Word64
prev Word64 -> Word64 -> Word64
forall a. Num a => a -> a -> a
+ Word64
1
type ActionCache = M.HashMap ActionName ActionInfo
type InheritedRolesCache = M.HashMap RoleName (HashSet RoleName)
askSourceInfo ::
forall b m.
(CacheRM m, MetadataM m, MonadError QErr m, Backend b) =>
SourceName ->
m (SourceInfo b)
askSourceInfo :: SourceName -> m (SourceInfo b)
askSourceInfo SourceName
sourceName = do
SourceCache
sources <- SchemaCache -> SourceCache
scSources (SchemaCache -> SourceCache) -> m SchemaCache -> m SourceCache
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m SchemaCache
forall (m :: * -> *). CacheRM m => m SchemaCache
askSchemaCache
Maybe (SourceInfo b) -> m (SourceInfo b) -> m (SourceInfo b)
forall (m :: * -> *) a. Applicative m => Maybe a -> m a -> m a
onNothing (HasTag b => BackendSourceInfo -> Maybe (SourceInfo b)
forall (b :: BackendType).
HasTag b =>
BackendSourceInfo -> Maybe (SourceInfo b)
unsafeSourceInfo @b (BackendSourceInfo -> Maybe (SourceInfo b))
-> Maybe BackendSourceInfo -> Maybe (SourceInfo b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< SourceName -> SourceCache -> Maybe BackendSourceInfo
forall k v. (Eq k, Hashable k) => k -> HashMap k v -> Maybe v
M.lookup SourceName
sourceName SourceCache
sources) do
Metadata
metadata <- m Metadata
forall (m :: * -> *). MetadataM m => m Metadata
getMetadata
case Metadata
metadata Metadata
-> Getting
(Maybe BackendSourceMetadata)
Metadata
(Maybe BackendSourceMetadata)
-> Maybe BackendSourceMetadata
forall s a. s -> Getting a s a -> a
^. (Sources -> Const (Maybe BackendSourceMetadata) Sources)
-> Metadata -> Const (Maybe BackendSourceMetadata) Metadata
Lens' Metadata Sources
metaSources ((Sources -> Const (Maybe BackendSourceMetadata) Sources)
-> Metadata -> Const (Maybe BackendSourceMetadata) Metadata)
-> ((Maybe BackendSourceMetadata
-> Const
(Maybe BackendSourceMetadata) (Maybe BackendSourceMetadata))
-> Sources -> Const (Maybe BackendSourceMetadata) Sources)
-> Getting
(Maybe BackendSourceMetadata)
Metadata
(Maybe BackendSourceMetadata)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Index Sources -> Lens' Sources (Maybe (IxValue Sources))
forall m. At m => Index m -> Lens' m (Maybe (IxValue m))
at Index Sources
SourceName
sourceName of
Maybe BackendSourceMetadata
Nothing ->
Code -> Text -> m (SourceInfo b)
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotExists (Text -> m (SourceInfo b)) -> Text -> m (SourceInfo b)
forall a b. (a -> b) -> a -> b
$ Text
"source with name " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> SourceName
sourceName SourceName -> Text -> Text
forall t. ToTxt t => t -> Text -> Text
<<> Text
" does not exist"
Just BackendSourceMetadata
_ ->
Code -> Text -> m (SourceInfo b)
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
Unexpected (Text -> m (SourceInfo b)) -> Text -> m (SourceInfo b)
forall a b. (a -> b) -> a -> b
$ Text
"source with name " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> SourceName
sourceName SourceName -> Text -> Text
forall t. ToTxt t => t -> Text -> Text
<<> Text
" is inconsistent"
askSourceConfig ::
forall b m.
(CacheRM m, MonadError QErr m, Backend b, MetadataM m) =>
SourceName ->
m (SourceConfig b)
askSourceConfig :: SourceName -> m (SourceConfig b)
askSourceConfig = (SourceInfo b -> SourceConfig b)
-> m (SourceInfo b) -> m (SourceConfig b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap SourceInfo b -> SourceConfig b
forall (b :: BackendType). SourceInfo b -> SourceConfig b
_siConfiguration (m (SourceInfo b) -> m (SourceConfig b))
-> (SourceName -> m (SourceInfo b))
-> SourceName
-> m (SourceConfig b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (b :: BackendType) (m :: * -> *).
(CacheRM m, MetadataM m, MonadError QErr m, Backend b) =>
SourceName -> m (SourceInfo b)
forall (m :: * -> *).
(CacheRM m, MetadataM m, MonadError QErr m, Backend b) =>
SourceName -> m (SourceInfo b)
askSourceInfo @b
unsafeTableCache ::
forall b. Backend b => SourceName -> SourceCache -> Maybe (TableCache b)
unsafeTableCache :: SourceName -> SourceCache -> Maybe (TableCache b)
unsafeTableCache SourceName
sourceName SourceCache
cache = do
HasTag b => BackendSourceInfo -> Maybe (TableCache b)
forall (b :: BackendType).
HasTag b =>
BackendSourceInfo -> Maybe (TableCache b)
unsafeSourceTables @b (BackendSourceInfo -> Maybe (TableCache b))
-> Maybe BackendSourceInfo -> Maybe (TableCache b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< SourceName -> SourceCache -> Maybe BackendSourceInfo
forall k v. (Eq k, Hashable k) => k -> HashMap k v -> Maybe v
M.lookup SourceName
sourceName SourceCache
cache
askTableCache ::
forall b m.
(Backend b, CacheRM m) =>
SourceName ->
m (Maybe (TableCache b))
askTableCache :: SourceName -> m (Maybe (TableCache b))
askTableCache SourceName
sourceName = do
SourceCache
sources <- SchemaCache -> SourceCache
scSources (SchemaCache -> SourceCache) -> m SchemaCache -> m SourceCache
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m SchemaCache
forall (m :: * -> *). CacheRM m => m SchemaCache
askSchemaCache
Maybe (TableCache b) -> m (Maybe (TableCache b))
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Maybe (TableCache b) -> m (Maybe (TableCache b)))
-> Maybe (TableCache b) -> m (Maybe (TableCache b))
forall a b. (a -> b) -> a -> b
$ BackendSourceInfo -> Maybe (TableCache b)
forall (b :: BackendType).
HasTag b =>
BackendSourceInfo -> Maybe (TableCache b)
unsafeSourceTables (BackendSourceInfo -> Maybe (TableCache b))
-> Maybe BackendSourceInfo -> Maybe (TableCache b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< SourceName -> SourceCache -> Maybe BackendSourceInfo
forall k v. (Eq k, Hashable k) => k -> HashMap k v -> Maybe v
M.lookup SourceName
sourceName SourceCache
sources
unsafeTableInfo ::
forall b. Backend b => SourceName -> TableName b -> SourceCache -> Maybe (TableInfo b)
unsafeTableInfo :: SourceName -> TableName b -> SourceCache -> Maybe (TableInfo b)
unsafeTableInfo SourceName
sourceName TableName b
tableName SourceCache
cache =
TableName b
-> HashMap (TableName b) (TableInfo b) -> Maybe (TableInfo b)
forall k v. (Eq k, Hashable k) => k -> HashMap k v -> Maybe v
M.lookup TableName b
tableName (HashMap (TableName b) (TableInfo b) -> Maybe (TableInfo b))
-> Maybe (HashMap (TableName b) (TableInfo b))
-> Maybe (TableInfo b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< SourceName
-> SourceCache -> Maybe (HashMap (TableName b) (TableInfo b))
forall (b :: BackendType).
Backend b =>
SourceName -> SourceCache -> Maybe (TableCache b)
unsafeTableCache @b SourceName
sourceName SourceCache
cache
askTableInfo ::
forall b m.
(QErrM m, CacheRM m, Backend b) =>
SourceName ->
TableName b ->
m (TableInfo b)
askTableInfo :: SourceName -> TableName b -> m (TableInfo b)
askTableInfo SourceName
sourceName TableName b
tableName = do
SchemaCache
rawSchemaCache <- m SchemaCache
forall (m :: * -> *). CacheRM m => m SchemaCache
askSchemaCache
Maybe (TableInfo b) -> m (TableInfo b) -> m (TableInfo b)
forall (m :: * -> *) a. Applicative m => Maybe a -> m a -> m a
onNothing (SourceName -> TableName b -> SourceCache -> Maybe (TableInfo b)
forall (b :: BackendType).
Backend b =>
SourceName -> TableName b -> SourceCache -> Maybe (TableInfo b)
unsafeTableInfo SourceName
sourceName TableName b
tableName (SourceCache -> Maybe (TableInfo b))
-> SourceCache -> Maybe (TableInfo b)
forall a b. (a -> b) -> a -> b
$ SchemaCache -> SourceCache
scSources SchemaCache
rawSchemaCache) (m (TableInfo b) -> m (TableInfo b))
-> m (TableInfo b) -> m (TableInfo b)
forall a b. (a -> b) -> a -> b
$
Code -> Text -> m (TableInfo b)
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotExists (Text -> m (TableInfo b)) -> Text -> m (TableInfo b)
forall a b. (a -> b) -> a -> b
$ Text
"table " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> TableName b
tableName TableName b -> Text -> Text
forall t. ToTxt t => t -> Text -> Text
<<> Text
" does not exist in source: " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> SourceName -> Text
sourceNameToText SourceName
sourceName
askTableCoreInfo ::
forall b m.
(QErrM m, CacheRM m, Backend b) =>
SourceName ->
TableName b ->
m (TableCoreInfo b)
askTableCoreInfo :: SourceName -> TableName b -> m (TableCoreInfo b)
askTableCoreInfo SourceName
sourceName TableName b
tableName =
TableInfo b -> TableCoreInfo b
forall (b :: BackendType). TableInfo b -> TableCoreInfo b
_tiCoreInfo (TableInfo b -> TableCoreInfo b)
-> m (TableInfo b) -> m (TableCoreInfo b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> SourceName -> TableName b -> m (TableInfo b)
forall (b :: BackendType) (m :: * -> *).
(QErrM m, CacheRM m, Backend b) =>
SourceName -> TableName b -> m (TableInfo b)
askTableInfo SourceName
sourceName TableName b
tableName
askTableFieldInfoMap ::
forall b m.
(QErrM m, CacheRM m, Backend b) =>
SourceName ->
TableName b ->
m (FieldInfoMap (FieldInfo b))
askTableFieldInfoMap :: SourceName -> TableName b -> m (FieldInfoMap (FieldInfo b))
askTableFieldInfoMap SourceName
sourceName TableName b
tableName =
TableCoreInfoG b (FieldInfo b) (ColumnInfo b)
-> FieldInfoMap (FieldInfo b)
forall (b :: BackendType) field primaryKeyColumn.
TableCoreInfoG b field primaryKeyColumn -> FieldInfoMap field
_tciFieldInfoMap (TableCoreInfoG b (FieldInfo b) (ColumnInfo b)
-> FieldInfoMap (FieldInfo b))
-> m (TableCoreInfoG b (FieldInfo b) (ColumnInfo b))
-> m (FieldInfoMap (FieldInfo b))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> SourceName
-> TableName b -> m (TableCoreInfoG b (FieldInfo b) (ColumnInfo b))
forall (b :: BackendType) (m :: * -> *).
(QErrM m, CacheRM m, Backend b) =>
SourceName -> TableName b -> m (TableCoreInfo b)
askTableCoreInfo SourceName
sourceName TableName b
tableName
askTableMetadata ::
forall b m.
(QErrM m, MetadataM m, Backend b) =>
SourceName ->
TableName b ->
m (TableMetadata b)
askTableMetadata :: SourceName -> TableName b -> m (TableMetadata b)
askTableMetadata SourceName
sourceName TableName b
tableName = do
m (Maybe (TableMetadata b))
-> m (TableMetadata b) -> m (TableMetadata b)
forall (m :: * -> *) a. Monad m => m (Maybe a) -> m a -> m a
onNothingM (m Metadata
forall (m :: * -> *). MetadataM m => m Metadata
getMetadata m Metadata
-> (Metadata -> Maybe (TableMetadata b))
-> m (Maybe (TableMetadata b))
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> Getting (First (TableMetadata b)) Metadata (TableMetadata b)
-> Metadata -> Maybe (TableMetadata b)
forall s (m :: * -> *) a.
MonadReader s m =>
Getting (First a) s a -> m (Maybe a)
preview Getting (First (TableMetadata b)) Metadata (TableMetadata b)
Traversal' Metadata (TableMetadata b)
focusTableMetadata) (m (TableMetadata b) -> m (TableMetadata b))
-> m (TableMetadata b) -> m (TableMetadata b)
forall a b. (a -> b) -> a -> b
$
Code -> Text -> m (TableMetadata b)
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotExists (Text -> m (TableMetadata b)) -> Text -> m (TableMetadata b)
forall a b. (a -> b) -> a -> b
$ Text
"table " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> TableName b
tableName TableName b -> Text -> Text
forall t. ToTxt t => t -> Text -> Text
<<> Text
" does not exist in source: " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> SourceName -> Text
sourceNameToText SourceName
sourceName
where
focusTableMetadata :: Traversal' Metadata (TableMetadata b)
focusTableMetadata :: (TableMetadata b -> f (TableMetadata b)) -> Metadata -> f Metadata
focusTableMetadata =
(Sources -> f Sources) -> Metadata -> f Metadata
Lens' Metadata Sources
metaSources
((Sources -> f Sources) -> Metadata -> f Metadata)
-> ((TableMetadata b -> f (TableMetadata b))
-> Sources -> f Sources)
-> (TableMetadata b -> f (TableMetadata b))
-> Metadata
-> f Metadata
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Index Sources -> Traversal' Sources (IxValue Sources)
forall m. Ixed m => Index m -> Traversal' m (IxValue m)
ix Index Sources
SourceName
sourceName
((BackendSourceMetadata -> f BackendSourceMetadata)
-> Sources -> f Sources)
-> ((TableMetadata b -> f (TableMetadata b))
-> BackendSourceMetadata -> f BackendSourceMetadata)
-> (TableMetadata b -> f (TableMetadata b))
-> Sources
-> f Sources
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Backend b => Prism' BackendSourceMetadata (SourceMetadata b)
forall (b :: BackendType).
Backend b =>
Prism' BackendSourceMetadata (SourceMetadata b)
toSourceMetadata @b
((SourceMetadata b -> f (SourceMetadata b))
-> BackendSourceMetadata -> f BackendSourceMetadata)
-> ((TableMetadata b -> f (TableMetadata b))
-> SourceMetadata b -> f (SourceMetadata b))
-> (TableMetadata b -> f (TableMetadata b))
-> BackendSourceMetadata
-> f BackendSourceMetadata
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (InsOrdHashMap (TableName b) (TableMetadata b)
-> f (InsOrdHashMap (TableName b) (TableMetadata b)))
-> SourceMetadata b -> f (SourceMetadata b)
forall (b :: BackendType). Lens' (SourceMetadata b) (Tables b)
smTables
((InsOrdHashMap (TableName b) (TableMetadata b)
-> f (InsOrdHashMap (TableName b) (TableMetadata b)))
-> SourceMetadata b -> f (SourceMetadata b))
-> ((TableMetadata b -> f (TableMetadata b))
-> InsOrdHashMap (TableName b) (TableMetadata b)
-> f (InsOrdHashMap (TableName b) (TableMetadata b)))
-> (TableMetadata b -> f (TableMetadata b))
-> SourceMetadata b
-> f (SourceMetadata b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Index (InsOrdHashMap (TableName b) (TableMetadata b))
-> Traversal'
(InsOrdHashMap (TableName b) (TableMetadata b))
(IxValue (InsOrdHashMap (TableName b) (TableMetadata b)))
forall m. Ixed m => Index m -> Traversal' m (IxValue m)
ix Index (InsOrdHashMap (TableName b) (TableMetadata b))
TableName b
tableName
unsafeFunctionCache ::
forall b. Backend b => SourceName -> SourceCache -> Maybe (FunctionCache b)
unsafeFunctionCache :: SourceName -> SourceCache -> Maybe (FunctionCache b)
unsafeFunctionCache SourceName
sourceName SourceCache
cache =
HasTag b => BackendSourceInfo -> Maybe (FunctionCache b)
forall (b :: BackendType).
HasTag b =>
BackendSourceInfo -> Maybe (FunctionCache b)
unsafeSourceFunctions @b (BackendSourceInfo -> Maybe (FunctionCache b))
-> Maybe BackendSourceInfo -> Maybe (FunctionCache b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< SourceName -> SourceCache -> Maybe BackendSourceInfo
forall k v. (Eq k, Hashable k) => k -> HashMap k v -> Maybe v
M.lookup SourceName
sourceName SourceCache
cache
unsafeFunctionInfo ::
forall b. Backend b => SourceName -> FunctionName b -> SourceCache -> Maybe (FunctionInfo b)
unsafeFunctionInfo :: SourceName
-> FunctionName b -> SourceCache -> Maybe (FunctionInfo b)
unsafeFunctionInfo SourceName
sourceName FunctionName b
functionName SourceCache
cache =
FunctionName b
-> HashMap (FunctionName b) (FunctionInfo b)
-> Maybe (FunctionInfo b)
forall k v. (Eq k, Hashable k) => k -> HashMap k v -> Maybe v
M.lookup FunctionName b
functionName (HashMap (FunctionName b) (FunctionInfo b)
-> Maybe (FunctionInfo b))
-> Maybe (HashMap (FunctionName b) (FunctionInfo b))
-> Maybe (FunctionInfo b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< SourceName
-> SourceCache -> Maybe (HashMap (FunctionName b) (FunctionInfo b))
forall (b :: BackendType).
Backend b =>
SourceName -> SourceCache -> Maybe (FunctionCache b)
unsafeFunctionCache @b SourceName
sourceName SourceCache
cache
askFunctionInfo ::
forall b m.
(QErrM m, CacheRM m, Backend b) =>
SourceName ->
FunctionName b ->
m (FunctionInfo b)
askFunctionInfo :: SourceName -> FunctionName b -> m (FunctionInfo b)
askFunctionInfo SourceName
sourceName FunctionName b
functionName = do
SchemaCache
rawSchemaCache <- m SchemaCache
forall (m :: * -> *). CacheRM m => m SchemaCache
askSchemaCache
Maybe (FunctionInfo b) -> m (FunctionInfo b) -> m (FunctionInfo b)
forall (m :: * -> *) a. Applicative m => Maybe a -> m a -> m a
onNothing (SourceName
-> FunctionName b -> SourceCache -> Maybe (FunctionInfo b)
forall (b :: BackendType).
Backend b =>
SourceName
-> FunctionName b -> SourceCache -> Maybe (FunctionInfo b)
unsafeFunctionInfo SourceName
sourceName FunctionName b
functionName (SourceCache -> Maybe (FunctionInfo b))
-> SourceCache -> Maybe (FunctionInfo b)
forall a b. (a -> b) -> a -> b
$ SchemaCache -> SourceCache
scSources SchemaCache
rawSchemaCache) (m (FunctionInfo b) -> m (FunctionInfo b))
-> m (FunctionInfo b) -> m (FunctionInfo b)
forall a b. (a -> b) -> a -> b
$
Code -> Text -> m (FunctionInfo b)
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotExists (Text -> m (FunctionInfo b)) -> Text -> m (FunctionInfo b)
forall a b. (a -> b) -> a -> b
$ Text
"function " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> FunctionName b
functionName FunctionName b -> Text -> Text
forall t. ToTxt t => t -> Text -> Text
<<> Text
" does not exist in source: " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> SourceName -> Text
sourceNameToText SourceName
sourceName
data SchemaCache = SchemaCache
{ SchemaCache -> SourceCache
scSources :: SourceCache,
SchemaCache -> ActionCache
scActions :: ActionCache,
SchemaCache -> RemoteSchemaMap
scRemoteSchemas :: RemoteSchemaMap,
SchemaCache -> InlinedAllowlist
scAllowlist :: InlinedAllowlist,
SchemaCache -> SchemaIntrospection
scAdminIntrospection :: G.SchemaIntrospection,
SchemaCache -> HashMap RoleName (RoleContext GQLContext)
scGQLContext :: HashMap RoleName (RoleContext GQLContext),
SchemaCache -> GQLContext
scUnauthenticatedGQLContext :: GQLContext,
SchemaCache -> HashMap RoleName (RoleContext GQLContext)
scRelayContext :: HashMap RoleName (RoleContext GQLContext),
SchemaCache -> GQLContext
scUnauthenticatedRelayContext :: GQLContext,
SchemaCache -> DepMap
scDepMap :: DepMap,
SchemaCache -> [InconsistentMetadata]
scInconsistentObjs :: [InconsistentMetadata],
SchemaCache -> HashMap TriggerName CronTriggerInfo
scCronTriggers :: M.HashMap TriggerName CronTriggerInfo,
SchemaCache -> EndpointTrie GQLQueryWithText
scEndpoints :: EndpointTrie GQLQueryWithText,
SchemaCache -> ApiLimit
scApiLimits :: ApiLimit,
SchemaCache -> MetricsConfig
scMetricsConfig :: MetricsConfig,
SchemaCache -> Maybe MetadataResourceVersion
scMetadataResourceVersion :: Maybe MetadataResourceVersion,
SchemaCache -> SetGraphqlIntrospectionOptions
scSetGraphqlIntrospectionOptions :: SetGraphqlIntrospectionOptions,
SchemaCache -> [TlsAllow]
scTlsAllowlist :: [TlsAllow],
SchemaCache -> QueryCollections
scQueryCollections :: QueryCollections
}
instance ToJSON SchemaCache where
toJSON :: SchemaCache -> Value
toJSON SchemaCache {[TlsAllow]
[InconsistentMetadata]
Maybe MetadataResourceVersion
HashMap RoleName (RoleContext GQLContext)
SourceCache
HashMap TriggerName CronTriggerInfo
RemoteSchemaMap
ActionCache
DepMap
QueryCollections
EndpointTrie GQLQueryWithText
SchemaIntrospection
ApiLimit
InlinedAllowlist
SetGraphqlIntrospectionOptions
MetricsConfig
GQLContext
scQueryCollections :: QueryCollections
scTlsAllowlist :: [TlsAllow]
scSetGraphqlIntrospectionOptions :: SetGraphqlIntrospectionOptions
scMetadataResourceVersion :: Maybe MetadataResourceVersion
scMetricsConfig :: MetricsConfig
scApiLimits :: ApiLimit
scEndpoints :: EndpointTrie GQLQueryWithText
scCronTriggers :: HashMap TriggerName CronTriggerInfo
scInconsistentObjs :: [InconsistentMetadata]
scDepMap :: DepMap
scUnauthenticatedRelayContext :: GQLContext
scRelayContext :: HashMap RoleName (RoleContext GQLContext)
scUnauthenticatedGQLContext :: GQLContext
scGQLContext :: HashMap RoleName (RoleContext GQLContext)
scAdminIntrospection :: SchemaIntrospection
scAllowlist :: InlinedAllowlist
scRemoteSchemas :: RemoteSchemaMap
scActions :: ActionCache
scSources :: SourceCache
scQueryCollections :: SchemaCache -> QueryCollections
scTlsAllowlist :: SchemaCache -> [TlsAllow]
scSetGraphqlIntrospectionOptions :: SchemaCache -> SetGraphqlIntrospectionOptions
scMetadataResourceVersion :: SchemaCache -> Maybe MetadataResourceVersion
scMetricsConfig :: SchemaCache -> MetricsConfig
scApiLimits :: SchemaCache -> ApiLimit
scEndpoints :: SchemaCache -> EndpointTrie GQLQueryWithText
scCronTriggers :: SchemaCache -> HashMap TriggerName CronTriggerInfo
scInconsistentObjs :: SchemaCache -> [InconsistentMetadata]
scDepMap :: SchemaCache -> DepMap
scUnauthenticatedRelayContext :: SchemaCache -> GQLContext
scRelayContext :: SchemaCache -> HashMap RoleName (RoleContext GQLContext)
scUnauthenticatedGQLContext :: SchemaCache -> GQLContext
scGQLContext :: SchemaCache -> HashMap RoleName (RoleContext GQLContext)
scAdminIntrospection :: SchemaCache -> SchemaIntrospection
scAllowlist :: SchemaCache -> InlinedAllowlist
scRemoteSchemas :: SchemaCache -> RemoteSchemaMap
scActions :: SchemaCache -> ActionCache
scSources :: SchemaCache -> SourceCache
..} =
[Pair] -> Value
object
[ Key
"sources" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= HashMap SourceName Value -> Value
forall a. ToJSON a => a -> Value
toJSON (BackendSourceInfo -> Value
forall (i :: BackendType -> *).
SatisfiesForAllBackends i ToJSON =>
AnyBackend i -> Value
AB.debugAnyBackendToJSON (BackendSourceInfo -> Value)
-> SourceCache -> HashMap SourceName Value
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> SourceCache
scSources),
Key
"actions" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ActionCache -> Value
forall a. ToJSON a => a -> Value
toJSON ActionCache
scActions,
Key
"remote_schemas" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= RemoteSchemaMap -> Value
forall a. ToJSON a => a -> Value
toJSON RemoteSchemaMap
scRemoteSchemas,
Key
"allowlist" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= InlinedAllowlist -> Value
forall a. ToJSON a => a -> Value
toJSON InlinedAllowlist
scAllowlist,
Key
"g_q_l_context" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= HashMap RoleName (RoleContext GQLContext) -> Value
forall a. ToJSON a => a -> Value
toJSON HashMap RoleName (RoleContext GQLContext)
scGQLContext,
Key
"unauthenticated_g_q_l_context" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GQLContext -> Value
forall a. ToJSON a => a -> Value
toJSON GQLContext
scUnauthenticatedGQLContext,
Key
"relay_context" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= HashMap RoleName (RoleContext GQLContext) -> Value
forall a. ToJSON a => a -> Value
toJSON HashMap RoleName (RoleContext GQLContext)
scRelayContext,
Key
"unauthenticated_relay_context" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= GQLContext -> Value
forall a. ToJSON a => a -> Value
toJSON GQLContext
scUnauthenticatedRelayContext,
Key
"dep_map" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= DepMap -> Value
forall a. ToJSON a => a -> Value
toJSON DepMap
scDepMap,
Key
"inconsistent_objs" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [InconsistentMetadata] -> Value
forall a. ToJSON a => a -> Value
toJSON [InconsistentMetadata]
scInconsistentObjs,
Key
"cron_triggers" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= HashMap TriggerName CronTriggerInfo -> Value
forall a. ToJSON a => a -> Value
toJSON HashMap TriggerName CronTriggerInfo
scCronTriggers,
Key
"endpoints" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= EndpointTrie GQLQueryWithText -> Value
forall a. ToJSON a => a -> Value
toJSON EndpointTrie GQLQueryWithText
scEndpoints,
Key
"api_limits" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ApiLimit -> Value
forall a. ToJSON a => a -> Value
toJSON ApiLimit
scApiLimits,
Key
"metrics_config" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= MetricsConfig -> Value
forall a. ToJSON a => a -> Value
toJSON MetricsConfig
scMetricsConfig,
Key
"metadata_resource_version" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Maybe MetadataResourceVersion -> Value
forall a. ToJSON a => a -> Value
toJSON Maybe MetadataResourceVersion
scMetadataResourceVersion,
Key
"set_graphql_introspection_options" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SetGraphqlIntrospectionOptions -> Value
forall a. ToJSON a => a -> Value
toJSON SetGraphqlIntrospectionOptions
scSetGraphqlIntrospectionOptions,
Key
"tls_allowlist" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [TlsAllow] -> Value
forall a. ToJSON a => a -> Value
toJSON [TlsAllow]
scTlsAllowlist,
Key
"query_collection" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= QueryCollections -> Value
forall a. ToJSON a => a -> Value
toJSON QueryCollections
scQueryCollections
]
getAllRemoteSchemas :: SchemaCache -> [RemoteSchemaName]
getAllRemoteSchemas :: SchemaCache -> [RemoteSchemaName]
getAllRemoteSchemas SchemaCache
sc =
let consistentRemoteSchemas :: [RemoteSchemaName]
consistentRemoteSchemas = RemoteSchemaMap -> [RemoteSchemaName]
forall k v. HashMap k v -> [k]
M.keys (RemoteSchemaMap -> [RemoteSchemaName])
-> RemoteSchemaMap -> [RemoteSchemaName]
forall a b. (a -> b) -> a -> b
$ SchemaCache -> RemoteSchemaMap
scRemoteSchemas SchemaCache
sc
inconsistentRemoteSchemas :: [RemoteSchemaName]
inconsistentRemoteSchemas =
[InconsistentMetadata] -> [RemoteSchemaName]
getInconsistentRemoteSchemas ([InconsistentMetadata] -> [RemoteSchemaName])
-> [InconsistentMetadata] -> [RemoteSchemaName]
forall a b. (a -> b) -> a -> b
$ SchemaCache -> [InconsistentMetadata]
scInconsistentObjs SchemaCache
sc
in [RemoteSchemaName]
consistentRemoteSchemas [RemoteSchemaName] -> [RemoteSchemaName] -> [RemoteSchemaName]
forall a. Semigroup a => a -> a -> a
<> [RemoteSchemaName]
inconsistentRemoteSchemas
class (Monad m) => SourceM m where
askCurrentSource :: m SourceName
instance (SourceM m) => SourceM (ReaderT r m) where
askCurrentSource :: ReaderT r m SourceName
askCurrentSource = m SourceName -> ReaderT r m SourceName
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m SourceName
forall (m :: * -> *). SourceM m => m SourceName
askCurrentSource
instance (SourceM m) => SourceM (StateT s m) where
askCurrentSource :: StateT s m SourceName
askCurrentSource = m SourceName -> StateT s m SourceName
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m SourceName
forall (m :: * -> *). SourceM m => m SourceName
askCurrentSource
instance (Monoid w, SourceM m) => SourceM (WriterT w m) where
askCurrentSource :: WriterT w m SourceName
askCurrentSource = m SourceName -> WriterT w m SourceName
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m SourceName
forall (m :: * -> *). SourceM m => m SourceName
askCurrentSource
instance (SourceM m) => SourceM (TraceT m) where
askCurrentSource :: TraceT m SourceName
askCurrentSource = m SourceName -> TraceT m SourceName
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m SourceName
forall (m :: * -> *). SourceM m => m SourceName
askCurrentSource
newtype SourceT m a = SourceT {SourceT m a -> SourceName -> m a
runSourceT :: SourceName -> m a}
deriving
(a -> SourceT m b -> SourceT m a
(a -> b) -> SourceT m a -> SourceT m b
(forall a b. (a -> b) -> SourceT m a -> SourceT m b)
-> (forall a b. a -> SourceT m b -> SourceT m a)
-> Functor (SourceT m)
forall a b. a -> SourceT m b -> SourceT m a
forall a b. (a -> b) -> SourceT m a -> SourceT m b
forall (m :: * -> *) a b.
Functor m =>
a -> SourceT m b -> SourceT m a
forall (m :: * -> *) a b.
Functor m =>
(a -> b) -> SourceT m a -> SourceT m b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> SourceT m b -> SourceT m a
$c<$ :: forall (m :: * -> *) a b.
Functor m =>
a -> SourceT m b -> SourceT m a
fmap :: (a -> b) -> SourceT m a -> SourceT m b
$cfmap :: forall (m :: * -> *) a b.
Functor m =>
(a -> b) -> SourceT m a -> SourceT m b
Functor, Functor (SourceT m)
a -> SourceT m a
Functor (SourceT m)
-> (forall a. a -> SourceT m a)
-> (forall a b. SourceT m (a -> b) -> SourceT m a -> SourceT m b)
-> (forall a b c.
(a -> b -> c) -> SourceT m a -> SourceT m b -> SourceT m c)
-> (forall a b. SourceT m a -> SourceT m b -> SourceT m b)
-> (forall a b. SourceT m a -> SourceT m b -> SourceT m a)
-> Applicative (SourceT m)
SourceT m a -> SourceT m b -> SourceT m b
SourceT m a -> SourceT m b -> SourceT m a
SourceT m (a -> b) -> SourceT m a -> SourceT m b
(a -> b -> c) -> SourceT m a -> SourceT m b -> SourceT m c
forall a. a -> SourceT m a
forall a b. SourceT m a -> SourceT m b -> SourceT m a
forall a b. SourceT m a -> SourceT m b -> SourceT m b
forall a b. SourceT m (a -> b) -> SourceT m a -> SourceT m b
forall a b c.
(a -> b -> c) -> SourceT m a -> SourceT m b -> SourceT m c
forall (f :: * -> *).
Functor f
-> (forall a. a -> f a)
-> (forall a b. f (a -> b) -> f a -> f b)
-> (forall a b c. (a -> b -> c) -> f a -> f b -> f c)
-> (forall a b. f a -> f b -> f b)
-> (forall a b. f a -> f b -> f a)
-> Applicative f
forall (m :: * -> *). Applicative m => Functor (SourceT m)
forall (m :: * -> *) a. Applicative m => a -> SourceT m a
forall (m :: * -> *) a b.
Applicative m =>
SourceT m a -> SourceT m b -> SourceT m a
forall (m :: * -> *) a b.
Applicative m =>
SourceT m a -> SourceT m b -> SourceT m b
forall (m :: * -> *) a b.
Applicative m =>
SourceT m (a -> b) -> SourceT m a -> SourceT m b
forall (m :: * -> *) a b c.
Applicative m =>
(a -> b -> c) -> SourceT m a -> SourceT m b -> SourceT m c
<* :: SourceT m a -> SourceT m b -> SourceT m a
$c<* :: forall (m :: * -> *) a b.
Applicative m =>
SourceT m a -> SourceT m b -> SourceT m a
*> :: SourceT m a -> SourceT m b -> SourceT m b
$c*> :: forall (m :: * -> *) a b.
Applicative m =>
SourceT m a -> SourceT m b -> SourceT m b
liftA2 :: (a -> b -> c) -> SourceT m a -> SourceT m b -> SourceT m c
$cliftA2 :: forall (m :: * -> *) a b c.
Applicative m =>
(a -> b -> c) -> SourceT m a -> SourceT m b -> SourceT m c
<*> :: SourceT m (a -> b) -> SourceT m a -> SourceT m b
$c<*> :: forall (m :: * -> *) a b.
Applicative m =>
SourceT m (a -> b) -> SourceT m a -> SourceT m b
pure :: a -> SourceT m a
$cpure :: forall (m :: * -> *) a. Applicative m => a -> SourceT m a
$cp1Applicative :: forall (m :: * -> *). Applicative m => Functor (SourceT m)
Applicative, Applicative (SourceT m)
a -> SourceT m a
Applicative (SourceT m)
-> (forall a b. SourceT m a -> (a -> SourceT m b) -> SourceT m b)
-> (forall a b. SourceT m a -> SourceT m b -> SourceT m b)
-> (forall a. a -> SourceT m a)
-> Monad (SourceT m)
SourceT m a -> (a -> SourceT m b) -> SourceT m b
SourceT m a -> SourceT m b -> SourceT m b
forall a. a -> SourceT m a
forall a b. SourceT m a -> SourceT m b -> SourceT m b
forall a b. SourceT m a -> (a -> SourceT m b) -> SourceT m b
forall (m :: * -> *). Monad m => Applicative (SourceT m)
forall (m :: * -> *) a. Monad m => a -> SourceT m a
forall (m :: * -> *) a b.
Monad m =>
SourceT m a -> SourceT m b -> SourceT m b
forall (m :: * -> *) a b.
Monad m =>
SourceT m a -> (a -> SourceT m b) -> SourceT m b
forall (m :: * -> *).
Applicative m
-> (forall a b. m a -> (a -> m b) -> m b)
-> (forall a b. m a -> m b -> m b)
-> (forall a. a -> m a)
-> Monad m
return :: a -> SourceT m a
$creturn :: forall (m :: * -> *) a. Monad m => a -> SourceT m a
>> :: SourceT m a -> SourceT m b -> SourceT m b
$c>> :: forall (m :: * -> *) a b.
Monad m =>
SourceT m a -> SourceT m b -> SourceT m b
>>= :: SourceT m a -> (a -> SourceT m b) -> SourceT m b
$c>>= :: forall (m :: * -> *) a b.
Monad m =>
SourceT m a -> (a -> SourceT m b) -> SourceT m b
$cp1Monad :: forall (m :: * -> *). Monad m => Applicative (SourceT m)
Monad, Monad (SourceT m)
Monad (SourceT m)
-> (forall a. IO a -> SourceT m a) -> MonadIO (SourceT m)
IO a -> SourceT m a
forall a. IO a -> SourceT m a
forall (m :: * -> *).
Monad m -> (forall a. IO a -> m a) -> MonadIO m
forall (m :: * -> *). MonadIO m => Monad (SourceT m)
forall (m :: * -> *) a. MonadIO m => IO a -> SourceT m a
liftIO :: IO a -> SourceT m a
$cliftIO :: forall (m :: * -> *) a. MonadIO m => IO a -> SourceT m a
$cp1MonadIO :: forall (m :: * -> *). MonadIO m => Monad (SourceT m)
MonadIO, MonadError e, MonadState s, MonadWriter w, MonadError QErr (SourceT m)
MonadError QErr (SourceT m)
-> (forall a. TxE QErr a -> SourceT m a) -> MonadTx (SourceT m)
TxE QErr a -> SourceT m a
forall a. TxE QErr a -> SourceT m a
forall (m :: * -> *).
MonadError QErr m -> (forall a. TxE QErr a -> m a) -> MonadTx m
forall (m :: * -> *). MonadTx m => MonadError QErr (SourceT m)
forall (m :: * -> *) a. MonadTx m => TxE QErr a -> SourceT m a
liftTx :: TxE QErr a -> SourceT m a
$cliftTx :: forall (m :: * -> *) a. MonadTx m => TxE QErr a -> SourceT m a
$cp1MonadTx :: forall (m :: * -> *). MonadTx m => MonadError QErr (SourceT m)
PG.MonadTx, TableCoreInfoRM b, Monad (SourceT m)
SourceT m SchemaCache
Monad (SourceT m) -> SourceT m SchemaCache -> CacheRM (SourceT m)
forall (m :: * -> *). Monad m -> m SchemaCache -> CacheRM m
forall (m :: * -> *). CacheRM m => Monad (SourceT m)
forall (m :: * -> *). CacheRM m => SourceT m SchemaCache
askSchemaCache :: SourceT m SchemaCache
$caskSchemaCache :: forall (m :: * -> *). CacheRM m => SourceT m SchemaCache
$cp1CacheRM :: forall (m :: * -> *). CacheRM m => Monad (SourceT m)
CacheRM)
via (ReaderT SourceName m)
deriving (m a -> SourceT m a
(forall (m :: * -> *) a. Monad m => m a -> SourceT m a)
-> MonadTrans SourceT
forall (m :: * -> *) a. Monad m => m a -> SourceT m a
forall (t :: (* -> *) -> * -> *).
(forall (m :: * -> *) a. Monad m => m a -> t m a) -> MonadTrans t
lift :: m a -> SourceT m a
$clift :: forall (m :: * -> *) a. Monad m => m a -> SourceT m a
MonadTrans) via (ReaderT SourceName)
instance (Monad m) => SourceM (SourceT m) where
askCurrentSource :: SourceT m SourceName
askCurrentSource = (SourceName -> m SourceName) -> SourceT m SourceName
forall (m :: * -> *) a. (SourceName -> m a) -> SourceT m a
SourceT SourceName -> m SourceName
forall (f :: * -> *) a. Applicative f => a -> f a
pure
class (SourceM m) => TableCoreInfoRM b m where
lookupTableCoreInfo :: TableName b -> m (Maybe (TableCoreInfo b))
instance (TableCoreInfoRM b m) => TableCoreInfoRM b (ReaderT r m) where
lookupTableCoreInfo :: TableName b -> ReaderT r m (Maybe (TableCoreInfo b))
lookupTableCoreInfo = m (Maybe (TableCoreInfo b))
-> ReaderT r m (Maybe (TableCoreInfo b))
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Maybe (TableCoreInfo b))
-> ReaderT r m (Maybe (TableCoreInfo b)))
-> (TableName b -> m (Maybe (TableCoreInfo b)))
-> TableName b
-> ReaderT r m (Maybe (TableCoreInfo b))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TableName b -> m (Maybe (TableCoreInfo b))
forall (b :: BackendType) (m :: * -> *).
TableCoreInfoRM b m =>
TableName b -> m (Maybe (TableCoreInfo b))
lookupTableCoreInfo
instance (TableCoreInfoRM b m) => TableCoreInfoRM b (StateT s m) where
lookupTableCoreInfo :: TableName b -> StateT s m (Maybe (TableCoreInfo b))
lookupTableCoreInfo = m (Maybe (TableCoreInfo b)) -> StateT s m (Maybe (TableCoreInfo b))
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Maybe (TableCoreInfo b))
-> StateT s m (Maybe (TableCoreInfo b)))
-> (TableName b -> m (Maybe (TableCoreInfo b)))
-> TableName b
-> StateT s m (Maybe (TableCoreInfo b))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TableName b -> m (Maybe (TableCoreInfo b))
forall (b :: BackendType) (m :: * -> *).
TableCoreInfoRM b m =>
TableName b -> m (Maybe (TableCoreInfo b))
lookupTableCoreInfo
instance (Monoid w, TableCoreInfoRM b m) => TableCoreInfoRM b (WriterT w m) where
lookupTableCoreInfo :: TableName b -> WriterT w m (Maybe (TableCoreInfo b))
lookupTableCoreInfo = m (Maybe (TableCoreInfo b))
-> WriterT w m (Maybe (TableCoreInfo b))
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Maybe (TableCoreInfo b))
-> WriterT w m (Maybe (TableCoreInfo b)))
-> (TableName b -> m (Maybe (TableCoreInfo b)))
-> TableName b
-> WriterT w m (Maybe (TableCoreInfo b))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TableName b -> m (Maybe (TableCoreInfo b))
forall (b :: BackendType) (m :: * -> *).
TableCoreInfoRM b m =>
TableName b -> m (Maybe (TableCoreInfo b))
lookupTableCoreInfo
instance (TableCoreInfoRM b m) => TableCoreInfoRM b (TraceT m) where
lookupTableCoreInfo :: TableName b -> TraceT m (Maybe (TableCoreInfo b))
lookupTableCoreInfo = m (Maybe (TableCoreInfo b)) -> TraceT m (Maybe (TableCoreInfo b))
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Maybe (TableCoreInfo b)) -> TraceT m (Maybe (TableCoreInfo b)))
-> (TableName b -> m (Maybe (TableCoreInfo b)))
-> TableName b
-> TraceT m (Maybe (TableCoreInfo b))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TableName b -> m (Maybe (TableCoreInfo b))
forall (b :: BackendType) (m :: * -> *).
TableCoreInfoRM b m =>
TableName b -> m (Maybe (TableCoreInfo b))
lookupTableCoreInfo
newtype TableCoreCacheRT b m a = TableCoreCacheRT {TableCoreCacheRT b m a
-> (SourceName, Dependency (TableCoreCache b)) -> m a
runTableCoreCacheRT :: (SourceName, Dependency (TableCoreCache b)) -> m a}
deriving
(a -> TableCoreCacheRT b m b -> TableCoreCacheRT b m a
(a -> b) -> TableCoreCacheRT b m a -> TableCoreCacheRT b m b
(forall a b.
(a -> b) -> TableCoreCacheRT b m a -> TableCoreCacheRT b m b)
-> (forall a b.
a -> TableCoreCacheRT b m b -> TableCoreCacheRT b m a)
-> Functor (TableCoreCacheRT b m)
forall a b. a -> TableCoreCacheRT b m b -> TableCoreCacheRT b m a
forall a b.
(a -> b) -> TableCoreCacheRT b m a -> TableCoreCacheRT b m b
forall (b :: BackendType) (m :: * -> *) a b.
Functor m =>
a -> TableCoreCacheRT b m b -> TableCoreCacheRT b m a
forall (b :: BackendType) (m :: * -> *) a b.
Functor m =>
(a -> b) -> TableCoreCacheRT b m a -> TableCoreCacheRT b m b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> TableCoreCacheRT b m b -> TableCoreCacheRT b m a
$c<$ :: forall (b :: BackendType) (m :: * -> *) a b.
Functor m =>
a -> TableCoreCacheRT b m b -> TableCoreCacheRT b m a
fmap :: (a -> b) -> TableCoreCacheRT b m a -> TableCoreCacheRT b m b
$cfmap :: forall (b :: BackendType) (m :: * -> *) a b.
Functor m =>
(a -> b) -> TableCoreCacheRT b m a -> TableCoreCacheRT b m b
Functor, Functor (TableCoreCacheRT b m)
a -> TableCoreCacheRT b m a
Functor (TableCoreCacheRT b m)
-> (forall a. a -> TableCoreCacheRT b m a)
-> (forall a b.
TableCoreCacheRT b m (a -> b)
-> TableCoreCacheRT b m a -> TableCoreCacheRT b m b)
-> (forall a b c.
(a -> b -> c)
-> TableCoreCacheRT b m a
-> TableCoreCacheRT b m b
-> TableCoreCacheRT b m c)
-> (forall a b.
TableCoreCacheRT b m a
-> TableCoreCacheRT b m b -> TableCoreCacheRT b m b)
-> (forall a b.
TableCoreCacheRT b m a
-> TableCoreCacheRT b m b -> TableCoreCacheRT b m a)
-> Applicative (TableCoreCacheRT b m)
TableCoreCacheRT b m a
-> TableCoreCacheRT b m b -> TableCoreCacheRT b m b
TableCoreCacheRT b m a
-> TableCoreCacheRT b m b -> TableCoreCacheRT b m a
TableCoreCacheRT b m (a -> b)
-> TableCoreCacheRT b m a -> TableCoreCacheRT b m b
(a -> b -> c)
-> TableCoreCacheRT b m a
-> TableCoreCacheRT b m b
-> TableCoreCacheRT b m c
forall a. a -> TableCoreCacheRT b m a
forall a b.
TableCoreCacheRT b m a
-> TableCoreCacheRT b m b -> TableCoreCacheRT b m a
forall a b.
TableCoreCacheRT b m a
-> TableCoreCacheRT b m b -> TableCoreCacheRT b m b
forall a b.
TableCoreCacheRT b m (a -> b)
-> TableCoreCacheRT b m a -> TableCoreCacheRT b m b
forall a b c.
(a -> b -> c)
-> TableCoreCacheRT b m a
-> TableCoreCacheRT b m b
-> TableCoreCacheRT b m c
forall (b :: BackendType) (m :: * -> *).
Applicative m =>
Functor (TableCoreCacheRT b m)
forall (b :: BackendType) (m :: * -> *) a.
Applicative m =>
a -> TableCoreCacheRT b m a
forall (b :: BackendType) (m :: * -> *) a b.
Applicative m =>
TableCoreCacheRT b m a
-> TableCoreCacheRT b m b -> TableCoreCacheRT b m a
forall (b :: BackendType) (m :: * -> *) a b.
Applicative m =>
TableCoreCacheRT b m a
-> TableCoreCacheRT b m b -> TableCoreCacheRT b m b
forall (b :: BackendType) (m :: * -> *) a b.
Applicative m =>
TableCoreCacheRT b m (a -> b)
-> TableCoreCacheRT b m a -> TableCoreCacheRT b m b
forall (b :: BackendType) (m :: * -> *) a b c.
Applicative m =>
(a -> b -> c)
-> TableCoreCacheRT b m a
-> TableCoreCacheRT b m b
-> TableCoreCacheRT b m c
forall (f :: * -> *).
Functor f
-> (forall a. a -> f a)
-> (forall a b. f (a -> b) -> f a -> f b)
-> (forall a b c. (a -> b -> c) -> f a -> f b -> f c)
-> (forall a b. f a -> f b -> f b)
-> (forall a b. f a -> f b -> f a)
-> Applicative f
<* :: TableCoreCacheRT b m a
-> TableCoreCacheRT b m b -> TableCoreCacheRT b m a
$c<* :: forall (b :: BackendType) (m :: * -> *) a b.
Applicative m =>
TableCoreCacheRT b m a
-> TableCoreCacheRT b m b -> TableCoreCacheRT b m a
*> :: TableCoreCacheRT b m a
-> TableCoreCacheRT b m b -> TableCoreCacheRT b m b
$c*> :: forall (b :: BackendType) (m :: * -> *) a b.
Applicative m =>
TableCoreCacheRT b m a
-> TableCoreCacheRT b m b -> TableCoreCacheRT b m b
liftA2 :: (a -> b -> c)
-> TableCoreCacheRT b m a
-> TableCoreCacheRT b m b
-> TableCoreCacheRT b m c
$cliftA2 :: forall (b :: BackendType) (m :: * -> *) a b c.
Applicative m =>
(a -> b -> c)
-> TableCoreCacheRT b m a
-> TableCoreCacheRT b m b
-> TableCoreCacheRT b m c
<*> :: TableCoreCacheRT b m (a -> b)
-> TableCoreCacheRT b m a -> TableCoreCacheRT b m b
$c<*> :: forall (b :: BackendType) (m :: * -> *) a b.
Applicative m =>
TableCoreCacheRT b m (a -> b)
-> TableCoreCacheRT b m a -> TableCoreCacheRT b m b
pure :: a -> TableCoreCacheRT b m a
$cpure :: forall (b :: BackendType) (m :: * -> *) a.
Applicative m =>
a -> TableCoreCacheRT b m a
$cp1Applicative :: forall (b :: BackendType) (m :: * -> *).
Applicative m =>
Functor (TableCoreCacheRT b m)
Applicative, Applicative (TableCoreCacheRT b m)
a -> TableCoreCacheRT b m a
Applicative (TableCoreCacheRT b m)
-> (forall a b.
TableCoreCacheRT b m a
-> (a -> TableCoreCacheRT b m b) -> TableCoreCacheRT b m b)
-> (forall a b.
TableCoreCacheRT b m a
-> TableCoreCacheRT b m b -> TableCoreCacheRT b m b)
-> (forall a. a -> TableCoreCacheRT b m a)
-> Monad (TableCoreCacheRT b m)
TableCoreCacheRT b m a
-> (a -> TableCoreCacheRT b m b) -> TableCoreCacheRT b m b
TableCoreCacheRT b m a
-> TableCoreCacheRT b m b -> TableCoreCacheRT b m b
forall a. a -> TableCoreCacheRT b m a
forall a b.
TableCoreCacheRT b m a
-> TableCoreCacheRT b m b -> TableCoreCacheRT b m b
forall a b.
TableCoreCacheRT b m a
-> (a -> TableCoreCacheRT b m b) -> TableCoreCacheRT b m b
forall (b :: BackendType) (m :: * -> *).
Monad m =>
Applicative (TableCoreCacheRT b m)
forall (b :: BackendType) (m :: * -> *) a.
Monad m =>
a -> TableCoreCacheRT b m a
forall (b :: BackendType) (m :: * -> *) a b.
Monad m =>
TableCoreCacheRT b m a
-> TableCoreCacheRT b m b -> TableCoreCacheRT b m b
forall (b :: BackendType) (m :: * -> *) a b.
Monad m =>
TableCoreCacheRT b m a
-> (a -> TableCoreCacheRT b m b) -> TableCoreCacheRT b m b
forall (m :: * -> *).
Applicative m
-> (forall a b. m a -> (a -> m b) -> m b)
-> (forall a b. m a -> m b -> m b)
-> (forall a. a -> m a)
-> Monad m
return :: a -> TableCoreCacheRT b m a
$creturn :: forall (b :: BackendType) (m :: * -> *) a.
Monad m =>
a -> TableCoreCacheRT b m a
>> :: TableCoreCacheRT b m a
-> TableCoreCacheRT b m b -> TableCoreCacheRT b m b
$c>> :: forall (b :: BackendType) (m :: * -> *) a b.
Monad m =>
TableCoreCacheRT b m a
-> TableCoreCacheRT b m b -> TableCoreCacheRT b m b
>>= :: TableCoreCacheRT b m a
-> (a -> TableCoreCacheRT b m b) -> TableCoreCacheRT b m b
$c>>= :: forall (b :: BackendType) (m :: * -> *) a b.
Monad m =>
TableCoreCacheRT b m a
-> (a -> TableCoreCacheRT b m b) -> TableCoreCacheRT b m b
$cp1Monad :: forall (b :: BackendType) (m :: * -> *).
Monad m =>
Applicative (TableCoreCacheRT b m)
Monad, Monad (TableCoreCacheRT b m)
Monad (TableCoreCacheRT b m)
-> (forall a. IO a -> TableCoreCacheRT b m a)
-> MonadIO (TableCoreCacheRT b m)
IO a -> TableCoreCacheRT b m a
forall a. IO a -> TableCoreCacheRT b m a
forall (b :: BackendType) (m :: * -> *).
MonadIO m =>
Monad (TableCoreCacheRT b m)
forall (b :: BackendType) (m :: * -> *) a.
MonadIO m =>
IO a -> TableCoreCacheRT b m a
forall (m :: * -> *).
Monad m -> (forall a. IO a -> m a) -> MonadIO m
liftIO :: IO a -> TableCoreCacheRT b m a
$cliftIO :: forall (b :: BackendType) (m :: * -> *) a.
MonadIO m =>
IO a -> TableCoreCacheRT b m a
$cp1MonadIO :: forall (b :: BackendType) (m :: * -> *).
MonadIO m =>
Monad (TableCoreCacheRT b m)
MonadIO, MonadError e, MonadState s, MonadWriter w, MonadError QErr (TableCoreCacheRT b m)
MonadError QErr (TableCoreCacheRT b m)
-> (forall a. TxE QErr a -> TableCoreCacheRT b m a)
-> MonadTx (TableCoreCacheRT b m)
TxE QErr a -> TableCoreCacheRT b m a
forall a. TxE QErr a -> TableCoreCacheRT b m a
forall (b :: BackendType) (m :: * -> *).
MonadTx m =>
MonadError QErr (TableCoreCacheRT b m)
forall (b :: BackendType) (m :: * -> *) a.
MonadTx m =>
TxE QErr a -> TableCoreCacheRT b m a
forall (m :: * -> *).
MonadError QErr m -> (forall a. TxE QErr a -> m a) -> MonadTx m
liftTx :: TxE QErr a -> TableCoreCacheRT b m a
$cliftTx :: forall (b :: BackendType) (m :: * -> *) a.
MonadTx m =>
TxE QErr a -> TableCoreCacheRT b m a
$cp1MonadTx :: forall (b :: BackendType) (m :: * -> *).
MonadTx m =>
MonadError QErr (TableCoreCacheRT b m)
PG.MonadTx)
via (ReaderT (SourceName, Dependency (TableCoreCache b)) m)
deriving (m a -> TableCoreCacheRT b m a
(forall (m :: * -> *) a. Monad m => m a -> TableCoreCacheRT b m a)
-> MonadTrans (TableCoreCacheRT b)
forall (b :: BackendType) (m :: * -> *) a.
Monad m =>
m a -> TableCoreCacheRT b m a
forall (m :: * -> *) a. Monad m => m a -> TableCoreCacheRT b m a
forall (t :: (* -> *) -> * -> *).
(forall (m :: * -> *) a. Monad m => m a -> t m a) -> MonadTrans t
lift :: m a -> TableCoreCacheRT b m a
$clift :: forall (b :: BackendType) (m :: * -> *) a.
Monad m =>
m a -> TableCoreCacheRT b m a
MonadTrans) via (ReaderT (SourceName, Dependency (TableCoreCache b)))
instance (MonadReader r m) => MonadReader r (TableCoreCacheRT b m) where
ask :: TableCoreCacheRT b m r
ask = m r -> TableCoreCacheRT b m r
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m r
forall r (m :: * -> *). MonadReader r m => m r
ask
local :: (r -> r) -> TableCoreCacheRT b m a -> TableCoreCacheRT b m a
local r -> r
f TableCoreCacheRT b m a
m = ((SourceName, Dependency (TableCoreCache b)) -> m a)
-> TableCoreCacheRT b m a
forall (b :: BackendType) (m :: * -> *) a.
((SourceName, Dependency (TableCoreCache b)) -> m a)
-> TableCoreCacheRT b m a
TableCoreCacheRT ((r -> r) -> m a -> m a
forall r (m :: * -> *) a. MonadReader r m => (r -> r) -> m a -> m a
local r -> r
f (m a -> m a)
-> ((SourceName, Dependency (TableCoreCache b)) -> m a)
-> (SourceName, Dependency (TableCoreCache b))
-> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TableCoreCacheRT b m a
-> (SourceName, Dependency (TableCoreCache b)) -> m a
forall (b :: BackendType) (m :: * -> *) a.
TableCoreCacheRT b m a
-> (SourceName, Dependency (TableCoreCache b)) -> m a
runTableCoreCacheRT TableCoreCacheRT b m a
m)
instance (Monad m) => SourceM (TableCoreCacheRT b m) where
askCurrentSource :: TableCoreCacheRT b m SourceName
askCurrentSource =
((SourceName, Dependency (TableCoreCache b)) -> m SourceName)
-> TableCoreCacheRT b m SourceName
forall (b :: BackendType) (m :: * -> *) a.
((SourceName, Dependency (TableCoreCache b)) -> m a)
-> TableCoreCacheRT b m a
TableCoreCacheRT (SourceName -> m SourceName
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SourceName -> m SourceName)
-> ((SourceName, Dependency (TableCoreCache b)) -> SourceName)
-> (SourceName, Dependency (TableCoreCache b))
-> m SourceName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (SourceName, Dependency (TableCoreCache b)) -> SourceName
forall a b. (a, b) -> a
fst)
instance (MonadDepend m, Backend b) => TableCoreInfoRM b (TableCoreCacheRT b m) where
lookupTableCoreInfo :: TableName b -> TableCoreCacheRT b m (Maybe (TableCoreInfo b))
lookupTableCoreInfo TableName b
tableName =
((SourceName, Dependency (TableCoreCache b))
-> m (Maybe (TableCoreInfo b)))
-> TableCoreCacheRT b m (Maybe (TableCoreInfo b))
forall (b :: BackendType) (m :: * -> *) a.
((SourceName, Dependency (TableCoreCache b)) -> m a)
-> TableCoreCacheRT b m a
TableCoreCacheRT (Dependency (Maybe (TableCoreInfo b)) -> m (Maybe (TableCoreInfo b))
forall (m :: * -> *) a.
(MonadDepend m, Cacheable a) =>
Dependency a -> m a
dependOnM (Dependency (Maybe (TableCoreInfo b))
-> m (Maybe (TableCoreInfo b)))
-> ((SourceName, Dependency (TableCoreCache b))
-> Dependency (Maybe (TableCoreInfo b)))
-> (SourceName, Dependency (TableCoreCache b))
-> m (Maybe (TableCoreInfo b))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TableName b
-> Dependency (TableCoreCache b)
-> Dependency (Maybe (TableCoreInfo b))
forall a k v.
(Select a, Selector a ~ ConstS k v) =>
k -> Dependency a -> Dependency v
selectKeyD TableName b
tableName (Dependency (TableCoreCache b)
-> Dependency (Maybe (TableCoreInfo b)))
-> ((SourceName, Dependency (TableCoreCache b))
-> Dependency (TableCoreCache b))
-> (SourceName, Dependency (TableCoreCache b))
-> Dependency (Maybe (TableCoreInfo b))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (SourceName, Dependency (TableCoreCache b))
-> Dependency (TableCoreCache b)
forall a b. (a, b) -> b
snd)
class (TableCoreInfoRM b m) => TableInfoRM b m where
lookupTableInfo :: TableName b -> m (Maybe (TableInfo b))
instance (TableInfoRM b m) => TableInfoRM b (ReaderT r m) where
lookupTableInfo :: TableName b -> ReaderT r m (Maybe (TableInfo b))
lookupTableInfo TableName b
tableName = m (Maybe (TableInfo b)) -> ReaderT r m (Maybe (TableInfo b))
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Maybe (TableInfo b)) -> ReaderT r m (Maybe (TableInfo b)))
-> m (Maybe (TableInfo b)) -> ReaderT r m (Maybe (TableInfo b))
forall a b. (a -> b) -> a -> b
$ TableName b -> m (Maybe (TableInfo b))
forall (b :: BackendType) (m :: * -> *).
TableInfoRM b m =>
TableName b -> m (Maybe (TableInfo b))
lookupTableInfo TableName b
tableName
instance (TableInfoRM b m) => TableInfoRM b (StateT s m) where
lookupTableInfo :: TableName b -> StateT s m (Maybe (TableInfo b))
lookupTableInfo TableName b
tableName = m (Maybe (TableInfo b)) -> StateT s m (Maybe (TableInfo b))
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Maybe (TableInfo b)) -> StateT s m (Maybe (TableInfo b)))
-> m (Maybe (TableInfo b)) -> StateT s m (Maybe (TableInfo b))
forall a b. (a -> b) -> a -> b
$ TableName b -> m (Maybe (TableInfo b))
forall (b :: BackendType) (m :: * -> *).
TableInfoRM b m =>
TableName b -> m (Maybe (TableInfo b))
lookupTableInfo TableName b
tableName
instance (Monoid w, TableInfoRM b m) => TableInfoRM b (WriterT w m) where
lookupTableInfo :: TableName b -> WriterT w m (Maybe (TableInfo b))
lookupTableInfo TableName b
tableName = m (Maybe (TableInfo b)) -> WriterT w m (Maybe (TableInfo b))
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Maybe (TableInfo b)) -> WriterT w m (Maybe (TableInfo b)))
-> m (Maybe (TableInfo b)) -> WriterT w m (Maybe (TableInfo b))
forall a b. (a -> b) -> a -> b
$ TableName b -> m (Maybe (TableInfo b))
forall (b :: BackendType) (m :: * -> *).
TableInfoRM b m =>
TableName b -> m (Maybe (TableInfo b))
lookupTableInfo TableName b
tableName
instance (TableInfoRM b m) => TableInfoRM b (TraceT m) where
lookupTableInfo :: TableName b -> TraceT m (Maybe (TableInfo b))
lookupTableInfo TableName b
tableName = m (Maybe (TableInfo b)) -> TraceT m (Maybe (TableInfo b))
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Maybe (TableInfo b)) -> TraceT m (Maybe (TableInfo b)))
-> m (Maybe (TableInfo b)) -> TraceT m (Maybe (TableInfo b))
forall a b. (a -> b) -> a -> b
$ TableName b -> m (Maybe (TableInfo b))
forall (b :: BackendType) (m :: * -> *).
TableInfoRM b m =>
TableName b -> m (Maybe (TableInfo b))
lookupTableInfo TableName b
tableName
newtype TableCacheRT b m a = TableCacheRT {TableCacheRT b m a -> (SourceName, TableCache b) -> m a
runTableCacheRT :: (SourceName, TableCache b) -> m a}
deriving
(a -> TableCacheRT b m b -> TableCacheRT b m a
(a -> b) -> TableCacheRT b m a -> TableCacheRT b m b
(forall a b. (a -> b) -> TableCacheRT b m a -> TableCacheRT b m b)
-> (forall a b. a -> TableCacheRT b m b -> TableCacheRT b m a)
-> Functor (TableCacheRT b m)
forall a b. a -> TableCacheRT b m b -> TableCacheRT b m a
forall a b. (a -> b) -> TableCacheRT b m a -> TableCacheRT b m b
forall (b :: BackendType) (m :: * -> *) a b.
Functor m =>
a -> TableCacheRT b m b -> TableCacheRT b m a
forall (b :: BackendType) (m :: * -> *) a b.
Functor m =>
(a -> b) -> TableCacheRT b m a -> TableCacheRT b m b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> TableCacheRT b m b -> TableCacheRT b m a
$c<$ :: forall (b :: BackendType) (m :: * -> *) a b.
Functor m =>
a -> TableCacheRT b m b -> TableCacheRT b m a
fmap :: (a -> b) -> TableCacheRT b m a -> TableCacheRT b m b
$cfmap :: forall (b :: BackendType) (m :: * -> *) a b.
Functor m =>
(a -> b) -> TableCacheRT b m a -> TableCacheRT b m b
Functor, Functor (TableCacheRT b m)
a -> TableCacheRT b m a
Functor (TableCacheRT b m)
-> (forall a. a -> TableCacheRT b m a)
-> (forall a b.
TableCacheRT b m (a -> b)
-> TableCacheRT b m a -> TableCacheRT b m b)
-> (forall a b c.
(a -> b -> c)
-> TableCacheRT b m a -> TableCacheRT b m b -> TableCacheRT b m c)
-> (forall a b.
TableCacheRT b m a -> TableCacheRT b m b -> TableCacheRT b m b)
-> (forall a b.
TableCacheRT b m a -> TableCacheRT b m b -> TableCacheRT b m a)
-> Applicative (TableCacheRT b m)
TableCacheRT b m a -> TableCacheRT b m b -> TableCacheRT b m b
TableCacheRT b m a -> TableCacheRT b m b -> TableCacheRT b m a
TableCacheRT b m (a -> b)
-> TableCacheRT b m a -> TableCacheRT b m b
(a -> b -> c)
-> TableCacheRT b m a -> TableCacheRT b m b -> TableCacheRT b m c
forall a. a -> TableCacheRT b m a
forall a b.
TableCacheRT b m a -> TableCacheRT b m b -> TableCacheRT b m a
forall a b.
TableCacheRT b m a -> TableCacheRT b m b -> TableCacheRT b m b
forall a b.
TableCacheRT b m (a -> b)
-> TableCacheRT b m a -> TableCacheRT b m b
forall a b c.
(a -> b -> c)
-> TableCacheRT b m a -> TableCacheRT b m b -> TableCacheRT b m c
forall (b :: BackendType) (m :: * -> *).
Applicative m =>
Functor (TableCacheRT b m)
forall (b :: BackendType) (m :: * -> *) a.
Applicative m =>
a -> TableCacheRT b m a
forall (b :: BackendType) (m :: * -> *) a b.
Applicative m =>
TableCacheRT b m a -> TableCacheRT b m b -> TableCacheRT b m a
forall (b :: BackendType) (m :: * -> *) a b.
Applicative m =>
TableCacheRT b m a -> TableCacheRT b m b -> TableCacheRT b m b
forall (b :: BackendType) (m :: * -> *) a b.
Applicative m =>
TableCacheRT b m (a -> b)
-> TableCacheRT b m a -> TableCacheRT b m b
forall (b :: BackendType) (m :: * -> *) a b c.
Applicative m =>
(a -> b -> c)
-> TableCacheRT b m a -> TableCacheRT b m b -> TableCacheRT b m c
forall (f :: * -> *).
Functor f
-> (forall a. a -> f a)
-> (forall a b. f (a -> b) -> f a -> f b)
-> (forall a b c. (a -> b -> c) -> f a -> f b -> f c)
-> (forall a b. f a -> f b -> f b)
-> (forall a b. f a -> f b -> f a)
-> Applicative f
<* :: TableCacheRT b m a -> TableCacheRT b m b -> TableCacheRT b m a
$c<* :: forall (b :: BackendType) (m :: * -> *) a b.
Applicative m =>
TableCacheRT b m a -> TableCacheRT b m b -> TableCacheRT b m a
*> :: TableCacheRT b m a -> TableCacheRT b m b -> TableCacheRT b m b
$c*> :: forall (b :: BackendType) (m :: * -> *) a b.
Applicative m =>
TableCacheRT b m a -> TableCacheRT b m b -> TableCacheRT b m b
liftA2 :: (a -> b -> c)
-> TableCacheRT b m a -> TableCacheRT b m b -> TableCacheRT b m c
$cliftA2 :: forall (b :: BackendType) (m :: * -> *) a b c.
Applicative m =>
(a -> b -> c)
-> TableCacheRT b m a -> TableCacheRT b m b -> TableCacheRT b m c
<*> :: TableCacheRT b m (a -> b)
-> TableCacheRT b m a -> TableCacheRT b m b
$c<*> :: forall (b :: BackendType) (m :: * -> *) a b.
Applicative m =>
TableCacheRT b m (a -> b)
-> TableCacheRT b m a -> TableCacheRT b m b
pure :: a -> TableCacheRT b m a
$cpure :: forall (b :: BackendType) (m :: * -> *) a.
Applicative m =>
a -> TableCacheRT b m a
$cp1Applicative :: forall (b :: BackendType) (m :: * -> *).
Applicative m =>
Functor (TableCacheRT b m)
Applicative, Applicative (TableCacheRT b m)
a -> TableCacheRT b m a
Applicative (TableCacheRT b m)
-> (forall a b.
TableCacheRT b m a
-> (a -> TableCacheRT b m b) -> TableCacheRT b m b)
-> (forall a b.
TableCacheRT b m a -> TableCacheRT b m b -> TableCacheRT b m b)
-> (forall a. a -> TableCacheRT b m a)
-> Monad (TableCacheRT b m)
TableCacheRT b m a
-> (a -> TableCacheRT b m b) -> TableCacheRT b m b
TableCacheRT b m a -> TableCacheRT b m b -> TableCacheRT b m b
forall a. a -> TableCacheRT b m a
forall a b.
TableCacheRT b m a -> TableCacheRT b m b -> TableCacheRT b m b
forall a b.
TableCacheRT b m a
-> (a -> TableCacheRT b m b) -> TableCacheRT b m b
forall (b :: BackendType) (m :: * -> *).
Monad m =>
Applicative (TableCacheRT b m)
forall (b :: BackendType) (m :: * -> *) a.
Monad m =>
a -> TableCacheRT b m a
forall (b :: BackendType) (m :: * -> *) a b.
Monad m =>
TableCacheRT b m a -> TableCacheRT b m b -> TableCacheRT b m b
forall (b :: BackendType) (m :: * -> *) a b.
Monad m =>
TableCacheRT b m a
-> (a -> TableCacheRT b m b) -> TableCacheRT b m b
forall (m :: * -> *).
Applicative m
-> (forall a b. m a -> (a -> m b) -> m b)
-> (forall a b. m a -> m b -> m b)
-> (forall a. a -> m a)
-> Monad m
return :: a -> TableCacheRT b m a
$creturn :: forall (b :: BackendType) (m :: * -> *) a.
Monad m =>
a -> TableCacheRT b m a
>> :: TableCacheRT b m a -> TableCacheRT b m b -> TableCacheRT b m b
$c>> :: forall (b :: BackendType) (m :: * -> *) a b.
Monad m =>
TableCacheRT b m a -> TableCacheRT b m b -> TableCacheRT b m b
>>= :: TableCacheRT b m a
-> (a -> TableCacheRT b m b) -> TableCacheRT b m b
$c>>= :: forall (b :: BackendType) (m :: * -> *) a b.
Monad m =>
TableCacheRT b m a
-> (a -> TableCacheRT b m b) -> TableCacheRT b m b
$cp1Monad :: forall (b :: BackendType) (m :: * -> *).
Monad m =>
Applicative (TableCacheRT b m)
Monad, Monad (TableCacheRT b m)
Monad (TableCacheRT b m)
-> (forall a. IO a -> TableCacheRT b m a)
-> MonadIO (TableCacheRT b m)
IO a -> TableCacheRT b m a
forall a. IO a -> TableCacheRT b m a
forall (b :: BackendType) (m :: * -> *).
MonadIO m =>
Monad (TableCacheRT b m)
forall (b :: BackendType) (m :: * -> *) a.
MonadIO m =>
IO a -> TableCacheRT b m a
forall (m :: * -> *).
Monad m -> (forall a. IO a -> m a) -> MonadIO m
liftIO :: IO a -> TableCacheRT b m a
$cliftIO :: forall (b :: BackendType) (m :: * -> *) a.
MonadIO m =>
IO a -> TableCacheRT b m a
$cp1MonadIO :: forall (b :: BackendType) (m :: * -> *).
MonadIO m =>
Monad (TableCacheRT b m)
MonadIO, MonadError e, MonadState s, MonadWriter w, MonadError QErr (TableCacheRT b m)
MonadError QErr (TableCacheRT b m)
-> (forall a. TxE QErr a -> TableCacheRT b m a)
-> MonadTx (TableCacheRT b m)
TxE QErr a -> TableCacheRT b m a
forall a. TxE QErr a -> TableCacheRT b m a
forall (b :: BackendType) (m :: * -> *).
MonadTx m =>
MonadError QErr (TableCacheRT b m)
forall (b :: BackendType) (m :: * -> *) a.
MonadTx m =>
TxE QErr a -> TableCacheRT b m a
forall (m :: * -> *).
MonadError QErr m -> (forall a. TxE QErr a -> m a) -> MonadTx m
liftTx :: TxE QErr a -> TableCacheRT b m a
$cliftTx :: forall (b :: BackendType) (m :: * -> *) a.
MonadTx m =>
TxE QErr a -> TableCacheRT b m a
$cp1MonadTx :: forall (b :: BackendType) (m :: * -> *).
MonadTx m =>
MonadError QErr (TableCacheRT b m)
PG.MonadTx)
via (ReaderT (SourceName, TableCache b) m)
deriving (m a -> TableCacheRT b m a
(forall (m :: * -> *) a. Monad m => m a -> TableCacheRT b m a)
-> MonadTrans (TableCacheRT b)
forall (b :: BackendType) (m :: * -> *) a.
Monad m =>
m a -> TableCacheRT b m a
forall (m :: * -> *) a. Monad m => m a -> TableCacheRT b m a
forall (t :: (* -> *) -> * -> *).
(forall (m :: * -> *) a. Monad m => m a -> t m a) -> MonadTrans t
lift :: m a -> TableCacheRT b m a
$clift :: forall (b :: BackendType) (m :: * -> *) a.
Monad m =>
m a -> TableCacheRT b m a
MonadTrans) via (ReaderT (SourceName, TableCache b))
instance (UserInfoM m) => UserInfoM (TableCacheRT b m) where
askUserInfo :: TableCacheRT b m UserInfo
askUserInfo = m UserInfo -> TableCacheRT b m UserInfo
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m UserInfo
forall (m :: * -> *). UserInfoM m => m UserInfo
askUserInfo
instance (Monad m) => SourceM (TableCacheRT b m) where
askCurrentSource :: TableCacheRT b m SourceName
askCurrentSource =
((SourceName, TableCache b) -> m SourceName)
-> TableCacheRT b m SourceName
forall (b :: BackendType) (m :: * -> *) a.
((SourceName, TableCache b) -> m a) -> TableCacheRT b m a
TableCacheRT (SourceName -> m SourceName
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SourceName -> m SourceName)
-> ((SourceName, TableCache b) -> SourceName)
-> (SourceName, TableCache b)
-> m SourceName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (SourceName, TableCache b) -> SourceName
forall a b. (a, b) -> a
fst)
instance (Monad m, Backend b) => TableCoreInfoRM b (TableCacheRT b m) where
lookupTableCoreInfo :: TableName b -> TableCacheRT b m (Maybe (TableCoreInfo b))
lookupTableCoreInfo TableName b
tableName =
((SourceName, TableCache b) -> m (Maybe (TableCoreInfo b)))
-> TableCacheRT b m (Maybe (TableCoreInfo b))
forall (b :: BackendType) (m :: * -> *) a.
((SourceName, TableCache b) -> m a) -> TableCacheRT b m a
TableCacheRT (Maybe (TableCoreInfo b) -> m (Maybe (TableCoreInfo b))
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Maybe (TableCoreInfo b) -> m (Maybe (TableCoreInfo b)))
-> ((SourceName, TableCache b) -> Maybe (TableCoreInfo b))
-> (SourceName, TableCache b)
-> m (Maybe (TableCoreInfo b))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TableInfo b -> TableCoreInfo b)
-> Maybe (TableInfo b) -> Maybe (TableCoreInfo b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap TableInfo b -> TableCoreInfo b
forall (b :: BackendType). TableInfo b -> TableCoreInfo b
_tiCoreInfo (Maybe (TableInfo b) -> Maybe (TableCoreInfo b))
-> ((SourceName, TableCache b) -> Maybe (TableInfo b))
-> (SourceName, TableCache b)
-> Maybe (TableCoreInfo b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TableName b -> TableCache b -> Maybe (TableInfo b)
forall k v. (Eq k, Hashable k) => k -> HashMap k v -> Maybe v
M.lookup TableName b
tableName (TableCache b -> Maybe (TableInfo b))
-> ((SourceName, TableCache b) -> TableCache b)
-> (SourceName, TableCache b)
-> Maybe (TableInfo b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (SourceName, TableCache b) -> TableCache b
forall a b. (a, b) -> b
snd)
instance (Monad m, Backend b) => TableInfoRM b (TableCacheRT b m) where
lookupTableInfo :: TableName b -> TableCacheRT b m (Maybe (TableInfo b))
lookupTableInfo TableName b
tableName =
((SourceName, TableCache b) -> m (Maybe (TableInfo b)))
-> TableCacheRT b m (Maybe (TableInfo b))
forall (b :: BackendType) (m :: * -> *) a.
((SourceName, TableCache b) -> m a) -> TableCacheRT b m a
TableCacheRT (Maybe (TableInfo b) -> m (Maybe (TableInfo b))
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Maybe (TableInfo b) -> m (Maybe (TableInfo b)))
-> ((SourceName, TableCache b) -> Maybe (TableInfo b))
-> (SourceName, TableCache b)
-> m (Maybe (TableInfo b))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TableName b -> TableCache b -> Maybe (TableInfo b)
forall k v. (Eq k, Hashable k) => k -> HashMap k v -> Maybe v
M.lookup TableName b
tableName (TableCache b -> Maybe (TableInfo b))
-> ((SourceName, TableCache b) -> TableCache b)
-> (SourceName, TableCache b)
-> Maybe (TableInfo b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (SourceName, TableCache b) -> TableCache b
forall a b. (a, b) -> b
snd)
instance (HasServerConfigCtx m) => HasServerConfigCtx (TableCacheRT b m) where
askServerConfigCtx :: TableCacheRT b m ServerConfigCtx
askServerConfigCtx = m ServerConfigCtx -> TableCacheRT b m ServerConfigCtx
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m ServerConfigCtx
forall (m :: * -> *). HasServerConfigCtx m => m ServerConfigCtx
askServerConfigCtx
class (Monad m) => CacheRM m where
askSchemaCache :: m SchemaCache
instance (CacheRM m) => CacheRM (ReaderT r m) where
askSchemaCache :: ReaderT r m SchemaCache
askSchemaCache = m SchemaCache -> ReaderT r m SchemaCache
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m SchemaCache
forall (m :: * -> *). CacheRM m => m SchemaCache
askSchemaCache
instance (CacheRM m) => CacheRM (StateT s m) where
askSchemaCache :: StateT s m SchemaCache
askSchemaCache = m SchemaCache -> StateT s m SchemaCache
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m SchemaCache
forall (m :: * -> *). CacheRM m => m SchemaCache
askSchemaCache
instance (Monoid w, CacheRM m) => CacheRM (WriterT w m) where
askSchemaCache :: WriterT w m SchemaCache
askSchemaCache = m SchemaCache -> WriterT w m SchemaCache
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m SchemaCache
forall (m :: * -> *). CacheRM m => m SchemaCache
askSchemaCache
instance (CacheRM m) => CacheRM (TraceT m) where
askSchemaCache :: TraceT m SchemaCache
askSchemaCache = m SchemaCache -> TraceT m SchemaCache
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m SchemaCache
forall (m :: * -> *). CacheRM m => m SchemaCache
askSchemaCache
instance (CacheRM m) => CacheRM (Q.TxET QErr m) where
askSchemaCache :: TxET QErr m SchemaCache
askSchemaCache = m SchemaCache -> TxET QErr m SchemaCache
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m SchemaCache
forall (m :: * -> *). CacheRM m => m SchemaCache
askSchemaCache
instance (CacheRM m) => CacheRM (MSSQL.TxET e m) where
askSchemaCache :: TxET e m SchemaCache
askSchemaCache = m SchemaCache -> TxET e m SchemaCache
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m SchemaCache
forall (m :: * -> *). CacheRM m => m SchemaCache
askSchemaCache
getDependentObjs :: SchemaCache -> SchemaObjId -> [SchemaObjId]
getDependentObjs :: SchemaCache -> SchemaObjId -> [SchemaObjId]
getDependentObjs = (DependencyReason -> Bool)
-> SchemaCache -> SchemaObjId -> [SchemaObjId]
getDependentObjsWith (Bool -> DependencyReason -> Bool
forall a b. a -> b -> a
const Bool
True)
getDependentObjsWith ::
(DependencyReason -> Bool) -> SchemaCache -> SchemaObjId -> [SchemaObjId]
getDependentObjsWith :: (DependencyReason -> Bool)
-> SchemaCache -> SchemaObjId -> [SchemaObjId]
getDependentObjsWith DependencyReason -> Bool
f SchemaCache
sc SchemaObjId
objId =
((SchemaObjId, HashSet SchemaDependency) -> SchemaObjId)
-> [(SchemaObjId, HashSet SchemaDependency)] -> [SchemaObjId]
forall a b. (a -> b) -> [a] -> [b]
map (SchemaObjId, HashSet SchemaDependency) -> SchemaObjId
forall a b. (a, b) -> a
fst ([(SchemaObjId, HashSet SchemaDependency)] -> [SchemaObjId])
-> [(SchemaObjId, HashSet SchemaDependency)] -> [SchemaObjId]
forall a b. (a -> b) -> a -> b
$ ((SchemaObjId, HashSet SchemaDependency) -> Bool)
-> [(SchemaObjId, HashSet SchemaDependency)]
-> [(SchemaObjId, HashSet SchemaDependency)]
forall a. (a -> Bool) -> [a] -> [a]
filter (HashSet SchemaDependency -> Bool
isDependency (HashSet SchemaDependency -> Bool)
-> ((SchemaObjId, HashSet SchemaDependency)
-> HashSet SchemaDependency)
-> (SchemaObjId, HashSet SchemaDependency)
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (SchemaObjId, HashSet SchemaDependency) -> HashSet SchemaDependency
forall a b. (a, b) -> b
snd) ([(SchemaObjId, HashSet SchemaDependency)]
-> [(SchemaObjId, HashSet SchemaDependency)])
-> [(SchemaObjId, HashSet SchemaDependency)]
-> [(SchemaObjId, HashSet SchemaDependency)]
forall a b. (a -> b) -> a -> b
$ DepMap -> [(SchemaObjId, HashSet SchemaDependency)]
forall k v. HashMap k v -> [(k, v)]
M.toList (DepMap -> [(SchemaObjId, HashSet SchemaDependency)])
-> DepMap -> [(SchemaObjId, HashSet SchemaDependency)]
forall a b. (a -> b) -> a -> b
$ SchemaCache -> DepMap
scDepMap SchemaCache
sc
where
isDependency :: HashSet SchemaDependency -> Bool
isDependency HashSet SchemaDependency
deps = Bool -> Bool
not (Bool -> Bool) -> Bool -> Bool
forall a b. (a -> b) -> a -> b
$
HashSet SchemaDependency -> Bool
forall a. HashSet a -> Bool
HS.null (HashSet SchemaDependency -> Bool)
-> HashSet SchemaDependency -> Bool
forall a b. (a -> b) -> a -> b
$
((SchemaDependency -> Bool)
-> HashSet SchemaDependency -> HashSet SchemaDependency)
-> HashSet SchemaDependency
-> (SchemaDependency -> Bool)
-> HashSet SchemaDependency
forall a b c. (a -> b -> c) -> b -> a -> c
flip (SchemaDependency -> Bool)
-> HashSet SchemaDependency -> HashSet SchemaDependency
forall a. (a -> Bool) -> HashSet a -> HashSet a
HS.filter HashSet SchemaDependency
deps ((SchemaDependency -> Bool) -> HashSet SchemaDependency)
-> (SchemaDependency -> Bool) -> HashSet SchemaDependency
forall a b. (a -> b) -> a -> b
$
\(SchemaDependency SchemaObjId
depId DependencyReason
reason) -> SchemaObjId
objId SchemaObjId -> SchemaObjId -> Bool
`induces` SchemaObjId
depId Bool -> Bool -> Bool
&& DependencyReason -> Bool
f DependencyReason
reason
induces :: SchemaObjId -> SchemaObjId -> Bool
induces (SOSource SourceName
s1) (SOSource SourceName
s2) = SourceName
s1 SourceName -> SourceName -> Bool
forall a. Eq a => a -> a -> Bool
== SourceName
s2
induces (SOSource SourceName
s1) (SOSourceObj SourceName
s2 AnyBackend SourceObjId
_) = SourceName
s1 SourceName -> SourceName -> Bool
forall a. Eq a => a -> a -> Bool
== SourceName
s2
induces o1 :: SchemaObjId
o1@(SOSourceObj SourceName
s1 AnyBackend SourceObjId
e1) o2 :: SchemaObjId
o2@(SOSourceObj SourceName
s2 AnyBackend SourceObjId
e2) =
SourceName
s1 SourceName -> SourceName -> Bool
forall a. Eq a => a -> a -> Bool
== SourceName
s2 Bool -> Bool -> Bool
&& Bool -> Maybe Bool -> Bool
forall a. a -> Maybe a -> a
fromMaybe (SchemaObjId
o1 SchemaObjId -> SchemaObjId -> Bool
forall a. Eq a => a -> a -> Bool
== SchemaObjId
o2) ((forall (b :: BackendType).
Backend b =>
SourceObjId b -> SourceObjId b -> Maybe Bool)
-> AnyBackend SourceObjId
-> AnyBackend SourceObjId
-> Maybe Bool
-> Maybe Bool
forall (c :: BackendType -> Constraint) (i :: BackendType -> *) r.
AllBackendsSatisfy c =>
(forall (b :: BackendType). c b => i b -> i b -> r)
-> AnyBackend i -> AnyBackend i -> r -> r
AB.composeAnyBackend @Backend forall (b :: BackendType).
Backend b =>
SourceObjId b -> SourceObjId b -> Maybe Bool
forall (b :: BackendType) (b :: BackendType).
(Eq (TableName b), TableName b ~ TableName b) =>
SourceObjId b -> SourceObjId b -> Maybe Bool
go AnyBackend SourceObjId
e1 AnyBackend SourceObjId
e2 Maybe Bool
forall a. Maybe a
Nothing)
induces SchemaObjId
o1 SchemaObjId
o2 = SchemaObjId
o1 SchemaObjId -> SchemaObjId -> Bool
forall a. Eq a => a -> a -> Bool
== SchemaObjId
o2
go :: SourceObjId b -> SourceObjId b -> Maybe Bool
go (SOITable TableName b
tn1) (SOITable TableName b
tn2) = Bool -> Maybe Bool
forall a. a -> Maybe a
Just (Bool -> Maybe Bool) -> Bool -> Maybe Bool
forall a b. (a -> b) -> a -> b
$ TableName b
TableName b
tn1 TableName b -> TableName b -> Bool
forall a. Eq a => a -> a -> Bool
== TableName b
tn2
go (SOITable TableName b
tn1) (SOITableObj TableName b
tn2 TableObjId b
_) = Bool -> Maybe Bool
forall a. a -> Maybe a
Just (Bool -> Maybe Bool) -> Bool -> Maybe Bool
forall a b. (a -> b) -> a -> b
$ TableName b
TableName b
tn1 TableName b -> TableName b -> Bool
forall a. Eq a => a -> a -> Bool
== TableName b
tn2
go SourceObjId b
_ SourceObjId b
_ = Maybe Bool
forall a. Maybe a
Nothing
getRemoteDependencies ::
SchemaCache ->
SourceName ->
[SchemaObjId]
getRemoteDependencies :: SchemaCache -> SourceName -> [SchemaObjId]
getRemoteDependencies SchemaCache
schemaCache SourceName
sourceName =
(SchemaObjId -> Bool) -> [SchemaObjId] -> [SchemaObjId]
forall a. (a -> Bool) -> [a] -> [a]
filter SchemaObjId -> Bool
isRemoteDep ([SchemaObjId] -> [SchemaObjId]) -> [SchemaObjId] -> [SchemaObjId]
forall a b. (a -> b) -> a -> b
$ SchemaCache -> SchemaObjId -> [SchemaObjId]
getDependentObjs SchemaCache
schemaCache (SourceName -> SchemaObjId
SOSource SourceName
sourceName)
where
isRemoteDep :: SchemaObjId -> Bool
isRemoteDep = \case
SOSourceObj SourceName
sn AnyBackend SourceObjId
_
| SourceName
sn SourceName -> SourceName -> Bool
forall a. Eq a => a -> a -> Bool
/= SourceName
sourceName -> Bool
True
| Bool
otherwise -> Bool
False
SORemoteSchemaRemoteRelationship {} -> Bool
True
SOSource {} -> Bool
False
SORemoteSchema {} -> Bool
False
SORemoteSchemaPermission {} -> Bool
False
SORole {} -> Bool
False
getBoolExpDeps ::
forall b.
(GetAggregationPredicatesDeps b) =>
SourceName ->
TableName b ->
AnnBoolExpPartialSQL b ->
[SchemaDependency]
getBoolExpDeps :: SourceName
-> TableName b -> AnnBoolExpPartialSQL b -> [SchemaDependency]
getBoolExpDeps SourceName
source TableName b
tableName =
BoolExpCtx b -> BoolExpM b [SchemaDependency] -> [SchemaDependency]
forall (b :: BackendType) a. BoolExpCtx b -> BoolExpM b a -> a
runBoolExpM (BoolExpCtx :: forall (b :: BackendType).
SourceName -> TableName b -> TableName b -> BoolExpCtx b
BoolExpCtx {source :: SourceName
source = SourceName
source, currTable :: TableName b
currTable = TableName b
tableName, rootTable :: TableName b
rootTable = TableName b
tableName}) (BoolExpM b [SchemaDependency] -> [SchemaDependency])
-> (AnnBoolExpPartialSQL b -> BoolExpM b [SchemaDependency])
-> AnnBoolExpPartialSQL b
-> [SchemaDependency]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. AnnBoolExpPartialSQL b -> BoolExpM b [SchemaDependency]
forall (b :: BackendType).
(Backend b, GetAggregationPredicatesDeps b) =>
AnnBoolExpPartialSQL b -> BoolExpM b [SchemaDependency]
getBoolExpDeps'
getBoolExpDeps' ::
forall b.
(Backend b, GetAggregationPredicatesDeps b) =>
AnnBoolExpPartialSQL b ->
BoolExpM b [SchemaDependency]
getBoolExpDeps' :: AnnBoolExpPartialSQL b -> BoolExpM b [SchemaDependency]
getBoolExpDeps' = \case
BoolAnd [AnnBoolExpPartialSQL b]
exps -> [AnnBoolExpPartialSQL b] -> BoolExpM b [SchemaDependency]
procExps [AnnBoolExpPartialSQL b]
exps
BoolOr [AnnBoolExpPartialSQL b]
exps -> [AnnBoolExpPartialSQL b] -> BoolExpM b [SchemaDependency]
procExps [AnnBoolExpPartialSQL b]
exps
BoolNot AnnBoolExpPartialSQL b
e -> AnnBoolExpPartialSQL b -> BoolExpM b [SchemaDependency]
forall (b :: BackendType).
(Backend b, GetAggregationPredicatesDeps b) =>
AnnBoolExpPartialSQL b -> BoolExpM b [SchemaDependency]
getBoolExpDeps' AnnBoolExpPartialSQL b
e
BoolField AnnBoolExpFld b (PartialSQLExp b)
fld -> AnnBoolExpFld b (PartialSQLExp b) -> BoolExpM b [SchemaDependency]
forall (b :: BackendType).
(Backend b, GetAggregationPredicatesDeps b) =>
AnnBoolExpFld b (PartialSQLExp b) -> BoolExpM b [SchemaDependency]
getColExpDeps AnnBoolExpFld b (PartialSQLExp b)
fld
BoolExists (GExists TableName b
refqt AnnBoolExpPartialSQL b
whereExp) -> do
BoolExpCtx {SourceName
source :: SourceName
source :: forall (b :: BackendType). BoolExpCtx b -> SourceName
source} <- BoolExpM b (BoolExpCtx b)
forall r (m :: * -> *). MonadReader r m => m r
ask
let tableDep :: SchemaDependency
tableDep =
SchemaObjId -> DependencyReason -> SchemaDependency
SchemaDependency
( SourceName -> AnyBackend SourceObjId -> SchemaObjId
SOSourceObj SourceName
source (AnyBackend SourceObjId -> SchemaObjId)
-> AnyBackend SourceObjId -> SchemaObjId
forall a b. (a -> b) -> a -> b
$
SourceObjId b -> AnyBackend SourceObjId
forall (b :: BackendType) (i :: BackendType -> *).
HasTag b =>
i b -> AnyBackend i
AB.mkAnyBackend (SourceObjId b -> AnyBackend SourceObjId)
-> SourceObjId b -> AnyBackend SourceObjId
forall a b. (a -> b) -> a -> b
$
TableName b -> SourceObjId b
forall (b :: BackendType). TableName b -> SourceObjId b
SOITable @b TableName b
refqt
)
DependencyReason
DRRemoteTable
(SchemaDependency
tableDep SchemaDependency -> [SchemaDependency] -> [SchemaDependency]
forall a. a -> [a] -> [a]
:) ([SchemaDependency] -> [SchemaDependency])
-> BoolExpM b [SchemaDependency] -> BoolExpM b [SchemaDependency]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (BoolExpCtx b -> BoolExpCtx b)
-> BoolExpM b [SchemaDependency] -> BoolExpM b [SchemaDependency]
forall r (m :: * -> *) a. MonadReader r m => (r -> r) -> m a -> m a
local (\BoolExpCtx b
e -> BoolExpCtx b
e {currTable :: TableName b
currTable = TableName b
refqt}) (AnnBoolExpPartialSQL b -> BoolExpM b [SchemaDependency]
forall (b :: BackendType).
(Backend b, GetAggregationPredicatesDeps b) =>
AnnBoolExpPartialSQL b -> BoolExpM b [SchemaDependency]
getBoolExpDeps' AnnBoolExpPartialSQL b
whereExp)
where
procExps :: [AnnBoolExpPartialSQL b] -> BoolExpM b [SchemaDependency]
procExps :: [AnnBoolExpPartialSQL b] -> BoolExpM b [SchemaDependency]
procExps = ([[SchemaDependency]] -> [SchemaDependency])
-> BoolExpM b [[SchemaDependency]] -> BoolExpM b [SchemaDependency]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [[SchemaDependency]] -> [SchemaDependency]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat (BoolExpM b [[SchemaDependency]] -> BoolExpM b [SchemaDependency])
-> ([AnnBoolExpPartialSQL b] -> BoolExpM b [[SchemaDependency]])
-> [AnnBoolExpPartialSQL b]
-> BoolExpM b [SchemaDependency]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (AnnBoolExpPartialSQL b -> BoolExpM b [SchemaDependency])
-> [AnnBoolExpPartialSQL b] -> BoolExpM b [[SchemaDependency]]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM AnnBoolExpPartialSQL b -> BoolExpM b [SchemaDependency]
forall (b :: BackendType).
(Backend b, GetAggregationPredicatesDeps b) =>
AnnBoolExpPartialSQL b -> BoolExpM b [SchemaDependency]
getBoolExpDeps'
getColExpDeps ::
forall b.
(Backend b, GetAggregationPredicatesDeps b) =>
AnnBoolExpFld b (PartialSQLExp b) ->
BoolExpM b [SchemaDependency]
getColExpDeps :: AnnBoolExpFld b (PartialSQLExp b) -> BoolExpM b [SchemaDependency]
getColExpDeps AnnBoolExpFld b (PartialSQLExp b)
bexp = do
BoolExpCtx {SourceName
source :: SourceName
source :: forall (b :: BackendType). BoolExpCtx b -> SourceName
source, TableName b
currTable :: TableName b
currTable :: forall (b :: BackendType). BoolExpCtx b -> TableName b
currTable} <- BoolExpM b (BoolExpCtx b)
forall r (m :: * -> *). MonadReader r m => m r
ask
case AnnBoolExpFld b (PartialSQLExp b)
bexp of
AVColumn ColumnInfo b
colInfo [OpExpG b (PartialSQLExp b)]
opExps ->
let columnName :: Column b
columnName = ColumnInfo b -> Column b
forall (b :: BackendType). ColumnInfo b -> Column b
ciColumn ColumnInfo b
colInfo
colDepReason :: DependencyReason
colDepReason = DependencyReason -> DependencyReason -> Bool -> DependencyReason
forall a. a -> a -> Bool -> a
bool DependencyReason
DRSessionVariable DependencyReason
DROnType (Bool -> DependencyReason) -> Bool -> DependencyReason
forall a b. (a -> b) -> a -> b
$ (OpExpG b (PartialSQLExp b) -> Bool)
-> [OpExpG b (PartialSQLExp b)] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any OpExpG b (PartialSQLExp b) -> Bool
forall (b :: BackendType).
Backend b =>
OpExpG b (PartialSQLExp b) -> Bool
hasStaticExp [OpExpG b (PartialSQLExp b)]
opExps
colDep :: SchemaDependency
colDep = DependencyReason
-> SourceName -> TableName b -> Column b -> SchemaDependency
forall (b :: BackendType).
Backend b =>
DependencyReason
-> SourceName -> TableName b -> Column b -> SchemaDependency
mkColDep @b DependencyReason
colDepReason SourceName
source TableName b
currTable Column b
columnName
in (SchemaDependency
colDep SchemaDependency -> [SchemaDependency] -> [SchemaDependency]
forall a. a -> [a] -> [a]
:) ([SchemaDependency] -> [SchemaDependency])
-> BoolExpM b [SchemaDependency] -> BoolExpM b [SchemaDependency]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [OpExpG b (PartialSQLExp b)] -> BoolExpM b [SchemaDependency]
forall (b :: BackendType).
Backend b =>
[OpExpG b (PartialSQLExp b)] -> BoolExpM b [SchemaDependency]
getOpExpDeps [OpExpG b (PartialSQLExp b)]
opExps
AVRelationship RelInfo b
relInfo AnnBoolExp b (PartialSQLExp b)
relBoolExp ->
let relationshipName :: RelName
relationshipName = RelInfo b -> RelName
forall (b :: BackendType). RelInfo b -> RelName
riName RelInfo b
relInfo
relationshipTable :: TableName b
relationshipTable = RelInfo b -> TableName b
forall (b :: BackendType). RelInfo b -> TableName b
riRTable RelInfo b
relInfo
schemaDependency :: SchemaDependency
schemaDependency =
SchemaObjId -> DependencyReason -> SchemaDependency
SchemaDependency
( SourceName -> AnyBackend SourceObjId -> SchemaObjId
SOSourceObj SourceName
source (AnyBackend SourceObjId -> SchemaObjId)
-> AnyBackend SourceObjId -> SchemaObjId
forall a b. (a -> b) -> a -> b
$
SourceObjId b -> AnyBackend SourceObjId
forall (b :: BackendType) (i :: BackendType -> *).
HasTag b =>
i b -> AnyBackend i
AB.mkAnyBackend (SourceObjId b -> AnyBackend SourceObjId)
-> SourceObjId b -> AnyBackend SourceObjId
forall a b. (a -> b) -> a -> b
$
TableName b -> TableObjId b -> SourceObjId b
forall (b :: BackendType).
TableName b -> TableObjId b -> SourceObjId b
SOITableObj @b TableName b
currTable (RelName -> TableObjId b
forall (b :: BackendType). RelName -> TableObjId b
TORel RelName
relationshipName)
)
DependencyReason
DROnType
in (SchemaDependency
schemaDependency SchemaDependency -> [SchemaDependency] -> [SchemaDependency]
forall a. a -> [a] -> [a]
:) ([SchemaDependency] -> [SchemaDependency])
-> BoolExpM b [SchemaDependency] -> BoolExpM b [SchemaDependency]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (BoolExpCtx b -> BoolExpCtx b)
-> BoolExpM b [SchemaDependency] -> BoolExpM b [SchemaDependency]
forall r (m :: * -> *) a. MonadReader r m => (r -> r) -> m a -> m a
local (\BoolExpCtx b
e -> BoolExpCtx b
e {currTable :: TableName b
currTable = TableName b
relationshipTable}) (AnnBoolExp b (PartialSQLExp b) -> BoolExpM b [SchemaDependency]
forall (b :: BackendType).
(Backend b, GetAggregationPredicatesDeps b) =>
AnnBoolExpPartialSQL b -> BoolExpM b [SchemaDependency]
getBoolExpDeps' AnnBoolExp b (PartialSQLExp b)
relBoolExp)
AVComputedField AnnComputedFieldBoolExp b (PartialSQLExp b)
computedFieldBoolExp ->
let mkComputedFieldDep' :: DependencyReason -> SchemaDependency
mkComputedFieldDep' DependencyReason
r =
DependencyReason
-> SourceName
-> TableName b
-> ComputedFieldName
-> SchemaDependency
forall (b :: BackendType).
Backend b =>
DependencyReason
-> SourceName
-> TableName b
-> ComputedFieldName
-> SchemaDependency
mkComputedFieldDep @b DependencyReason
r SourceName
source TableName b
currTable (ComputedFieldName -> SchemaDependency)
-> ComputedFieldName -> SchemaDependency
forall a b. (a -> b) -> a -> b
$ AnnComputedFieldBoolExp b (PartialSQLExp b) -> ComputedFieldName
forall (backend :: BackendType) scalar.
AnnComputedFieldBoolExp backend scalar -> ComputedFieldName
_acfbName AnnComputedFieldBoolExp b (PartialSQLExp b)
computedFieldBoolExp
in case AnnComputedFieldBoolExp b (PartialSQLExp b)
-> ComputedFieldBoolExp b (PartialSQLExp b)
forall (backend :: BackendType) scalar.
AnnComputedFieldBoolExp backend scalar
-> ComputedFieldBoolExp backend scalar
_acfbBoolExp AnnComputedFieldBoolExp b (PartialSQLExp b)
computedFieldBoolExp of
CFBEScalar [OpExpG b (PartialSQLExp b)]
opExps ->
let computedFieldDep :: SchemaDependency
computedFieldDep =
DependencyReason -> SchemaDependency
mkComputedFieldDep' (DependencyReason -> SchemaDependency)
-> DependencyReason -> SchemaDependency
forall a b. (a -> b) -> a -> b
$
DependencyReason -> DependencyReason -> Bool -> DependencyReason
forall a. a -> a -> Bool -> a
bool DependencyReason
DRSessionVariable DependencyReason
DROnType (Bool -> DependencyReason) -> Bool -> DependencyReason
forall a b. (a -> b) -> a -> b
$ (OpExpG b (PartialSQLExp b) -> Bool)
-> [OpExpG b (PartialSQLExp b)] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any OpExpG b (PartialSQLExp b) -> Bool
forall (b :: BackendType).
Backend b =>
OpExpG b (PartialSQLExp b) -> Bool
hasStaticExp [OpExpG b (PartialSQLExp b)]
opExps
in (SchemaDependency
computedFieldDep SchemaDependency -> [SchemaDependency] -> [SchemaDependency]
forall a. a -> [a] -> [a]
:) ([SchemaDependency] -> [SchemaDependency])
-> BoolExpM b [SchemaDependency] -> BoolExpM b [SchemaDependency]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [OpExpG b (PartialSQLExp b)] -> BoolExpM b [SchemaDependency]
forall (b :: BackendType).
Backend b =>
[OpExpG b (PartialSQLExp b)] -> BoolExpM b [SchemaDependency]
getOpExpDeps [OpExpG b (PartialSQLExp b)]
opExps
CFBETable TableName b
cfTable AnnBoolExp b (PartialSQLExp b)
cfTableBoolExp ->
(DependencyReason -> SchemaDependency
mkComputedFieldDep' DependencyReason
DROnType SchemaDependency -> [SchemaDependency] -> [SchemaDependency]
forall a. a -> [a] -> [a]
:) ([SchemaDependency] -> [SchemaDependency])
-> BoolExpM b [SchemaDependency] -> BoolExpM b [SchemaDependency]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (BoolExpCtx b -> BoolExpCtx b)
-> BoolExpM b [SchemaDependency] -> BoolExpM b [SchemaDependency]
forall r (m :: * -> *) a. MonadReader r m => (r -> r) -> m a -> m a
local (\BoolExpCtx b
e -> BoolExpCtx b
e {currTable :: TableName b
currTable = TableName b
cfTable}) (AnnBoolExp b (PartialSQLExp b) -> BoolExpM b [SchemaDependency]
forall (b :: BackendType).
(Backend b, GetAggregationPredicatesDeps b) =>
AnnBoolExpPartialSQL b -> BoolExpM b [SchemaDependency]
getBoolExpDeps' AnnBoolExp b (PartialSQLExp b)
cfTableBoolExp)
AVAggregationPredicates AggregationPredicates b (PartialSQLExp b)
aggPreds -> AggregationPredicates b (PartialSQLExp b)
-> BoolExpM b [SchemaDependency]
forall (b :: BackendType).
GetAggregationPredicatesDeps b =>
AggregationPredicates b (PartialSQLExp b)
-> BoolExpM b [SchemaDependency]
getAggregationPredicateDeps AggregationPredicates b (PartialSQLExp b)
aggPreds
getOpExpDeps ::
forall b.
(Backend b) =>
[OpExpG b (PartialSQLExp b)] ->
BoolExpM b [SchemaDependency]
getOpExpDeps :: [OpExpG b (PartialSQLExp b)] -> BoolExpM b [SchemaDependency]
getOpExpDeps [OpExpG b (PartialSQLExp b)]
opExps = do
BoolExpCtx {SourceName
source :: SourceName
source :: forall (b :: BackendType). BoolExpCtx b -> SourceName
source, TableName b
rootTable :: TableName b
rootTable :: forall (b :: BackendType). BoolExpCtx b -> TableName b
rootTable, TableName b
currTable :: TableName b
currTable :: forall (b :: BackendType). BoolExpCtx b -> TableName b
currTable} <- BoolExpM b (BoolExpCtx b)
forall r (m :: * -> *). MonadReader r m => m r
ask
[SchemaDependency] -> BoolExpM b [SchemaDependency]
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([SchemaDependency] -> BoolExpM b [SchemaDependency])
-> [SchemaDependency] -> BoolExpM b [SchemaDependency]
forall a b. (a -> b) -> a -> b
$ do
RootOrCurrentColumn RootOrCurrent
rootOrCol Column b
col <- (OpExpG b (PartialSQLExp b) -> Maybe (RootOrCurrentColumn b))
-> [OpExpG b (PartialSQLExp b)] -> [RootOrCurrentColumn b]
forall (f :: * -> *) a b.
Filterable f =>
(a -> Maybe b) -> f a -> f b
mapMaybe OpExpG b (PartialSQLExp b) -> Maybe (RootOrCurrentColumn b)
forall (backend :: BackendType) field.
OpExpG backend field -> Maybe (RootOrCurrentColumn backend)
opExpDepCol [OpExpG b (PartialSQLExp b)]
opExps
let table :: TableName b
table = case RootOrCurrent
rootOrCol of
RootOrCurrent
IsRoot -> TableName b
rootTable
RootOrCurrent
IsCurrent -> TableName b
currTable
SchemaDependency -> [SchemaDependency]
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SchemaDependency -> [SchemaDependency])
-> SchemaDependency -> [SchemaDependency]
forall a b. (a -> b) -> a -> b
$ DependencyReason
-> SourceName -> TableName b -> Column b -> SchemaDependency
forall (b :: BackendType).
Backend b =>
DependencyReason
-> SourceName -> TableName b -> Column b -> SchemaDependency
mkColDep @b DependencyReason
DROnType SourceName
source TableName b
table Column b
col
askFieldInfoMapSource ::
(QErrM m, Backend b, TableCoreInfoRM b m) =>
TableName b ->
m (FieldInfoMap (FieldInfo b))
askFieldInfoMapSource :: TableName b -> m (FieldInfoMap (FieldInfo b))
askFieldInfoMapSource TableName b
tableName = do
(TableCoreInfoG b (FieldInfo b) (ColumnInfo b)
-> FieldInfoMap (FieldInfo b))
-> m (TableCoreInfoG b (FieldInfo b) (ColumnInfo b))
-> m (FieldInfoMap (FieldInfo b))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap TableCoreInfoG b (FieldInfo b) (ColumnInfo b)
-> FieldInfoMap (FieldInfo b)
forall (b :: BackendType) field primaryKeyColumn.
TableCoreInfoG b field primaryKeyColumn -> FieldInfoMap field
_tciFieldInfoMap (m (TableCoreInfoG b (FieldInfo b) (ColumnInfo b))
-> m (FieldInfoMap (FieldInfo b)))
-> m (TableCoreInfoG b (FieldInfo b) (ColumnInfo b))
-> m (FieldInfoMap (FieldInfo b))
forall a b. (a -> b) -> a -> b
$
m (Maybe (TableCoreInfoG b (FieldInfo b) (ColumnInfo b)))
-> m (TableCoreInfoG b (FieldInfo b) (ColumnInfo b))
-> m (TableCoreInfoG b (FieldInfo b) (ColumnInfo b))
forall (m :: * -> *) a. Monad m => m (Maybe a) -> m a -> m a
onNothingM (TableName b
-> m (Maybe (TableCoreInfoG b (FieldInfo b) (ColumnInfo b)))
forall (b :: BackendType) (m :: * -> *).
TableCoreInfoRM b m =>
TableName b -> m (Maybe (TableCoreInfo b))
lookupTableCoreInfo TableName b
tableName) (m (TableCoreInfoG b (FieldInfo b) (ColumnInfo b))
-> m (TableCoreInfoG b (FieldInfo b) (ColumnInfo b)))
-> m (TableCoreInfoG b (FieldInfo b) (ColumnInfo b))
-> m (TableCoreInfoG b (FieldInfo b) (ColumnInfo b))
forall a b. (a -> b) -> a -> b
$
Code -> Text -> m (TableCoreInfoG b (FieldInfo b) (ColumnInfo b))
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
NotExists (Text -> m (TableCoreInfoG b (FieldInfo b) (ColumnInfo b)))
-> Text -> m (TableCoreInfoG b (FieldInfo b) (ColumnInfo b))
forall a b. (a -> b) -> a -> b
$ Text
"table " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> TableName b
tableName TableName b -> Text -> Text
forall t. ToTxt t => t -> Text -> Text
<<> Text
" does not exist"