refactor: remove Table from Relationship

Just having the QualifiedIdentifier gets us closer to having
Relationship as a Table attribute since it avoids a cyclic dependency

* remove unnecessary findTable
* modify RootSpec test
This commit is contained in:
steve-chavez
2022-04-18 15:48:03 -05:00
committed by Steve Chavez
parent cdcc175abf
commit 7f1507b9fb
9 changed files with 54 additions and 65 deletions
+5 -4
View File
@@ -11,7 +11,8 @@ module PostgREST.DbStructure.Relationship
import qualified Data.Aeson as JSON
import PostgREST.DbStructure.Table (Column (..), Table (..))
import PostgREST.DbStructure.Identifiers (QualifiedIdentifier)
import PostgREST.DbStructure.Table (Column (..), Table)
import Protolude
@@ -23,9 +24,9 @@ import Protolude
--
-- TODO merge relColumns and relForeignColumns to a tuple or Data.Bimap
data Relationship = Relationship
{ relTable :: Table
{ relTable :: QualifiedIdentifier
, relColumns :: [Column]
, relForeignTable :: Table
, relForeignTable :: QualifiedIdentifier
, relForeignColumns :: [Column]
, relCardinality :: Cardinality
}
@@ -44,7 +45,7 @@ type FKConstraint = Text
-- | Junction table on an M2M relationship
data Junction = Junction
{ junTable :: Table
{ junTable :: QualifiedIdentifier
, junConstraint1 :: FKConstraint
, junColumns1 :: [Column]
, junConstraint2 :: FKConstraint
+1 -5
View File
@@ -4,11 +4,10 @@
module PostgREST.DbStructure.Table
( Column(..)
, Table(..)
, tableQi
, TablesMap
) where
import qualified Data.Aeson as JSON
import qualified Data.Aeson as JSON
import qualified Data.HashMap.Strict as M
import PostgREST.DbStructure.Identifiers (FieldName,
@@ -34,9 +33,6 @@ data Table = Table
instance Eq Table where
Table{tableSchema=s1,tableName=n1} == Table{tableSchema=s2,tableName=n2} = s1 == s2 && n1 == n2
tableQi :: Table -> QualifiedIdentifier
tableQi Table{tableSchema=s, tableName=n} = QualifiedIdentifier s n
data Column = Column
{ colTable :: Table
, colName :: FieldName