refactor: self relationship
* Add test for self relationship in view
This commit is contained in:
committed by
Steve Chavez
parent
c60380b5fc
commit
2be63b36d6
@@ -5,7 +5,6 @@ module PostgREST.DbStructure.Relationship
|
||||
( Cardinality(..)
|
||||
, Relationship(..)
|
||||
, Junction(..)
|
||||
, isSelfReference
|
||||
, RelationshipsMap
|
||||
) where
|
||||
|
||||
@@ -22,6 +21,7 @@ import Protolude
|
||||
data Relationship = Relationship
|
||||
{ relTable :: QualifiedIdentifier
|
||||
, relForeignTable :: QualifiedIdentifier
|
||||
, relIsSelf :: Bool -- ^ Whether is a self relationship
|
||||
, relCardinality :: Cardinality
|
||||
}
|
||||
deriving (Eq, Ord, Generic, JSON.ToJSON)
|
||||
@@ -50,8 +50,5 @@ data Junction = Junction
|
||||
}
|
||||
deriving (Eq, Ord, Generic, JSON.ToJSON)
|
||||
|
||||
isSelfReference :: Relationship -> Bool
|
||||
isSelfReference r = relTable r == relForeignTable r
|
||||
|
||||
-- | Key based on the source table and the foreign table schema
|
||||
type RelationshipsMap = M.HashMap (QualifiedIdentifier, Schema) [Relationship]
|
||||
|
||||
Reference in New Issue
Block a user