mirror of
https://github.com/khibino/haskell-relational-record.git
synced 2024-12-02 08:12:49 +03:00
relational-query: move base SQL structure definitions to internal space.
This commit is contained in:
parent
66e86ccbb5
commit
8b60b56507
@ -68,6 +68,7 @@ library
|
||||
Database.Relational.Query.Internal.Config
|
||||
Database.Relational.Query.Internal.ContextType
|
||||
Database.Relational.Query.Internal.SQL
|
||||
Database.Relational.Query.Internal.BaseSQL
|
||||
Database.Relational.Query.Internal.UntypedTable
|
||||
Database.Relational.Query.Internal.Product
|
||||
Database.Relational.Query.Internal.Sub
|
||||
|
@ -21,7 +21,10 @@ module Database.Relational.Query.Component
|
||||
module Database.Relational.Query.Internal.Config,
|
||||
|
||||
-- * Duplication attribute
|
||||
Duplication (..), showsDuplication,
|
||||
-- re-export
|
||||
Duplication (..),
|
||||
|
||||
showsDuplication,
|
||||
|
||||
-- * Types for aggregation
|
||||
AggregateColumnRef,
|
||||
@ -37,14 +40,21 @@ module Database.Relational.Query.Component
|
||||
AggregateKey, aggregateKeyProjection, aggregateKeyElement, unsafeAggregateKey,
|
||||
|
||||
-- * Types for ordering
|
||||
-- re-export
|
||||
Order (..), OrderColumn, OrderingTerm,
|
||||
|
||||
composeOrderBy,
|
||||
|
||||
-- deprecated interfaces
|
||||
OrderingTerms,
|
||||
|
||||
-- * Types for assignments
|
||||
AssignColumn, AssignTerm, Assignment, Assignments, composeSets, composeValues,
|
||||
-- re-export
|
||||
AssignColumn, AssignTerm, Assignment,
|
||||
|
||||
Assignments,
|
||||
|
||||
composeSets, composeValues,
|
||||
|
||||
-- * Compose window clause
|
||||
composeOver,
|
||||
@ -61,6 +71,10 @@ import Database.Relational.Query.Internal.Config
|
||||
Config (..), defaultConfig,)
|
||||
import Database.Relational.Query.Internal.SQL (StringSQL, rowConsStringSQL)
|
||||
import qualified Database.Relational.Query.Internal.SQL as Internal
|
||||
import Database.Relational.Query.Internal.BaseSQL
|
||||
(Duplication (..),
|
||||
Order (..), OrderColumn, OrderingTerm,
|
||||
AssignColumn, AssignTerm, Assignment,)
|
||||
|
||||
|
||||
{-# DEPRECATED ColumnSQL, columnSQL, columnSQL', showsColumnSQL "prepare to drop public interface. internally use Database.Relational.Query.Internal.SQL.*" #-}
|
||||
@ -80,9 +94,6 @@ showsColumnSQL :: ColumnSQL -> StringSQL
|
||||
showsColumnSQL = Internal.showsColumnSQL
|
||||
|
||||
|
||||
-- | Result record duplication attribute
|
||||
data Duplication = All | Distinct deriving Show
|
||||
|
||||
-- | Compose duplication attribute string.
|
||||
showsDuplication :: Duplication -> StringSQL
|
||||
showsDuplication = dup where
|
||||
@ -181,21 +192,12 @@ unsafeAggregateKey :: (a, AggregateElem) -> AggregateKey a
|
||||
unsafeAggregateKey = AggregateKey
|
||||
|
||||
|
||||
-- | Order direction. Ascendant or Descendant.
|
||||
data Order = Asc | Desc deriving Show
|
||||
|
||||
-- | Type for order-by column
|
||||
type OrderColumn = ColumnSQL
|
||||
|
||||
-- | Type for order-by term
|
||||
type OrderingTerm = (Order, OrderColumn)
|
||||
|
||||
{-# DEPRECATED OrderingTerms "use [OrderingTerm]." #-}
|
||||
-- | Type for order-by terms
|
||||
type OrderingTerms = [OrderingTerm]
|
||||
|
||||
-- | Compose ORDER BY clause from OrderingTerms
|
||||
composeOrderBy :: OrderingTerms -> StringSQL
|
||||
composeOrderBy :: [OrderingTerm] -> StringSQL
|
||||
composeOrderBy = d where
|
||||
d [] = mempty
|
||||
d ts@(_:_) = ORDER <> BY <> commaed (map showsOt ts)
|
||||
@ -204,15 +206,6 @@ composeOrderBy = d where
|
||||
order Desc = DESC
|
||||
|
||||
|
||||
-- | Column SQL String
|
||||
type AssignColumn = ColumnSQL
|
||||
|
||||
-- | Value SQL String
|
||||
type AssignTerm = ColumnSQL
|
||||
|
||||
-- | Assignment pair
|
||||
type Assignment = (AssignColumn, AssignTerm)
|
||||
|
||||
-- | Assignment pair list.
|
||||
type Assignments = [Assignment]
|
||||
|
||||
|
@ -0,0 +1,39 @@
|
||||
-- |
|
||||
-- Module : Database.Relational.Query.Internal.BaseSQL
|
||||
-- Copyright : 2013-2017 Kei Hibino
|
||||
-- License : BSD3
|
||||
--
|
||||
-- Maintainer : ex8k.hibino@gmail.com
|
||||
-- Stability : experimental
|
||||
-- Portability : unknown
|
||||
--
|
||||
-- This module provides base structure of SQL syntax tree.
|
||||
module Database.Relational.Query.Internal.BaseSQL (
|
||||
Duplication (..),
|
||||
Order (..), OrderColumn, OrderingTerm,
|
||||
AssignColumn, AssignTerm, Assignment,
|
||||
) where
|
||||
|
||||
import Database.Relational.Query.Internal.SQL (ColumnSQL)
|
||||
|
||||
|
||||
-- | Result record duplication attribute
|
||||
data Duplication = All | Distinct deriving Show
|
||||
|
||||
-- | Order direction. Ascendant or Descendant.
|
||||
data Order = Asc | Desc deriving Show
|
||||
|
||||
-- | Type for order-by column
|
||||
type OrderColumn = ColumnSQL
|
||||
|
||||
-- | Type for order-by term
|
||||
type OrderingTerm = (Order, OrderColumn)
|
||||
|
||||
-- | Column SQL String of assignment
|
||||
type AssignColumn = ColumnSQL
|
||||
|
||||
-- | Value SQL String of assignment
|
||||
type AssignTerm = ColumnSQL
|
||||
|
||||
-- | Assignment pair
|
||||
type Assignment = (AssignColumn, AssignTerm)
|
Loading…
Reference in New Issue
Block a user