Merge AliasId s into Qualify module.

This commit is contained in:
Kei Hibino 2013-06-05 17:55:53 +09:00
parent 18ad78fef2
commit 21cc22f86c
7 changed files with 17 additions and 45 deletions

View File

@ -16,7 +16,6 @@ cabal-version: >=1.8
library
exposed-modules:
Database.Relational.Query
Database.Relational.Query.AliasId
Database.Relational.Query.Table
Database.Relational.Query.SQL
Database.Relational.Query.Pi

View File

@ -4,13 +4,13 @@ module Database.Relational.Query (
module Database.Relational.Query.SQL,
module Database.Relational.Query.Pi,
module Database.Relational.Query.Constraint,
module Database.Relational.Query.AliasId,
module Database.Relational.Query.Expr,
module Database.Relational.Query.Sub,
module Database.Relational.Query.Projection,
module Database.Relational.Query.Aggregation,
module Database.Relational.Query.Projectable,
module Database.Relational.Query.ProjectableExtended,
module Database.Relational.Query.Monad.Qualify,
module Database.Relational.Query.Monad.Class,
module Database.Relational.Query.Monad.Trans.Ordering,
module Database.Relational.Query.Monad.Core,
@ -28,13 +28,13 @@ import Database.Relational.Query.Constraint
(Key, tableConstraint, projectionKey,
uniqueKey, notNullKey, HasConstraintKey(constraintKey),
Primary, Unique, NotNull)
import Database.Relational.Query.AliasId (Qualified)
import Database.Relational.Query.Expr hiding (flattenMaybe, just)
import Database.Relational.Query.Sub (SubQuery, unitSQL, queryWidth)
import Database.Relational.Query.Projection (Projection)
import Database.Relational.Query.Aggregation (Aggregation)
import Database.Relational.Query.Projectable
import Database.Relational.Query.ProjectableExtended
import Database.Relational.Query.Monad.Qualify (Qualified)
import Database.Relational.Query.Monad.Class (on, wheres, groupBy, having)
import Database.Relational.Query.Monad.Trans.Ordering (asc, desc)
import Database.Relational.Query.Monad.Core (QueryCore, expr)

View File

@ -1,15 +0,0 @@
-- |
-- Module : Database.Relational.Query.AliasId
-- Copyright : 2013 Kei Hibino
-- License : BSD3
--
-- Maintainer : ex8k.hibino@gmail.com
-- Stability : experimental
-- Portability : unknown
--
-- This module defines qualifier for SQL table form.
module Database.Relational.Query.AliasId (
Qualified
) where
import Database.Relational.Query.Internal.AliasId (Qualified)

View File

@ -1,14 +1,9 @@
{-# LANGUAGE OverloadedStrings #-}
module Database.Relational.Query.Internal.Context (
AliasIdContext,
primeAliasIdContext,
Context,
primeContext,
nextAlias,
updateProduct, takeProduct, restoreLeft,
addRestriction,
@ -31,10 +26,9 @@ import qualified Data.DList as DList
import Data.Monoid ((<>))
import Control.Applicative (pure)
import Database.Relational.Query.Internal.AliasId (primAlias, AliasId, newAliasId, asColumnN)
import Database.Relational.Query.Expr (Expr, showExpr, fromTriBool, exprAnd)
import Database.Relational.Query.Internal.AliasId (asColumnN)
import Database.Relational.Query.Internal.Product (QueryProductNode, QueryProduct, queryProductSQL)
import qualified Database.Relational.Query.Internal.Product as Product
@ -47,11 +41,6 @@ import qualified Language.SQL.Keyword as SQL
-- Base contexts
newtype AliasIdContext = AliasIdContext { currentAliasId :: AliasId }
primeAliasIdContext :: AliasIdContext
primeAliasIdContext = AliasIdContext primAlias
data Context = Context
{ product :: Maybe QueryProductNode
, restriction :: Maybe (Expr Bool)
@ -60,10 +49,6 @@ data Context = Context
primeContext :: Context
primeContext = Context Nothing Nothing
nextAlias :: AliasIdContext -> (AliasId, AliasIdContext)
nextAlias s = (cur, s { currentAliasId = newAliasId cur }) where
cur = currentAliasId s
updateProduct' :: (Maybe QueryProductNode -> Maybe QueryProductNode) -> Context -> Context
updateProduct' uf ctx = ctx { product = uf . product $ ctx }

View File

@ -9,7 +9,7 @@ module Database.Relational.Query.Internal.Product (
import Prelude hiding (and, product)
import Database.Relational.Query.Expr (Expr, showExpr, fromTriBool, exprAnd)
import Database.Relational.Query.Projectable (valueTrue)
import Database.Relational.Query.AliasId (Qualified)
import Database.Relational.Query.Monad.Qualify (Qualified)
import Database.Relational.Query.Sub (SubQuery)
import qualified Database.Relational.Query.Sub as SubQuery

View File

@ -1,7 +1,7 @@
{-# LANGUAGE MultiParamTypeClasses #-}
module Database.Relational.Query.Monad.Qualify (
Qualify, evalQualifyPrime, newAlias, qualifyQuery
Qualified, Qualify, evalQualifyPrime, newAlias, qualifyQuery
) where
import Control.Monad (liftM, ap)
@ -9,10 +9,18 @@ import Control.Monad.Trans.State
(State, state, runState)
import Control.Applicative (Applicative (pure, (<*>)))
import Database.Relational.Query.Internal.AliasId (AliasId, Qualified)
import Database.Relational.Query.Internal.AliasId (primAlias, AliasId, newAliasId, Qualified)
import qualified Database.Relational.Query.Internal.AliasId as AliasId
import Database.Relational.Query.Internal.Context
(AliasIdContext, primeAliasIdContext, nextAlias)
newtype AliasIdContext = AliasIdContext { currentAliasId :: AliasId }
primeAliasIdContext :: AliasIdContext
primeAliasIdContext = AliasIdContext primAlias
nextAlias :: AliasIdContext -> (AliasId, AliasIdContext)
nextAlias s = (cur, s { currentAliasId = newAliasId cur }) where
cur = currentAliasId s
newtype Qualify a =
@ -48,8 +56,3 @@ qualifyQuery :: query -> Qualify (Qualified query)
qualifyQuery query =
do n <- newAlias
return $ AliasId.qualify query n
-- qualifyQuery :: Qualify query -> Qualify (Qualified query)
-- qualifyQuery qualSub = do
-- sub <- qualSub
-- qualifyQuery' sub

View File

@ -37,7 +37,7 @@ import Database.Record.Persistable (runPersistableRecordWidth)
import Database.Relational.Query.Pi (Pi)
import qualified Database.Relational.Query.Pi as Pi
import Database.Relational.Query.AliasId (Qualified)
import Database.Relational.Query.Monad.Qualify (Qualified)
import Database.Relational.Query.Sub (SubQuery, queryWidth)
import qualified Database.Relational.Query.Sub as SubQuery