Skip to content

Commit

Permalink
no-op refactor; resolve review comments
Browse files Browse the repository at this point in the history
As suggested by @lexi-lambda
  • Loading branch information
rakeshkky committed Sep 26, 2019
1 parent a7e2d6d commit 53b7760
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
9 changes: 9 additions & 0 deletions server/src-lib/Hasura/RQL/DDL/Schema/Catalog.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module Hasura.RQL.DDL.Schema.Catalog
, updateTableIsEnumInCatalog
, updateTableConfig
, deleteTableFromCatalog
, getTableConfig
) where

import Hasura.Prelude
Expand Down Expand Up @@ -56,3 +57,11 @@ deleteTableFromCatalog (QualifiedObject sn tn) = liftTx $ Q.unitQE defaultTxErro
DELETE FROM "hdb_catalog"."hdb_table"
WHERE table_schema = $1 AND table_name = $2
|] (sn, tn) False

getTableConfig :: MonadTx m => QualifiedTable -> m TableConfig
getTableConfig (QualifiedObject sn tn) = liftTx $
Q.getAltJ . runIdentity . Q.getRow <$> Q.withQE defaultTxErrorHandler
[Q.sql|
SELECT configuration::json FROM hdb_catalog.hdb_table
WHERE table_schema = $1 AND table_name = $2
|] (sn, tn) True
10 changes: 1 addition & 9 deletions server/src-lib/Hasura/RQL/DDL/Schema/Rename.hs
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ updateColMap fromQT toQT rnCol colMap =
possiblyUpdateCustomColumnNames
:: MonadTx m => QualifiedTable -> PGCol -> PGCol -> m ()
possiblyUpdateCustomColumnNames qt oCol nCol = do
TableConfig customRootFields customColumns <- liftTx $ getTableConfig qt
TableConfig customRootFields customColumns <- getTableConfig qt
let updatedCustomColumns =
M.fromList $ flip map (M.toList customColumns) $
\(dbCol, val) -> (, val) $ if dbCol == oCol then nCol else dbCol
Expand All @@ -446,11 +446,3 @@ updateRel (QualifiedObject sn tn) rn relDef =
AND table_name = $3
AND rel_name = $4
|] (Q.AltJ relDef, sn , tn, rn) True

getTableConfig :: QualifiedTable -> Q.TxE QErr TableConfig
getTableConfig (QualifiedObject sn tn) =
Q.getAltJ . runIdentity . Q.getRow <$> Q.withQE defaultTxErrorHandler
[Q.sql|
SELECT configuration::json FROM hdb_catalog.hdb_table
WHERE table_schema = $1 AND table_name = $2
|] (sn, tn) True
2 changes: 1 addition & 1 deletion server/src-lib/Hasura/RQL/DDL/Schema/Table.hs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ processTableChanges ti tableDiff = do

possiblyDropCustomColumnNames tn = do
let TableConfig customFields customColumnNames = _tiCustomConfig ti
modifiedCustomColumnNames = foldl (flip M.delete) customColumnNames droppedCols
modifiedCustomColumnNames = foldl' (flip M.delete) customColumnNames droppedCols
if modifiedCustomColumnNames == customColumnNames then
pure customColumnNames
else do
Expand Down

0 comments on commit 53b7760

Please sign in to comment.