From 0a9382f2dca07cf3c02e5f86b51c0e77bc80d7f6 Mon Sep 17 00:00:00 2001 From: Antoine Leblanc Date: Fri, 9 Jul 2021 16:53:55 +0100 Subject: [PATCH] [gardening] remove Alias from Backend ### Description In our haste to generalize everything for MSSQL, we put every single "suspicious" type in Backend, including ones that weren't required. `Alias` is one of those: it's only used in a type alias, and is actually just an implementation detail of the translation layer. This PR removes it. https://github.com/hasura/graphql-engine-mono/pull/1759 GitOrigin-RevId: fb348934ec65a51aae7f95d93c83c3bb704587b5 --- .../Hasura/Backends/BigQuery/Instances/Types.hs | 1 - .../src-lib/Hasura/Backends/MSSQL/Instances/Types.hs | 1 - .../Hasura/Backends/Postgres/Instances/Types.hs | 1 - .../Hasura/Backends/Postgres/Translate/Select.hs | 12 +++++++++--- .../Hasura/GraphQL/Execute/RemoteJoin/Join.hs | 2 +- server/src-lib/Hasura/RQL/IR/Select.hs | 1 - server/src-lib/Hasura/RQL/Types/Backend.hs | 1 - 7 files changed, 10 insertions(+), 9 deletions(-) diff --git a/server/src-lib/Hasura/Backends/BigQuery/Instances/Types.hs b/server/src-lib/Hasura/Backends/BigQuery/Instances/Types.hs index 9981f8136e1..569135d00fe 100644 --- a/server/src-lib/Hasura/Backends/BigQuery/Instances/Types.hs +++ b/server/src-lib/Hasura/Backends/BigQuery/Instances/Types.hs @@ -21,7 +21,6 @@ instance Backend 'BigQuery where type SourceConfig 'BigQuery = BigQuery.BigQuerySourceConfig type SourceConnConfiguration 'BigQuery = BigQuery.BigQueryConnSourceConfig type Identifier 'BigQuery = Void - type Alias 'BigQuery = BigQuery.EntityAlias type TableName 'BigQuery = BigQuery.TableName type FunctionName 'BigQuery = BigQuery.FunctionName type FunctionArgType 'BigQuery = Void diff --git a/server/src-lib/Hasura/Backends/MSSQL/Instances/Types.hs b/server/src-lib/Hasura/Backends/MSSQL/Instances/Types.hs index 83ac89e251c..82155f0fe69 100644 --- a/server/src-lib/Hasura/Backends/MSSQL/Instances/Types.hs +++ b/server/src-lib/Hasura/Backends/MSSQL/Instances/Types.hs @@ -22,7 +22,6 @@ instance Backend 'MSSQL where type SourceConfig 'MSSQL = MSSQL.MSSQLSourceConfig type SourceConnConfiguration 'MSSQL = MSSQL.MSSQLConnConfiguration type Identifier 'MSSQL = Void - type Alias 'MSSQL = MSSQL.EntityAlias type TableName 'MSSQL = MSSQL.TableName type FunctionName 'MSSQL = MSSQL.FunctionName type FunctionArgType 'MSSQL = Void diff --git a/server/src-lib/Hasura/Backends/Postgres/Instances/Types.hs b/server/src-lib/Hasura/Backends/Postgres/Instances/Types.hs index 0c50b61c4f0..1a1bac5cee9 100644 --- a/server/src-lib/Hasura/Backends/Postgres/Instances/Types.hs +++ b/server/src-lib/Hasura/Backends/Postgres/Instances/Types.hs @@ -59,7 +59,6 @@ instance type SourceConfig ('Postgres pgKind) = PG.PGSourceConfig type SourceConnConfiguration ('Postgres pgKind) = PG.PostgresConnConfiguration type Identifier ('Postgres pgKind) = PG.Identifier - type Alias ('Postgres pgKind) = PG.Alias type TableName ('Postgres pgKind) = PG.QualifiedTable type FunctionName ('Postgres pgKind) = PG.QualifiedFunction type FunctionArgType ('Postgres pgKind) = PG.QualifiedPGType diff --git a/server/src-lib/Hasura/Backends/Postgres/Translate/Select.hs b/server/src-lib/Hasura/Backends/Postgres/Translate/Select.hs index df73ee2f7a4..aa2210b2c14 100644 --- a/server/src-lib/Hasura/Backends/Postgres/Translate/Select.hs +++ b/server/src-lib/Hasura/Backends/Postgres/Translate/Select.hs @@ -697,7 +697,9 @@ processOrderByItems sourcePrefix' fieldAlias' similarArrayFields orderByItems = cursor = mkCursorExp $ toList orderByItemExps pure (orderByExtractors, orderByExp, cursor) where - processAnnOrderByItem :: AnnOrderByItem ('Postgres pgKind) -> m (OrderByItemExp ('Postgres pgKind)) + processAnnOrderByItem + :: AnnOrderByItem ('Postgres pgKind) + -> m (OrderByItemG ('Postgres pgKind) (AnnOrderByElement ('Postgres pgKind) (SQLExpression ('Postgres pgKind)), (S.Alias, SQLExpression ('Postgres pgKind)))) processAnnOrderByItem orderByItem = forM orderByItem $ \ordByCol -> (ordByCol,) <$> processAnnOrderByElement sourcePrefix' fieldAlias' ordByCol @@ -743,12 +745,16 @@ processOrderByItems sourcePrefix' fieldAlias' similarArrayFields orderByItems = , S.mkQIdenExp relSourcePrefix (mkAggregateOrderByAlias aggOrderBy) ) - toOrderByExp :: OrderByItemExp ('Postgres pgKind) -> S.OrderByItem + toOrderByExp + :: OrderByItemG ('Postgres pgKind) (AnnOrderByElement ('Postgres pgKind) (SQLExpression ('Postgres pgKind)), (S.Alias, SQLExpression ('Postgres pgKind))) + -> S.OrderByItem toOrderByExp orderByItemExp = let OrderByItemG obTyM expAlias obNullsM = fst . snd <$> orderByItemExp in S.OrderByItem (S.SEIdentifier $ toIdentifier expAlias) obTyM obNullsM - mkCursorExp :: [OrderByItemExp ('Postgres pgKind)] -> S.SQLExp + mkCursorExp + :: [OrderByItemG ('Postgres pgKind) (AnnOrderByElement ('Postgres pgKind) (SQLExpression ('Postgres pgKind)), (S.Alias, SQLExpression ('Postgres pgKind)))] + -> S.SQLExp mkCursorExp orderByItemExps = S.applyJsonBuildObj $ flip concatMap orderByItemExps $ \orderByItemExp -> diff --git a/server/src-lib/Hasura/GraphQL/Execute/RemoteJoin/Join.hs b/server/src-lib/Hasura/GraphQL/Execute/RemoteJoin/Join.hs index 84b8fcf6c5c..74286afdbdd 100644 --- a/server/src-lib/Hasura/GraphQL/Execute/RemoteJoin/Join.hs +++ b/server/src-lib/Hasura/GraphQL/Execute/RemoteJoin/Join.hs @@ -31,7 +31,7 @@ import Hasura.GraphQL.Parser hiding (field) import Hasura.GraphQL.RemoteServer (execRemoteGQ) import Hasura.GraphQL.Transport.HTTP.Protocol import Hasura.RQL.IR.Select -import Hasura.RQL.Types hiding (Alias) +import Hasura.RQL.Types import Hasura.Server.Version (HasVersion) import Hasura.Session diff --git a/server/src-lib/Hasura/RQL/IR/Select.hs b/server/src-lib/Hasura/RQL/IR/Select.hs index fe19455e9bd..f84aa2f1cad 100644 --- a/server/src-lib/Hasura/RQL/IR/Select.hs +++ b/server/src-lib/Hasura/RQL/IR/Select.hs @@ -176,7 +176,6 @@ instance (Backend b) => Hashable (AnnAggregateOrderBy b) type AnnOrderByElement b v = AnnOrderByElementG b (AnnBoolExp b v) type AnnOrderByItemG b v = OrderByItemG b (AnnOrderByElement b v) type AnnOrderByItem b = AnnOrderByItemG b (SQLExpression b) -type OrderByItemExp b = OrderByItemG b (AnnOrderByElement b (SQLExpression b), (Alias b, SQLExpression b)) -- Fields diff --git a/server/src-lib/Hasura/RQL/Types/Backend.hs b/server/src-lib/Hasura/RQL/Types/Backend.hs index 65b352139ed..22b161e1469 100644 --- a/server/src-lib/Hasura/RQL/Types/Backend.hs +++ b/server/src-lib/Hasura/RQL/Types/Backend.hs @@ -109,7 +109,6 @@ class type SourceConfig b :: Type type SourceConnConfiguration b :: Type type Identifier b :: Type - type Alias b :: Type type TableName b :: Type type FunctionName b :: Type type FunctionArgType b :: Type