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
, UntypedProjection, untypedProjectionWidth, ProjectionUnit (..)
, Projection, untypeProjection, typedProjection, projectionWidth, projectFromColumns
, Projection, untypeProjection, typedProjection, projectionWidth
, projectFromColumns, projectFromScalarSubQuery
-- * Query restriction
, QueryRestriction
@ -138,6 +139,10 @@ projectFromColumns :: [ColumnSQL] -- ^ SQL string list specifies columns
-> Projection c r -- ^ Result 'Projection'
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 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 Database.Relational.Query.Sub
(projectionColumns,
untypedProjectionFromJoinedSubQuery, untypedProjectionFromScalarSubQuery,
untypedProjectionFromJoinedSubQuery,
unsafeProjectionStringSql)
import qualified Database.Relational.Query.Sub as SubQuery
@ -90,7 +90,7 @@ unsafeFromQualifiedSubQuery = typedProjection . untypedProjectionFromJoinedSubQ
-- | Unsafely generate 'Projection' from scalar sub-query.
unsafeFromScalarSubQuery :: SubQuery -> Projection c t
unsafeFromScalarSubQuery = typedProjection . untypedProjectionFromScalarSubQuery
unsafeFromScalarSubQuery = Internal.projectFromScalarSubQuery
-- | Unsafely generate unqualified 'Projection' from 'Table'.
unsafeFromTable :: Table r

View File

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