refactor: rename RelationType to Cardinality

Remove Root type constructor
This commit is contained in:
steve-chavez
2019-11-05 12:55:48 -05:00
committed by Steve Chávez
parent db41fb454e
commit cb3d9ab625
3 changed files with 19 additions and 17 deletions
+9 -4
View File
@@ -257,7 +257,12 @@ data QualifiedIdentifier = QualifiedIdentifier {
} deriving (Show, Eq, Ord)
data RelationType = Child | Parent | Many | Root deriving (Show, Eq)
-- | The relationship [cardinality](https://en.wikipedia.org/wiki/Cardinality_(data_modeling)).
-- | TODO: missing one-to-one
data Cardinality = Child -- ^ a.k.a. many-to-one
| Parent -- ^ a.k.a. one-to-many
| Many -- ^ a.k.a. many-to-many
deriving (Show, Eq)
{-|
The name 'Relation' here is used with the meaning
@@ -272,15 +277,15 @@ data Relation = Relation {
, relColumns :: [Column]
, relFTable :: Table
, relFColumns :: [Column]
, relType :: RelationType
-- The Link attrs are used when RelationType == Many
, relType :: Cardinality
-- The Link attrs are used when Cardinality == Many
, relLinkTable :: Maybe Table
, relLinkCols1 :: Maybe [Column]
, relLinkCols2 :: Maybe [Column]
} deriving (Show, Eq)
isSelfJoin :: Relation -> Bool
isSelfJoin r = relType r /= Root && relTable r == relFTable r
isSelfJoin r = relTable r == relFTable r
data PayloadJSON =
-- | Cached attributes of a JSON payload