这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion server/src-lib/Hasura/GraphQL/Explain.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import qualified Hasura.GraphQL.Transport.HTTP.Protocol as GH
import qualified Hasura.GraphQL.Validate as GV
import qualified Hasura.RQL.DML.Select as RS
import qualified Hasura.Server.Query as RQ
import qualified Hasura.SQL.DML as S

data GQLExplain
= GQLExplain
Expand Down Expand Up @@ -91,7 +92,8 @@ explainField userInfo gCtx fld =
return $ FieldPlan fName (Just selectSQL) $ Just planLines
where
fName = _fName fld
txtConverter = return . txtEncoder . snd
txtConverter (ty, val) =
return $ S.annotateExp (txtEncoder val) ty
opCtxMap = _gOpCtxMap gCtx
fldMap = _gFields gCtx
orderByCtx = _gOrdByCtx gCtx
Expand Down
8 changes: 1 addition & 7 deletions server/src-lib/Hasura/RQL/GBoolExp.hs
Original file line number Diff line number Diff line change
Expand Up @@ -410,12 +410,6 @@ cColExp annVal = case annVal of
innerBoolExp = S.BEBin S.AndOp backCompExp annRelBoolExp
S.mkExists relTN innerBoolExp

inBoolExpBuilder :: S.SQLExp -> [S.SQLExp] -> S.BoolExp
inBoolExpBuilder qualColExp rhsExps =
foldr (S.BEBin S.OrOp) (S.BELit False) eqExps
where
eqExps = map (equalsBoolExpBuilder qualColExp) rhsExps

-- txtValParser
-- :: (MonadError QErr m)
-- => ValueParser m (AnnValOpExpG S.SQLExp)
Expand Down Expand Up @@ -481,7 +475,7 @@ mkBoolExpBuilder rhsBldr lhs = \case

mkInOrNotBoolExpBuilder isIn arrVals = do
rhsExps <- mapM rhsBldr arrVals
let boolExp = inBoolExpBuilder lhs rhsExps
let boolExp = S.BEEqualsAny lhs rhsExps
return $ bool (S.BENot boolExp) boolExp isIn

-- txtRHSBuilder :: (MonadError QErr m) => RHSBuilder m
Expand Down
9 changes: 9 additions & 0 deletions server/src-lib/Hasura/SQL/DML.hs
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,10 @@ intToSQLExp :: Int -> SQLExp
intToSQLExp =
SEUnsafe . T.pack . show

annotateExp :: SQLExp -> PGColType -> SQLExp
annotateExp sqlExp =
SETyAnn sqlExp . AnnType . T.pack . show

data Extractor = Extractor !SQLExp !(Maybe Alias)
deriving (Show, Eq)

Expand Down Expand Up @@ -439,6 +443,7 @@ data BoolExp
| BENull !SQLExp
| BENotNull !SQLExp
| BEExists !Select
| BEEqualsAny !SQLExp ![SQLExp]
deriving (Show, Eq)

-- removes extraneous 'AND true's
Expand Down Expand Up @@ -483,6 +488,10 @@ instance ToSQL BoolExp where
paren (toSQL v) <-> "IS NOT NULL"
toSQL (BEExists sel) =
"EXISTS " <-> paren (toSQL sel)
-- special case to handle 'lhs = ANY(ARRAY[..])'
toSQL (BEEqualsAny l rhsExps) =
paren (toSQL l) <-> toSQL SEQ
<-> toSQL (SEFnApp "ANY" [SEArray rhsExps] Nothing)

data BinOp = AndOp
| OrOp
Expand Down
2 changes: 2 additions & 0 deletions server/src-lib/Hasura/SQL/Rewrite.hs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ uBoolExp = restoringIdens . \case
S.BENull e -> S.BENull <$> uSqlExp e
S.BENotNull e -> S.BENotNull <$> uSqlExp e
S.BEExists sel -> S.BEExists <$> uSelect sel
S.BEEqualsAny l rExps ->
S.BEEqualsAny <$> uSqlExp l <*> mapM uSqlExp rExps

uOrderBy :: S.OrderByExp -> Uniq S.OrderByExp
uOrderBy (S.OrderByExp ordByItems) =
Expand Down