Safe Haskell | None |
---|---|
Language | Haskell2010 |
MSSQL Instances Execute
Defines a BackendExecute
type class instance for MSSQL.
This module implements the needed functionality for implementing a BackendExecute
instance for MSSQL, which defines an interface for translating a root field into an execution plan
and interacting with a database.
This module includes the MSSQL implementation of queries, mutations, and more.
Synopsis
- data MultiplexedQuery' = MultiplexedQuery' {}
- msDBQueryPlan :: forall m. (MonadError QErr m, MonadReader QueryTagsComment m) => UserInfo -> Environment -> SourceName -> SourceConfig 'MSSQL -> QueryDB 'MSSQL Void (UnpreparedValue 'MSSQL) -> m (DBStepInfo 'MSSQL)
- runShowplan :: MonadIO m => Query -> TxET QErr m [Text]
- msDBQueryExplain :: MonadError QErr m => RootFieldAlias -> UserInfo -> SourceName -> SourceConfig 'MSSQL -> QueryDB 'MSSQL Void (UnpreparedValue 'MSSQL) -> m (AnyBackend DBStepInfo)
- msDBSubscriptionExplain :: (MonadIO m, MonadBaseControl IO m, MonadError QErr m) => SubscriptionQueryPlan 'MSSQL (MultiplexedQuery 'MSSQL) -> m SubscriptionQueryPlanExplanation
- multiplexRootReselect :: [(CohortId, CohortVariables)] -> Reselect -> Select
- msDBMutationPlan :: forall m. (MonadError QErr m, MonadReader QueryTagsComment m) => UserInfo -> StringifyNumbers -> SourceName -> SourceConfig 'MSSQL -> MutationDB 'MSSQL Void (UnpreparedValue 'MSSQL) -> m (DBStepInfo 'MSSQL)
- msDBLiveQuerySubscriptionPlan :: forall m. (MonadError QErr m, MonadIO m, MonadBaseControl IO m, MonadReader QueryTagsComment m) => UserInfo -> SourceName -> SourceConfig 'MSSQL -> Maybe Name -> RootFieldMap (QueryDB 'MSSQL Void (UnpreparedValue 'MSSQL)) -> m (SubscriptionQueryPlan 'MSSQL (MultiplexedQuery 'MSSQL))
- prepareStateCohortVariables :: (MonadError QErr m, MonadIO m, MonadBaseControl IO m) => SourceConfig 'MSSQL -> SessionVariables -> PrepareState -> m CohortVariables
- validateVariables :: (MonadError QErr m, MonadIO m, MonadBaseControl IO m) => SourceConfig 'MSSQL -> SessionVariables -> PrepareState -> m (ValidatedQueryVariables, ValidatedSyntheticVariables)
- msDBRemoteRelationshipPlan :: forall m. MonadError QErr m => UserInfo -> SourceName -> SourceConfig 'MSSQL -> NonEmpty Object -> HashMap FieldName (Column 'MSSQL, ScalarType 'MSSQL) -> FieldName -> (FieldName, SourceRelationshipSelection 'MSSQL Void UnpreparedValue) -> m (DBStepInfo 'MSSQL)
Multiplexed query
data MultiplexedQuery' Source #
Instances
ToTxt MultiplexedQuery' Source # | |
Defined in Hasura.Backends.MSSQL.Instances.Execute toTxt :: MultiplexedQuery' -> Text Source # |
Query
msDBQueryPlan :: forall m. (MonadError QErr m, MonadReader QueryTagsComment m) => UserInfo -> Environment -> SourceName -> SourceConfig 'MSSQL -> QueryDB 'MSSQL Void (UnpreparedValue 'MSSQL) -> m (DBStepInfo 'MSSQL) Source #
msDBQueryExplain :: MonadError QErr m => RootFieldAlias -> UserInfo -> SourceName -> SourceConfig 'MSSQL -> QueryDB 'MSSQL Void (UnpreparedValue 'MSSQL) -> m (AnyBackend DBStepInfo) Source #
msDBSubscriptionExplain :: (MonadIO m, MonadBaseControl IO m, MonadError QErr m) => SubscriptionQueryPlan 'MSSQL (MultiplexedQuery 'MSSQL) -> m SubscriptionQueryPlanExplanation Source #
multiplexRootReselect :: [(CohortId, CohortVariables)] -> Reselect -> Select Source #
Producing the correct SQL-level list comprehension to multiplex a query Problem description:
Generate a query that repeats the same query N times but with certain slots replaced:
- Select x y | (x,y) <- [..
- ]
Caution: Be aware that this query has a FOR JSON
clause at the top-level
and hence its results may be split up across multiple rows. Use
forJsonQueryE
to handle this.
Mutation
msDBMutationPlan :: forall m. (MonadError QErr m, MonadReader QueryTagsComment m) => UserInfo -> StringifyNumbers -> SourceName -> SourceConfig 'MSSQL -> MutationDB 'MSSQL Void (UnpreparedValue 'MSSQL) -> m (DBStepInfo 'MSSQL) Source #
Subscription
msDBLiveQuerySubscriptionPlan :: forall m. (MonadError QErr m, MonadIO m, MonadBaseControl IO m, MonadReader QueryTagsComment m) => UserInfo -> SourceName -> SourceConfig 'MSSQL -> Maybe Name -> RootFieldMap (QueryDB 'MSSQL Void (UnpreparedValue 'MSSQL)) -> m (SubscriptionQueryPlan 'MSSQL (MultiplexedQuery 'MSSQL)) Source #
prepareStateCohortVariables :: (MonadError QErr m, MonadIO m, MonadBaseControl IO m) => SourceConfig 'MSSQL -> SessionVariables -> PrepareState -> m CohortVariables Source #
validateVariables :: (MonadError QErr m, MonadIO m, MonadBaseControl IO m) => SourceConfig 'MSSQL -> SessionVariables -> PrepareState -> m (ValidatedQueryVariables, ValidatedSyntheticVariables) Source #
Ensure that the set of variables (with value instantiations) that occur in a (RQL) query produce a well-formed and executable (SQL) query when considered in isolation.
This helps avoiding cascading failures in multiplexed queries.
c.f. https://github.com/hasura/graphql-engine-mono/issues/1210.
Remote Relationships (e.g. DB-to-DB Joins, remote schema joins, etc.)
msDBRemoteRelationshipPlan Source #
:: forall m. MonadError QErr m | |
=> UserInfo | |
-> SourceName | |
-> SourceConfig 'MSSQL | |
-> NonEmpty Object | List of json objects, each of which becomes a row of the table. |
-> HashMap FieldName (Column 'MSSQL, ScalarType 'MSSQL) | The above objects have this schema XXX: What is this for/what does this mean? |
-> FieldName | This is a field name from the lhs that *has* to be selected in the response along with the relationship. |
-> (FieldName, SourceRelationshipSelection 'MSSQL Void UnpreparedValue) | |
-> m (DBStepInfo 'MSSQL) |
Construct an action (i.e. DBStepInfo
) which can marshal some remote
relationship information into a form that SQL Server can query against.
XXX: Currently unimplemented; the Postgres implementation uses
jsonb_to_recordset
to query the remote relationship, however this
functionality doesn't exist in SQL Server.
NOTE: The following typeclass constraints will be necessary when implementing this function for real:
MonadQueryTags m Backend 'MSSQL