Remove resolveUnpreparedValue

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4743
GitOrigin-RevId: 1d532ac2475e292e587581ac840d056e3b96a951
This commit is contained in:
Tom Harding 2022-06-15 19:15:51 +01:00 committed by hasura-bot
parent 2526dd0114
commit 16213a9b77
2 changed files with 1 additions and 21 deletions

View File

@ -14,7 +14,6 @@ module Hasura.Backends.Postgres.Execute.Prepare
initPlanningSt,
prepareWithPlan,
prepareWithoutPlan,
resolveUnpreparedValue,
withUserVars,
)
where
@ -104,24 +103,6 @@ prepareWithoutPlan userInfo = \case
"missing session variable: " <>> sessionVariableToText sessVar
pure $ withTypeAnn ty sessionVariableValue
resolveUnpreparedValue ::
(MonadError QErr m) =>
UserInfo ->
UnpreparedValue ('Postgres pgKind) ->
m S.SQLExp
resolveUnpreparedValue userInfo = \case
UVParameter _ cv -> pure $ toTxtValue cv
UVLiteral sqlExp -> pure sqlExp
UVSession -> pure $ sessionInfoJsonExp $ _uiSession userInfo
UVSessionVar ty sessionVariable -> do
let maybeSessionVariableValue =
getSessionVariableValue sessionVariable (_uiSession userInfo)
sessionVariableValue <-
fmap S.SELit
<$> onNothing maybeSessionVariableValue
$ throw400 UnexpectedPayload $ "missing required session variable for role " <> _uiRole userInfo <<> " : " <> sessionVariableToText sessionVariable
pure $ withTypeAnn ty sessionVariableValue
withUserVars :: SessionVariables -> PrepArgMap -> PrepArgMap
withUserVars usrVars list =
let usrVarsAsPgScalar = PGValJSON $ Q.JSON $ J.toJSON usrVars

View File

@ -29,7 +29,6 @@ import Hasura.Backends.Postgres.Execute.Prepare
initPlanningSt,
prepareWithPlan,
prepareWithoutPlan,
resolveUnpreparedValue,
withUserVars,
)
import Hasura.Backends.Postgres.Execute.Subscription qualified as PGL
@ -149,7 +148,7 @@ pgDBQueryExplain ::
QueryDB ('Postgres pgKind) Void (UnpreparedValue ('Postgres pgKind)) ->
m (AB.AnyBackend DBStepInfo)
pgDBQueryExplain fieldName userInfo sourceName sourceConfig rootSelection = do
preparedQuery <- traverse (resolveUnpreparedValue userInfo) rootSelection
preparedQuery <- traverse (prepareWithoutPlan userInfo) rootSelection
let PreparedSql querySQL _ = irToRootFieldPlan mempty preparedQuery
textSQL = Q.getQueryText querySQL
-- CAREFUL!: an `EXPLAIN ANALYZE` here would actually *execute* this