Safe Haskell | None |
---|---|
Language | GHC2024 |
Synopsis
- combineTablesLeft :: DefinedRelation -> [(DefinedRelation, Ref Relation -> Ref Relation -> SExp)] -> Q ()
- columnsToRows :: DefinedRelation -> [Text] -> Query
- unionTables :: [DefinedRelation] -> Query
- unionWithSchema :: forall {k} (bk :: k). HasBackendSchemaField bk => [(Relation, [BackendSchemaField bk])] -> Query
- unifySchemas :: forall {k} (bk :: k). HasBackendSchemaField bk => [(Relation, [BackendSchemaField bk])] -> [Query]
- filterFields :: forall {k} (t :: k). (Ref t -> Bool) -> Query -> Query
- whitelistFields :: forall {k} t1 (t :: k). Foldable t1 => t1 Regex -> Ref t -> Bool
- longToWideFormat :: (SExp -> SExp) -> [Alias SExp] -> [(SExp, SExp, Ref SExp)] -> Query -> Query
- longToWideFormatSimple :: (SExp -> SExp) -> [Alias SExp] -> [(SExp, SExp)] -> Ref SExp -> SExp -> Query -> Query
- simpleValueAsColumnName :: Text -> Value -> Ref SExp
- splitUnions :: Foldable t => Int -> t Query -> [Query]
Documentation
:: DefinedRelation | |
-> [(DefinedRelation, Ref Relation -> Ref Relation -> SExp)] | Table definitions and primary keys each shares with the first table in list |
-> Q () |
Combine multiple tables/queries that were defined in napkin that share a common set of primary keys via a chain of left joins.
:: DefinedRelation | |
-> [Text] | Groups, keep these intact on each row |
-> Query |
Transforms columns into separate rows, per given partition
unionTables :: [DefinedRelation] -> Query #
Combine all tables into one assuming if the field names are the same, their types will just work out. Fill missing columns with NULL on a per-table basis.
unionWithSchema :: forall {k} (bk :: k). HasBackendSchemaField bk => [(Relation, [BackendSchemaField bk])] -> Query #
Unify schemas and join given relations under a single UNION query.
unifySchemas :: forall {k} (bk :: k). HasBackendSchemaField bk => [(Relation, [BackendSchemaField bk])] -> [Query] #
Given relations' and their known schema, whether it's a Query
or a table reference, union them in a way that works out the
missing columns in each and even unifies mismatching types to a
common denominator.
filterFields :: forall {k} (t :: k). (Ref t -> Bool) -> Query -> Query #
Only keep selected fields in Query that pass the predicate.
whitelistFields :: forall {k} t1 (t :: k). Foldable t1 => t1 Regex -> Ref t -> Bool #
Keep any field that matches any of the given regexes. Can use
this to construct the predicate in filterFields
longToWideFormat :: (SExp -> SExp) -> [Alias SExp] -> [(SExp, SExp, Ref SExp)] -> Query -> Query #
Convert a "long" query to "wide" by aggregating/matching over certain SExps.
longToWideFormatSimple :: (SExp -> SExp) -> [Alias SExp] -> [(SExp, SExp)] -> Ref SExp -> SExp -> Query -> Query #
A long-to-wide query transformer which matches using equality
simpleValueAsColumnName :: Text -> Value -> Ref SExp #
A basic means of generating new column names from
splitUnions :: Foldable t => Int -> t Query -> [Query] #
Given a list of queries that may contain any number of top level UNIONs, chunk them into queries where each contains at most N unions.
Useful for reducing/capping the size of each top level query so they can be sent individually to the database.