mirror of
https://github.com/khibino/haskell-relational-record.git
synced 2024-12-12 12:09:08 +03:00
Move default definitions of column selector.
This commit is contained in:
parent
0ea4d7edb9
commit
7824af3a78
@ -60,24 +60,26 @@ defineTable tableVar' relVar' recordType table columns = do
|
||||
let tableVar = varName tableVar'
|
||||
tableDs <- simpleValD tableVar [t| Table $(recordType) |]
|
||||
[| Table.table $(stringE table) $(listE $ map stringE (map fst columns)) |]
|
||||
let defCol i (name, typ) = defineColumnDefault recordType name i typ
|
||||
colsDs <- fmap concat . sequence . zipWith defCol [0..] $ columns
|
||||
let relVar = varName relVar'
|
||||
relDs <- simpleValD relVar [t| Relation $(recordType) |]
|
||||
[| fromTable $(varE tableVar) |]
|
||||
return $ tableDs ++ colsDs ++ relDs
|
||||
return $ tableDs ++ relDs
|
||||
|
||||
defineTableDefault :: String -- ^ Schema name
|
||||
-> String -- ^ Table name
|
||||
-> [(String, TypeQ)] -- ^ Column names and types
|
||||
-> Q [Dec] -- ^ Result declarations
|
||||
defineTableDefault schema table columns =
|
||||
defineTable
|
||||
(table `varNameWithPrefix` "tableOf")
|
||||
(varCamelcaseName table)
|
||||
(recordTypeDefault table)
|
||||
(tableSQL schema table)
|
||||
columns
|
||||
defineTableDefault schema table columns = do
|
||||
let recordType = recordTypeDefault table
|
||||
tableDs <- defineTable
|
||||
(table `varNameWithPrefix` "tableOf")
|
||||
(varCamelcaseName table)
|
||||
recordType
|
||||
(tableSQL schema table)
|
||||
columns
|
||||
let defCol i (name, typ) = defineColumnDefault recordType name i typ
|
||||
colsDs <- fmap concat . sequence . zipWith defCol [0..] $ columns
|
||||
return $ tableDs ++ colsDs
|
||||
|
||||
defineRecordAndTableDefault :: TypeQ -- ^ SQL value type
|
||||
-> String -- ^ Schema name
|
||||
|
Loading…
Reference in New Issue
Block a user