unsafeShowSql definitions of projection type specified version.

This commit is contained in:
Kei Hibino 2013-07-30 23:58:44 +09:00
parent 4fcb52d26b
commit 21ddfe5524

View File

@ -27,6 +27,9 @@ module Database.Relational.Query.Projectable (
placeholder', placeholder, placeholder', placeholder,
-- * Projectable into SQL strings -- * Projectable into SQL strings
unsafeShowSqlExpr,
unsafeShowSqlProjection,
unsafeShowSqlAggregation,
ProjectableShowSql (unsafeShowSql), ProjectableShowSql (unsafeShowSql),
-- * Binary Operators -- * Binary Operators
@ -82,12 +85,12 @@ sqlTermsString = d where
d (cs) = paren $ intercalate ", " cs d (cs) = paren $ intercalate ", " cs
-- | SQL expression strings which represent projection. -- | SQL expression strings which represent projection.
sqlString :: Projection r -> String sqlStringOfProjection :: Projection r -> String
sqlString = sqlTermsString . columns sqlStringOfProjection = sqlTermsString . columns
-- | 'Expr' from 'Projection' -- | 'Expr' from 'Projection'
exprOfProjection :: Projection r -> Expr Projection r exprOfProjection :: Projection r -> Expr Projection r
exprOfProjection = UnsafeExpr.Expr . sqlString exprOfProjection = UnsafeExpr.Expr . sqlStringOfProjection
-- | Projection interface into expression. -- | Projection interface into expression.
class ExpressionProjectable p where class ExpressionProjectable p where
@ -98,7 +101,7 @@ instance ExpressionProjectable Projection where
expr = exprOfProjection expr = exprOfProjection
instance ExpressionProjectable Aggregation where instance ExpressionProjectable Aggregation where
expr = UnsafeExpr.Expr . sqlString . Aggregation.unsafeProjection expr = UnsafeExpr.Expr . sqlStringOfProjection . Aggregation.unsafeProjection
-- | Projection interface. -- | Projection interface.
class ProjectablePi p where class ProjectablePi p where
@ -174,17 +177,29 @@ class ProjectableShowSql p where
unsafeShowSql :: p a -- ^ Source projection object unsafeShowSql :: p a -- ^ Source projection object
-> String -- ^ Result SQL expression string. -> String -- ^ Result SQL expression string.
-- | Unsafely get SQL term from 'Proejction'. -- | Unsafely get SQL term from 'Expr'.
instance ProjectableShowSql Projection where unsafeShowSqlExpr :: Expr p t -> String
unsafeShowSql = sqlString unsafeShowSqlExpr = UnsafeExpr.showExpr
-- | Unsafely get SQL term from 'Expr'. -- | Unsafely get SQL term from 'Expr'.
instance ProjectableShowSql (Expr p) where instance ProjectableShowSql (Expr p) where
unsafeShowSql = UnsafeExpr.showExpr unsafeShowSql = unsafeShowSqlExpr
-- | Unsafely get SQL term from 'Aggregation.unsafeFromProjection'. -- | Unsafely get SQL term from 'Proejction'.
unsafeShowSqlProjection :: Projection r -> String
unsafeShowSqlProjection = sqlStringOfProjection
-- | Unsafely get SQL term from 'Proejction'.
instance ProjectableShowSql Projection where
unsafeShowSql = unsafeShowSqlProjection
-- | Unsafely get SQL term from 'Aggregation'.
unsafeShowSqlAggregation :: Aggregation a -> String
unsafeShowSqlAggregation = unsafeShowSql . Aggregation.unsafeProjection
-- | Unsafely get SQL term from 'Aggregation'.
instance ProjectableShowSql Aggregation where instance ProjectableShowSql Aggregation where
unsafeShowSql = unsafeShowSql . Aggregation.unsafeProjection unsafeShowSql = unsafeShowSqlAggregation
-- | Binary operator type for SQL String. -- | Binary operator type for SQL String.