mirror of
https://github.com/khibino/haskell-relational-record.git
synced 2024-12-15 14:53:28 +03:00
Prepare to change wrapped type.
This commit is contained in:
parent
0fb3a53b0c
commit
ae91f3e804
@ -70,6 +70,19 @@ import qualified Language.SQL.Keyword.ConcatString as SQLs
|
|||||||
|
|
||||||
-- | Uni-term raw SQL
|
-- | Uni-term raw SQL
|
||||||
type UniTermSQL = String
|
type UniTermSQL = String
|
||||||
|
-- newtype UniTermSQL = UniTermSQL String
|
||||||
|
|
||||||
|
uniTermSQL :: String -> UniTermSQL
|
||||||
|
uniTermSQL = id
|
||||||
|
-- uniTermSQL = UniTermSQL
|
||||||
|
|
||||||
|
stringFromUniTermSQL :: UniTermSQL -> String
|
||||||
|
stringFromUniTermSQL = id
|
||||||
|
-- stringFromUniTermSQL (UniTermSQL s) = s
|
||||||
|
|
||||||
|
wordSqlFromUniTerm :: UniTermSQL -> SQL.Keyword
|
||||||
|
wordSqlFromUniTerm = SQL.word . stringFromUniTermSQL
|
||||||
|
|
||||||
|
|
||||||
data BinOp = Union | Except | Intersect
|
data BinOp = Union | Except | Intersect
|
||||||
|
|
||||||
@ -184,11 +197,11 @@ qualify = Qualified
|
|||||||
|
|
||||||
-- | Column name of projection index.
|
-- | Column name of projection index.
|
||||||
columnN :: Int -> UniTermSQL
|
columnN :: Int -> UniTermSQL
|
||||||
columnN i = 'f' : show i
|
columnN i = uniTermSQL $ 'f' : show i
|
||||||
|
|
||||||
-- | Renamed column in SQL expression.
|
-- | Renamed column in SQL expression.
|
||||||
asColumnN :: SQL.Keyword -> Int -> SQL.Keyword
|
asColumnN :: SQL.Keyword -> Int -> SQL.Keyword
|
||||||
f `asColumnN` n = f `SQL.as` SQL.word (columnN n)
|
f `asColumnN` n = f `SQL.as` wordSqlFromUniTerm (columnN n)
|
||||||
|
|
||||||
-- | Alias string from qualifier
|
-- | Alias string from qualifier
|
||||||
showQualifier :: Qualifier -> String
|
showQualifier :: Qualifier -> String
|
||||||
@ -196,7 +209,7 @@ showQualifier (Qualifier i) = 'T' : show i
|
|||||||
|
|
||||||
-- | Binary operator to qualify.
|
-- | Binary operator to qualify.
|
||||||
(<.>) :: Qualifier -> UniTermSQL -> UniTermSQL
|
(<.>) :: Qualifier -> UniTermSQL -> UniTermSQL
|
||||||
i <.> n = showQualifier i ++ '.' : n
|
i <.> n = uniTermSQL $ showQualifier i ++ '.' : stringFromUniTermSQL n
|
||||||
|
|
||||||
-- | Qualified expression from qualifier and projection index.
|
-- | Qualified expression from qualifier and projection index.
|
||||||
columnFromId :: Qualifier -> Int -> UniTermSQL
|
columnFromId :: Qualifier -> Int -> UniTermSQL
|
||||||
@ -217,7 +230,7 @@ queryWidth = width . unQualify
|
|||||||
column :: Qualified SubQuery -> Int -> UniTermSQL
|
column :: Qualified SubQuery -> Int -> UniTermSQL
|
||||||
column qs = d (unQualify qs) where
|
column qs = d (unQualify qs) where
|
||||||
q = qualifier qs
|
q = qualifier qs
|
||||||
d (Table u) i = (q <.> (u ! i))
|
d (Table u) i = (q <.> uniTermSQL (u ! i))
|
||||||
d (SubQuery _ _) i = (q `columnFromId` i)
|
d (SubQuery _ _) i = (q `columnFromId` i)
|
||||||
d (Bin _ _ _) i = (q `columnFromId` i)
|
d (Bin _ _ _) i = (q `columnFromId` i)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user