mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 09:22:43 +03:00
server: rename spiScalarComputedFields
to spiComputedFields
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4629 GitOrigin-RevId: 53d72d8ed73ecab486718f424bbd8d30c6f423bf
This commit is contained in:
parent
ebc8cd5134
commit
524819b4b7
@ -1355,7 +1355,7 @@ computedFieldPG sourceInfo ComputedFieldInfo {..} parentTable tableInfo = runMay
|
||||
case _cfiReturnType of
|
||||
PG.CFRScalar scalarReturnType -> do
|
||||
caseBoolExpMaybe <-
|
||||
hoistMaybe (Map.lookup _cfiName (spiScalarComputedFields selectPermissions))
|
||||
hoistMaybe (Map.lookup _cfiName (spiComputedFields selectPermissions))
|
||||
let caseBoolExpUnpreparedValue =
|
||||
(fmap . fmap) partialSQLExpToUnpreparedValue <$> caseBoolExpMaybe
|
||||
fieldArgsParser = do
|
||||
|
@ -191,7 +191,7 @@ tableSelectFields sourceInfo tableInfo = do
|
||||
canBeSelected (Just permissions) (FIComputedField computedFieldInfo) =
|
||||
case computedFieldReturnType @b (_cfiReturnType computedFieldInfo) of
|
||||
ReturnsScalar _ ->
|
||||
pure $ Map.member (_cfiName computedFieldInfo) $ spiScalarComputedFields permissions
|
||||
pure $ Map.member (_cfiName computedFieldInfo) $ spiComputedFields permissions
|
||||
ReturnsTable tableName -> do
|
||||
tableInfo' <- askTableInfo sourceInfo tableName
|
||||
isJust <$> tableSelectPermissions @b tableInfo'
|
||||
|
@ -343,7 +343,7 @@ buildSelPermInfo source tn fieldInfoMap sp = withPathK "permission" $ do
|
||||
askColumnType fieldInfoMap pgCol autoInferredErr
|
||||
|
||||
-- validate computed fields
|
||||
scalarComputedFields <-
|
||||
validComputedFields <-
|
||||
withPathK "computed_fields" $
|
||||
indexedForM computedFields $ \fieldName -> do
|
||||
computedFieldInfo <- askComputedFieldInfo fieldInfoMap fieldName
|
||||
@ -363,7 +363,7 @@ buildSelPermInfo source tn fieldInfoMap sp = withPathK "permission" $ do
|
||||
let deps =
|
||||
mkParentDep @b source tn :
|
||||
boolExpDeps ++ map (mkColDep @b DRUntyped source tn) pgCols
|
||||
++ map (mkComputedFieldDep @b DRUntyped source tn) scalarComputedFields
|
||||
++ map (mkComputedFieldDep @b DRUntyped source tn) validComputedFields
|
||||
depHeaders = getDependentHeaders $ spFilter sp
|
||||
mLimit = spLimit sp
|
||||
|
||||
@ -372,10 +372,10 @@ buildSelPermInfo source tn fieldInfoMap sp = withPathK "permission" $ do
|
||||
throw400 NotSupported "unexpected negative value"
|
||||
|
||||
let pgColsWithFilter = HM.fromList $ map (,Nothing) pgCols
|
||||
scalarComputedFieldsWithFilter = HS.toMap (HS.fromList scalarComputedFields) $> Nothing
|
||||
computedFieldsWithFilter = HS.toMap (HS.fromList validComputedFields) $> Nothing
|
||||
|
||||
let selPermInfo =
|
||||
SelPermInfo pgColsWithFilter scalarComputedFieldsWithFilter boolExp mLimit allowAgg depHeaders
|
||||
SelPermInfo pgColsWithFilter computedFieldsWithFilter boolExp mLimit allowAgg depHeaders
|
||||
|
||||
return (selPermInfo, deps)
|
||||
where
|
||||
|
@ -189,7 +189,7 @@ checkSelectPermOnScalarComputedField ::
|
||||
m ()
|
||||
checkSelectPermOnScalarComputedField selPermInfo computedField = do
|
||||
role <- askCurRole
|
||||
unless (M.member computedField $ spiScalarComputedFields selPermInfo) $
|
||||
unless (M.member computedField $ spiComputedFields selPermInfo) $
|
||||
throw400 PermissionDenied $ permErrMsg role
|
||||
where
|
||||
permErrMsg role
|
||||
|
@ -217,7 +217,8 @@ data SelPerm (b :: BackendType) = SelPerm
|
||||
spLimit :: !(Maybe Int),
|
||||
-- | Allow aggregation
|
||||
spAllowAggregations :: !Bool,
|
||||
-- | Allowed computed fields
|
||||
-- | Allowed computed fields which should not
|
||||
-- include the fields returning rows of existing table.
|
||||
spComputedFields :: ![ComputedFieldName]
|
||||
}
|
||||
deriving (Show, Eq, Generic)
|
||||
|
@ -94,7 +94,7 @@ rolePermInfoToCombineRolePermInfo RolePermInfo {..} =
|
||||
modifySingleSelectPerm SelPermInfo {..} =
|
||||
let columnCaseBoolExp = fmap AnnColumnCaseBoolExpField spiFilter
|
||||
colsWithColCaseBoolExp = spiCols $> Just columnCaseBoolExp
|
||||
scalarCompFieldsWithColCaseBoolExp = spiScalarComputedFields $> Just columnCaseBoolExp
|
||||
scalarCompFieldsWithColCaseBoolExp = spiComputedFields $> Just columnCaseBoolExp
|
||||
in CombinedSelPermInfo
|
||||
[colsWithColCaseBoolExp]
|
||||
[scalarCompFieldsWithColCaseBoolExp]
|
||||
|
@ -353,7 +353,7 @@ instance
|
||||
-- to combine more than one select permissions for inherited roles.
|
||||
data CombinedSelPermInfo (b :: BackendType) = CombinedSelPermInfo
|
||||
{ cspiCols :: ![(M.HashMap (Column b) (Maybe (AnnColumnCaseBoolExpPartialSQL b)))],
|
||||
cspiScalarComputedFields :: ![(M.HashMap ComputedFieldName (Maybe (AnnColumnCaseBoolExpPartialSQL b)))],
|
||||
cspiComputedFields :: ![(M.HashMap ComputedFieldName (Maybe (AnnColumnCaseBoolExpPartialSQL b)))],
|
||||
cspiFilter :: ![(AnnBoolExpPartialSQL b)],
|
||||
cspiLimit :: !(Maybe (Max Int)),
|
||||
cspiAllowAgg :: !Any,
|
||||
@ -379,7 +379,7 @@ combinedSelPermInfoToSelPermInfo ::
|
||||
combinedSelPermInfoToSelPermInfo selPermsCount CombinedSelPermInfo {..} =
|
||||
SelPermInfo
|
||||
(mergeColumnsWithBoolExp <$> M.unionsAll cspiCols)
|
||||
(mergeColumnsWithBoolExp <$> M.unionsAll cspiScalarComputedFields)
|
||||
(mergeColumnsWithBoolExp <$> M.unionsAll cspiComputedFields)
|
||||
(BoolOr cspiFilter)
|
||||
(getMax <$> cspiLimit)
|
||||
(getAny cspiAllowAgg)
|
||||
@ -419,9 +419,10 @@ data SelPermInfo (b :: BackendType) = SelPermInfo
|
||||
-- bool exp will determine if the column should be nullified in a row, when
|
||||
-- there aren't requisite permissions.
|
||||
spiCols :: !(M.HashMap (Column b) (Maybe (AnnColumnCaseBoolExpPartialSQL b))),
|
||||
-- | HashMap of accessible scalar computed fields to the role, mapped to
|
||||
-- `AnnColumnCaseBoolExpPartialSQL`, simililar to `spiCols`
|
||||
spiScalarComputedFields :: !(M.HashMap ComputedFieldName (Maybe (AnnColumnCaseBoolExpPartialSQL b))),
|
||||
-- | HashMap of accessible computed fields to the role, mapped to
|
||||
-- `AnnColumnCaseBoolExpPartialSQL`, simililar to `spiCols`.
|
||||
-- These computed fields do not return rows of existing table.
|
||||
spiComputedFields :: !(M.HashMap ComputedFieldName (Maybe (AnnColumnCaseBoolExpPartialSQL b))),
|
||||
spiFilter :: !(AnnBoolExpPartialSQL b),
|
||||
spiLimit :: !(Maybe Int),
|
||||
spiAllowAgg :: !Bool,
|
||||
|
@ -175,7 +175,7 @@ mkParser table cib =
|
||||
selPermInfo =
|
||||
SelPermInfo
|
||||
{ spiCols = HM.fromList . fmap ((,Nothing) . unsafePGCol . cibName) $ cib,
|
||||
spiScalarComputedFields = mempty,
|
||||
spiComputedFields = mempty,
|
||||
spiFilter = upiFilter,
|
||||
spiLimit = Nothing,
|
||||
spiAllowAgg = True,
|
||||
|
Loading…
Reference in New Issue
Block a user