graphql-engine/server/src-lib/Hasura/Backends/Postgres/Translate/Select.hs
Evie Ciobanu 0060a48009 server: minor nit-picks for the Postgres Select module split
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4338
GitOrigin-RevId: c2125275b32a5084c5a96afba79d4cb6c65687a8
2022-04-22 17:19:58 +00:00

48 lines
1.7 KiB
Haskell

-- | Postgres Translate Select
--
-- This module is a translation layer between IR and postgres-specific select queries.
--
-- There are four main types of selects (as distinguished from the IR):
--
-- * "simple" selects
--
-- * aggregate selects
--
-- * connection selects (used for relay)
--
-- * streaming selects (see Hasura.Backends.Postgres.Translate.Select.Streaming for details)
module Hasura.Backends.Postgres.Translate.Select
( module Simple,
module Aggregate,
module Connection,
module Streaming,
PostgresAnnotatedFieldJSON,
)
where
import Hasura.Backends.Postgres.Translate.Select.Aggregate as Aggregate
import Hasura.Backends.Postgres.Translate.Select.AnnotatedFieldJSON (PostgresAnnotatedFieldJSON)
import Hasura.Backends.Postgres.Translate.Select.Connection as Connection
import Hasura.Backends.Postgres.Translate.Select.Simple as Simple
import Hasura.Backends.Postgres.Translate.Select.Streaming as Streaming
{- Note: [SQL generation for inherited roles]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When a query is executed by an inherited role, each column may contain a predicate
(AnnColumnCaseBoolExp ('Postgres pgKind) SQLExp) along with it. The predicate is then
converted to a BoolExp, which will be used to check if the said column should
be nullified. For example,
Suppose there are two roles, role1 gives access only to the `addr` column with
row filter P1 and role2 gives access to both addr and phone column with row
filter P2. The `OR`ing of the predicates will have already been done while
the schema has been generated. The SQL generated will look like this:
select
(case when (P1 or P2) then addr else null end) as addr,
(case when P2 then phone else null end) as phone
from employee
where (P1 or P2)
-}