relational-query: simplify module dependency. projecting interface.

This commit is contained in:
Kei Hibino 2017-02-13 13:16:06 +09:00
parent d044616d82
commit c005b9a98a
3 changed files with 11 additions and 5 deletions

View File

@ -21,7 +21,8 @@ module Database.Relational.Query.Internal.Sub
, ProductTreeBuilder, ProductBuilder , ProductTreeBuilder, ProductBuilder
, UntypedProjection, untypedProjectionWidth, ProjectionUnit (..) , UntypedProjection, untypedProjectionWidth, ProjectionUnit (..)
, Projection, untypeProjection, typedProjection, projectionWidth, projectFromColumns , Projection, untypeProjection, typedProjection, projectionWidth
, projectFromColumns, projectFromScalarSubQuery
-- * Query restriction -- * Query restriction
, QueryRestriction , QueryRestriction
@ -138,6 +139,10 @@ projectFromColumns :: [ColumnSQL] -- ^ SQL string list specifies columns
-> Projection c r -- ^ Result 'Projection' -> Projection c r -- ^ Result 'Projection'
projectFromColumns = typedProjection . map RawColumn projectFromColumns = typedProjection . map RawColumn
-- | Unsafely generate 'Projection' from scalar sub-query.
projectFromScalarSubQuery :: SubQuery -> Projection c t
projectFromScalarSubQuery = typedProjection . (:[]) . Scalar
-- | Type for restriction of query. -- | Type for restriction of query.
type QueryRestriction c = [Projection c (Maybe Bool)] type QueryRestriction c = [Projection c (Maybe Bool)]

View File

@ -61,7 +61,7 @@ import Database.Relational.Query.Pi (Pi)
import qualified Database.Relational.Query.Pi.Unsafe as UnsafePi import qualified Database.Relational.Query.Pi.Unsafe as UnsafePi
import Database.Relational.Query.Sub import Database.Relational.Query.Sub
(projectionColumns, (projectionColumns,
untypedProjectionFromJoinedSubQuery, untypedProjectionFromScalarSubQuery, untypedProjectionFromJoinedSubQuery,
unsafeProjectionStringSql) unsafeProjectionStringSql)
import qualified Database.Relational.Query.Sub as SubQuery import qualified Database.Relational.Query.Sub as SubQuery
@ -90,7 +90,7 @@ unsafeFromQualifiedSubQuery = typedProjection . untypedProjectionFromJoinedSubQ
-- | Unsafely generate 'Projection' from scalar sub-query. -- | Unsafely generate 'Projection' from scalar sub-query.
unsafeFromScalarSubQuery :: SubQuery -> Projection c t unsafeFromScalarSubQuery :: SubQuery -> Projection c t
unsafeFromScalarSubQuery = typedProjection . untypedProjectionFromScalarSubQuery unsafeFromScalarSubQuery = Internal.projectFromScalarSubQuery
-- | Unsafely generate unqualified 'Projection' from 'Table'. -- | Unsafely generate unqualified 'Projection' from 'Table'.
unsafeFromTable :: Table r unsafeFromTable :: Table r

View File

@ -30,12 +30,12 @@ module Database.Relational.Query.Sub (
-- * Projection -- * Projection
Projection, ProjectionUnit, UntypedProjection, Projection, ProjectionUnit, UntypedProjection,
untypedProjectionFromJoinedSubQuery, untypedProjectionFromScalarSubQuery, untypedProjectionFromJoinedSubQuery,
projectionColumns, unsafeProjectionStringSql, projectionColumns, unsafeProjectionStringSql,
-- deprecated interfaces -- deprecated interfaces
untypedProjectionFromColumns, untypedProjectionFromColumns, untypedProjectionFromScalarSubQuery,
unsafeProjectFromColumns, unsafeProjectFromColumns,
widthOfUntypedProjection, columnsOfUntypedProjection, widthOfUntypedProjection, columnsOfUntypedProjection,
@ -256,6 +256,7 @@ column qs = d (Internal.unQualify qs) where
untypedProjectionFromColumns :: [ColumnSQL] -> UntypedProjection untypedProjectionFromColumns :: [ColumnSQL] -> UntypedProjection
untypedProjectionFromColumns = map RawColumn untypedProjectionFromColumns = map RawColumn
{-# DEPRECATED untypedProjectionFromScalarSubQuery "prepare to drop public interface. use ( (:[]) . Scalar )." #-}
-- | Make untyped projection from scalar sub-query. -- | Make untyped projection from scalar sub-query.
untypedProjectionFromScalarSubQuery :: SubQuery -> UntypedProjection untypedProjectionFromScalarSubQuery :: SubQuery -> UntypedProjection
untypedProjectionFromScalarSubQuery = (:[]) . Scalar untypedProjectionFromScalarSubQuery = (:[]) . Scalar