chore: show on ReadPlan and MediaType
This commit is contained in:
committed by
Steve Chavez
parent
7508230760
commit
20b06efabe
@@ -65,23 +65,6 @@ import Protolude hiding (try)
|
|||||||
-- Setup for doctests
|
-- Setup for doctests
|
||||||
-- >>> import Text.Pretty.Simple (pPrint)
|
-- >>> import Text.Pretty.Simple (pPrint)
|
||||||
-- >>> deriving instance Show QPError
|
-- >>> deriving instance Show QPError
|
||||||
-- >>> deriving instance Show TrileanVal
|
|
||||||
-- >>> deriving instance Show FtsOperator
|
|
||||||
-- >>> deriving instance Show QuantOperator
|
|
||||||
-- >>> deriving instance Show SimpleOperator
|
|
||||||
-- >>> deriving instance Show OpQuantifier
|
|
||||||
-- >>> deriving instance Show Operation
|
|
||||||
-- >>> deriving instance Show OpExpr
|
|
||||||
-- >>> deriving instance Show JsonOperand
|
|
||||||
-- >>> deriving instance Show JsonOperation
|
|
||||||
-- >>> deriving instance Show Filter
|
|
||||||
-- >>> deriving instance Show JoinType
|
|
||||||
-- >>> deriving instance Show SelectItem
|
|
||||||
-- >>> deriving instance Show OrderDirection
|
|
||||||
-- >>> deriving instance Show OrderNulls
|
|
||||||
-- >>> deriving instance Show OrderTerm
|
|
||||||
-- >>> deriving instance Show LogicOperator
|
|
||||||
-- >>> deriving instance Show LogicTree
|
|
||||||
|
|
||||||
data QueryParams =
|
data QueryParams =
|
||||||
QueryParams
|
QueryParams
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ data SelectItem
|
|||||||
, selHint :: Maybe Hint
|
, selHint :: Maybe Hint
|
||||||
, selJoinType :: Maybe JoinType
|
, selJoinType :: Maybe JoinType
|
||||||
}
|
}
|
||||||
deriving (Eq)
|
deriving (Eq, Show)
|
||||||
|
|
||||||
data ApiRequestError
|
data ApiRequestError
|
||||||
= AmbiguousRelBetween Text Text [Relationship]
|
= AmbiguousRelBetween Text Text [Relationship]
|
||||||
@@ -108,17 +108,17 @@ data OrderTerm
|
|||||||
, otDirection :: Maybe OrderDirection
|
, otDirection :: Maybe OrderDirection
|
||||||
, otNullOrder :: Maybe OrderNulls
|
, otNullOrder :: Maybe OrderNulls
|
||||||
}
|
}
|
||||||
deriving Eq
|
deriving (Eq, Show)
|
||||||
|
|
||||||
data OrderDirection
|
data OrderDirection
|
||||||
= OrderAsc
|
= OrderAsc
|
||||||
| OrderDesc
|
| OrderDesc
|
||||||
deriving (Eq)
|
deriving (Eq, Show)
|
||||||
|
|
||||||
data OrderNulls
|
data OrderNulls
|
||||||
= OrderNullsFirst
|
= OrderNullsFirst
|
||||||
| OrderNullsLast
|
| OrderNullsLast
|
||||||
deriving (Eq)
|
deriving (Eq, Show)
|
||||||
|
|
||||||
type Field = (FieldName, JsonPath)
|
type Field = (FieldName, JsonPath)
|
||||||
type Cast = Text
|
type Cast = Text
|
||||||
@@ -135,7 +135,7 @@ data EmbedParam
|
|||||||
data JoinType
|
data JoinType
|
||||||
= JTInner
|
= JTInner
|
||||||
| JTLeft
|
| JTLeft
|
||||||
deriving Eq
|
deriving (Eq, Show)
|
||||||
|
|
||||||
-- | Path of the embedded levels, e.g "clients.projects.name=eq.." gives Path
|
-- | Path of the embedded levels, e.g "clients.projects.name=eq.." gives Path
|
||||||
-- ["clients", "projects"]
|
-- ["clients", "projects"]
|
||||||
@@ -149,7 +149,7 @@ type JsonPath = [JsonOperation]
|
|||||||
data JsonOperation
|
data JsonOperation
|
||||||
= JArrow { jOp :: JsonOperand }
|
= JArrow { jOp :: JsonOperand }
|
||||||
| J2Arrow { jOp :: JsonOperand }
|
| J2Arrow { jOp :: JsonOperand }
|
||||||
deriving (Eq, Ord)
|
deriving (Eq, Show, Ord)
|
||||||
|
|
||||||
-- | Represents the key(`->'key'`) or index(`->'1`::int`), the index is Text
|
-- | Represents the key(`->'key'`) or index(`->'1`::int`), the index is Text
|
||||||
-- because we reuse our escaping functons and let pg do the casting with
|
-- because we reuse our escaping functons and let pg do the casting with
|
||||||
@@ -157,7 +157,7 @@ data JsonOperation
|
|||||||
data JsonOperand
|
data JsonOperand
|
||||||
= JKey { jVal :: Text }
|
= JKey { jVal :: Text }
|
||||||
| JIdx { jVal :: Text }
|
| JIdx { jVal :: Text }
|
||||||
deriving (Eq, Ord)
|
deriving (Eq, Show, Ord)
|
||||||
|
|
||||||
-- | Boolean logic expression tree e.g. "and(name.eq.N,or(id.eq.1,id.eq.2))" is:
|
-- | Boolean logic expression tree e.g. "and(name.eq.N,or(id.eq.1,id.eq.2))" is:
|
||||||
--
|
--
|
||||||
@@ -169,12 +169,12 @@ data JsonOperand
|
|||||||
data LogicTree
|
data LogicTree
|
||||||
= Expr Bool LogicOperator [LogicTree]
|
= Expr Bool LogicOperator [LogicTree]
|
||||||
| Stmnt Filter
|
| Stmnt Filter
|
||||||
deriving (Eq)
|
deriving (Eq, Show)
|
||||||
|
|
||||||
data LogicOperator
|
data LogicOperator
|
||||||
= And
|
= And
|
||||||
| Or
|
| Or
|
||||||
deriving Eq
|
deriving (Eq, Show)
|
||||||
|
|
||||||
data Filter
|
data Filter
|
||||||
= Filter
|
= Filter
|
||||||
@@ -182,15 +182,15 @@ data Filter
|
|||||||
, opExpr :: OpExpr
|
, opExpr :: OpExpr
|
||||||
}
|
}
|
||||||
| FilterNullEmbed Bool FieldName
|
| FilterNullEmbed Bool FieldName
|
||||||
deriving (Eq)
|
deriving (Eq, Show)
|
||||||
|
|
||||||
data OpExpr
|
data OpExpr
|
||||||
= OpExpr Bool Operation
|
= OpExpr Bool Operation
|
||||||
| NoOpExpr Text
|
| NoOpExpr Text
|
||||||
deriving (Eq)
|
deriving (Eq, Show)
|
||||||
|
|
||||||
data OpQuantifier = QuantAny | QuantAll
|
data OpQuantifier = QuantAny | QuantAll
|
||||||
deriving Eq
|
deriving (Eq, Show)
|
||||||
|
|
||||||
data Operation
|
data Operation
|
||||||
= Op SimpleOperator SingleVal
|
= Op SimpleOperator SingleVal
|
||||||
@@ -199,7 +199,7 @@ data Operation
|
|||||||
| Is TrileanVal
|
| Is TrileanVal
|
||||||
| IsDistinctFrom SingleVal
|
| IsDistinctFrom SingleVal
|
||||||
| Fts FtsOperator (Maybe Language) SingleVal
|
| Fts FtsOperator (Maybe Language) SingleVal
|
||||||
deriving (Eq)
|
deriving (Eq, Show)
|
||||||
|
|
||||||
type Language = Text
|
type Language = Text
|
||||||
|
|
||||||
@@ -215,7 +215,7 @@ data TrileanVal
|
|||||||
| TriFalse
|
| TriFalse
|
||||||
| TriNull
|
| TriNull
|
||||||
| TriUnknown
|
| TriUnknown
|
||||||
deriving Eq
|
deriving (Eq, Show)
|
||||||
|
|
||||||
-- Operators that are quantifiable, i.e. they can be used with the any/all modifiers
|
-- Operators that are quantifiable, i.e. they can be used with the any/all modifiers
|
||||||
data QuantOperator
|
data QuantOperator
|
||||||
@@ -228,7 +228,7 @@ data QuantOperator
|
|||||||
| OpILike
|
| OpILike
|
||||||
| OpMatch
|
| OpMatch
|
||||||
| OpIMatch
|
| OpIMatch
|
||||||
deriving Eq
|
deriving (Eq, Show)
|
||||||
|
|
||||||
data SimpleOperator
|
data SimpleOperator
|
||||||
= OpNotEqual
|
= OpNotEqual
|
||||||
@@ -240,7 +240,7 @@ data SimpleOperator
|
|||||||
| OpNotExtendsRight
|
| OpNotExtendsRight
|
||||||
| OpNotExtendsLeft
|
| OpNotExtendsLeft
|
||||||
| OpAdjacent
|
| OpAdjacent
|
||||||
deriving Eq
|
deriving (Eq, Show)
|
||||||
|
|
||||||
--
|
--
|
||||||
-- | Operators for full text search operators
|
-- | Operators for full text search operators
|
||||||
@@ -249,4 +249,4 @@ data FtsOperator
|
|||||||
| FilterFtsPlain
|
| FilterFtsPlain
|
||||||
| FilterFtsPhrase
|
| FilterFtsPhrase
|
||||||
| FilterFtsWebsearch
|
| FilterFtsWebsearch
|
||||||
deriving Eq
|
deriving (Eq, Show)
|
||||||
|
|||||||
@@ -17,14 +17,6 @@ import Network.HTTP.Types.Header (Header, hContentType)
|
|||||||
|
|
||||||
import Protolude
|
import Protolude
|
||||||
|
|
||||||
--
|
|
||||||
-- $setup
|
|
||||||
-- Setup for doctests
|
|
||||||
-- >>> import Text.Pretty.Simple (pPrint)
|
|
||||||
-- >>> deriving instance Show MTPlanFormat
|
|
||||||
-- >>> deriving instance Show MTPlanOption
|
|
||||||
-- >>> deriving instance Show MediaType
|
|
||||||
|
|
||||||
-- | Enumeration of currently supported media types
|
-- | Enumeration of currently supported media types
|
||||||
data MediaType
|
data MediaType
|
||||||
= MTApplicationJSON
|
= MTApplicationJSON
|
||||||
@@ -39,6 +31,7 @@ data MediaType
|
|||||||
| MTAny
|
| MTAny
|
||||||
| MTOther ByteString
|
| MTOther ByteString
|
||||||
| MTPlan MediaType MTPlanFormat [MTPlanOption]
|
| MTPlan MediaType MTPlanFormat [MTPlanOption]
|
||||||
|
deriving Show
|
||||||
instance Eq MediaType where
|
instance Eq MediaType where
|
||||||
MTApplicationJSON == MTApplicationJSON = True
|
MTApplicationJSON == MTApplicationJSON = True
|
||||||
MTSingularJSON == MTSingularJSON = True
|
MTSingularJSON == MTSingularJSON = True
|
||||||
@@ -56,9 +49,11 @@ instance Eq MediaType where
|
|||||||
|
|
||||||
data MTPlanOption
|
data MTPlanOption
|
||||||
= PlanAnalyze | PlanVerbose | PlanSettings | PlanBuffers | PlanWAL
|
= PlanAnalyze | PlanVerbose | PlanSettings | PlanBuffers | PlanWAL
|
||||||
|
deriving (Eq, Show)
|
||||||
|
|
||||||
data MTPlanFormat
|
data MTPlanFormat
|
||||||
= PlanJSON | PlanText
|
= PlanJSON | PlanText
|
||||||
|
deriving (Eq, Show)
|
||||||
|
|
||||||
-- | Convert MediaType to a Content-Type HTTP Header
|
-- | Convert MediaType to a Content-Type HTTP Header
|
||||||
toContentType :: MediaType -> Header
|
toContentType :: MediaType -> Header
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ data JoinCondition =
|
|||||||
JoinCondition
|
JoinCondition
|
||||||
(QualifiedIdentifier, FieldName)
|
(QualifiedIdentifier, FieldName)
|
||||||
(QualifiedIdentifier, FieldName)
|
(QualifiedIdentifier, FieldName)
|
||||||
deriving (Eq)
|
deriving (Eq, Show)
|
||||||
|
|
||||||
data ReadPlan = ReadPlan
|
data ReadPlan = ReadPlan
|
||||||
{ select :: [(CoercibleField, Maybe Cast, Maybe Alias)]
|
{ select :: [(CoercibleField, Maybe Cast, Maybe Alias)]
|
||||||
@@ -45,4 +45,4 @@ data ReadPlan = ReadPlan
|
|||||||
, depth :: Depth
|
, depth :: Depth
|
||||||
-- ^ used for aliasing
|
-- ^ used for aliasing
|
||||||
}
|
}
|
||||||
deriving (Eq)
|
deriving (Eq, Show)
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ data CoercibleField = CoercibleField
|
|||||||
, cfIRType :: Text -- ^ The native Postgres type of the field, the intermediate (IR) type before mapping.
|
, cfIRType :: Text -- ^ The native Postgres type of the field, the intermediate (IR) type before mapping.
|
||||||
, cfTransform :: Maybe TransformerProc -- ^ The optional mapping from irType -> targetType.
|
, cfTransform :: Maybe TransformerProc -- ^ The optional mapping from irType -> targetType.
|
||||||
, cfDefault :: Maybe Text
|
, cfDefault :: Maybe Text
|
||||||
} deriving Eq
|
} deriving (Eq, Show)
|
||||||
|
|
||||||
unknownField :: FieldName -> JsonPath -> CoercibleField
|
unknownField :: FieldName -> JsonPath -> CoercibleField
|
||||||
unknownField name path = CoercibleField name path "" Nothing Nothing
|
unknownField name path = CoercibleField name path "" Nothing Nothing
|
||||||
@@ -40,11 +40,11 @@ unknownField name path = CoercibleField name path "" Nothing Nothing
|
|||||||
data CoercibleLogicTree
|
data CoercibleLogicTree
|
||||||
= CoercibleExpr Bool LogicOperator [CoercibleLogicTree]
|
= CoercibleExpr Bool LogicOperator [CoercibleLogicTree]
|
||||||
| CoercibleStmnt CoercibleFilter
|
| CoercibleStmnt CoercibleFilter
|
||||||
deriving (Eq)
|
deriving (Eq, Show)
|
||||||
|
|
||||||
data CoercibleFilter = CoercibleFilter
|
data CoercibleFilter = CoercibleFilter
|
||||||
{ field :: CoercibleField
|
{ field :: CoercibleField
|
||||||
, opExpr :: OpExpr
|
, opExpr :: OpExpr
|
||||||
}
|
}
|
||||||
| CoercibleFilterNullEmbed Bool FieldName
|
| CoercibleFilterNullEmbed Bool FieldName
|
||||||
deriving (Eq)
|
deriving (Eq, Show)
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ data QualifiedIdentifier = QualifiedIdentifier
|
|||||||
{ qiSchema :: Schema
|
{ qiSchema :: Schema
|
||||||
, qiName :: TableName
|
, qiName :: TableName
|
||||||
}
|
}
|
||||||
deriving (Eq, Ord, Generic, JSON.ToJSON, JSON.ToJSONKey)
|
deriving (Eq, Show, Ord, Generic, JSON.ToJSON, JSON.ToJSONKey)
|
||||||
|
|
||||||
instance Hashable QualifiedIdentifier
|
instance Hashable QualifiedIdentifier
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ data Relationship = Relationship
|
|||||||
, relToOne :: Bool
|
, relToOne :: Bool
|
||||||
, relIsSelf :: Bool
|
, relIsSelf :: Bool
|
||||||
}
|
}
|
||||||
deriving (Eq, Ord, Generic, JSON.ToJSON)
|
deriving (Eq, Show, Ord, Generic, JSON.ToJSON)
|
||||||
|
|
||||||
-- | The relationship cardinality
|
-- | The relationship cardinality
|
||||||
-- | https://en.wikipedia.org/wiki/Cardinality_(data_modeling)
|
-- | https://en.wikipedia.org/wiki/Cardinality_(data_modeling)
|
||||||
@@ -47,7 +47,7 @@ data Cardinality
|
|||||||
-- ^ one-to-one, this is a refinement over M2O so operating on it is pretty much the same as M2O
|
-- ^ one-to-one, this is a refinement over M2O so operating on it is pretty much the same as M2O
|
||||||
| M2M Junction
|
| M2M Junction
|
||||||
-- ^ many-to-many
|
-- ^ many-to-many
|
||||||
deriving (Eq, Ord, Generic, JSON.ToJSON)
|
deriving (Eq, Show, Ord, Generic, JSON.ToJSON)
|
||||||
|
|
||||||
type FKConstraint = Text
|
type FKConstraint = Text
|
||||||
|
|
||||||
@@ -59,7 +59,7 @@ data Junction = Junction
|
|||||||
, junColsSource :: [(FieldName, FieldName)]
|
, junColsSource :: [(FieldName, FieldName)]
|
||||||
, junColsTarget :: [(FieldName, FieldName)]
|
, junColsTarget :: [(FieldName, FieldName)]
|
||||||
}
|
}
|
||||||
deriving (Eq, Ord, Generic, JSON.ToJSON)
|
deriving (Eq, Show, Ord, Generic, JSON.ToJSON)
|
||||||
|
|
||||||
-- | Key based on the source table and the foreign table schema
|
-- | Key based on the source table and the foreign table schema
|
||||||
type RelationshipsMap = HM.HashMap (QualifiedIdentifier, Schema) [Relationship]
|
type RelationshipsMap = HM.HashMap (QualifiedIdentifier, Schema) [Relationship]
|
||||||
|
|||||||
Reference in New Issue
Block a user