mirror of
https://github.com/khibino/haskell-relational-record.git
synced 2024-12-15 06:43:04 +03:00
Use of string utility functions.
This commit is contained in:
parent
a56d0c4e52
commit
e70a84a3d5
@ -35,6 +35,7 @@ import qualified Data.Text as T
|
||||
|
||||
import Database.Relational.Query.Expr.Unsafe (Expr(Expr), showExpr)
|
||||
|
||||
import Database.Relational.Query.Internal.String (paren)
|
||||
import qualified Language.SQL.Keyword as SQL
|
||||
import qualified Language.SQL.Keyword.ConcatString as SQLs
|
||||
|
||||
@ -120,4 +121,4 @@ fromJust = unsafeCastExpr
|
||||
|
||||
-- | AND operator for 'Expr'.
|
||||
exprAnd :: Expr p Bool -> Expr p Bool -> Expr p Bool
|
||||
exprAnd a b = Expr $ '(' : SQLs.defineBinOp SQL.AND (showExpr a) (showExpr b) ++ [')']
|
||||
exprAnd a b = Expr . paren $ SQLs.defineBinOp SQL.AND (showExpr a) (showExpr b)
|
||||
|
@ -63,7 +63,7 @@ import Database.Relational.Query.Table
|
||||
import qualified Database.Relational.Query.Table as Table
|
||||
|
||||
import Database.Relational.Query.Internal.String
|
||||
(showUnwordsSQL, showWordSQL, showUnwords)
|
||||
(showUnwordsSQL, showWordSQL, showUnwords, paren)
|
||||
import Language.SQL.Keyword (Keyword(..), unwordsSQL)
|
||||
import qualified Language.SQL.Keyword as SQL
|
||||
import qualified Language.SQL.Keyword.ConcatString as SQLs
|
||||
@ -146,8 +146,8 @@ toSQLs :: SubQuery
|
||||
-> (String, String) -- ^ subquery SQL and top-level SQL
|
||||
toSQLs = d where
|
||||
d (Table u) = (Table.name' u, fromTableToSql u)
|
||||
d (SubQuery { sql' = q }) = ('(' : q ++ [')'], q)
|
||||
d (Bin op l r) = ('(' : q ++ [')'], q) where
|
||||
d (SubQuery { sql' = q }) = (paren q, q)
|
||||
d (Bin op l r) = (paren q, q) where
|
||||
q = unwords [unitSQL l, SQL.wordShow $ keywordBinOp op, unitSQL r]
|
||||
|
||||
-- | SQL string for nested-qeury.
|
||||
|
Loading…
Reference in New Issue
Block a user