mirror of
https://github.com/khibino/haskell-relational-record.git
synced 2024-12-12 12:09:08 +03:00
Rename functions which expand relation into SQL string.
This commit is contained in:
parent
04c0848370
commit
9a3e990459
@ -15,9 +15,9 @@ module Database.Relational.Query.Join (
|
||||
inner', left', right', full',
|
||||
inner, left, right, full,
|
||||
|
||||
toSQL,
|
||||
sqlFromRelation,
|
||||
|
||||
toSubQuery,
|
||||
subQueryFromRelation,
|
||||
|
||||
nested, width
|
||||
) where
|
||||
@ -250,22 +250,22 @@ full = join queryMaybe queryMaybe
|
||||
|
||||
infix 8 `inner'`, `left'`, `right'`, `full'`, `inner`, `left`, `right`, `full`
|
||||
|
||||
toSQL :: PrimeRelation p r -> String
|
||||
toSQL = d where
|
||||
sqlFromRelation :: PrimeRelation p r -> String
|
||||
sqlFromRelation = d where
|
||||
d (SubQuery sub) = SubQuery.toSQL sub
|
||||
d (PrimeRelation qp) = uncurry composeSQL (runQueryPrime qp)
|
||||
|
||||
instance Show (PrimeRelation p r) where
|
||||
show = toSQL
|
||||
show = sqlFromRelation
|
||||
|
||||
toSubQuery :: PrimeRelation p r -> SubQuery
|
||||
toSubQuery = d where
|
||||
subQueryFromRelation :: PrimeRelation p r -> SubQuery
|
||||
subQueryFromRelation = d where
|
||||
d (SubQuery sub) = sub
|
||||
d (PrimeRelation qp) = SubQuery.subQuery (composeSQL pj c) (Projection.width pj) where
|
||||
(pj, c) = runQueryPrime qp
|
||||
|
||||
width :: PrimeRelation p r -> Int
|
||||
width = SubQuery.width . toSubQuery
|
||||
width = SubQuery.width . subQueryFromRelation
|
||||
|
||||
nested :: PrimeRelation p r -> PrimeRelation p r
|
||||
nested = SubQuery . toSubQuery
|
||||
nested = SubQuery . subQueryFromRelation
|
||||
|
@ -49,7 +49,7 @@ import Database.Record.TH
|
||||
|
||||
import Database.Relational.Query
|
||||
(Table, Pi, Relation, PrimeRelation,
|
||||
toSQL, Query, fromRelation, Update, Insert, typedInsert,
|
||||
sqlFromRelation, Query, fromRelation, Update, Insert, typedInsert,
|
||||
HasConstraintKey(constraintKey), projectionKey, Primary, NotNull)
|
||||
import qualified Database.Relational.Query as Query
|
||||
|
||||
@ -293,6 +293,6 @@ inlineQuery relVar' rel qVar' = do
|
||||
| prn == ''PrimeRelation -> do
|
||||
simpleValD qVar
|
||||
[t| Query $(return p) $(return r) |]
|
||||
[| unsafeTypedQuery $(stringE . toSQL $ rel) |]
|
||||
[| unsafeTypedQuery $(stringE . sqlFromRelation $ rel) |]
|
||||
_ ->
|
||||
compileError $ "expandRelation: Variable must have PrimeRelation type: " ++ show relVar
|
||||
|
@ -6,7 +6,7 @@ module Database.Relational.Query.Type (
|
||||
Insert(untypeInsert), unsafeTypedInsert, typedInsert
|
||||
) where
|
||||
|
||||
import Database.Relational.Query.Join (PrimeRelation, toSQL)
|
||||
import Database.Relational.Query.Join (PrimeRelation, sqlFromRelation)
|
||||
import Database.Relational.Query.Table (Table)
|
||||
import Database.Relational.Query.SQL (singleKeyUpdateSQL, insertSQL)
|
||||
|
||||
@ -20,7 +20,7 @@ instance Show (Query p a) where
|
||||
show = untypeQuery
|
||||
|
||||
fromRelation :: PrimeRelation p r -> Query p r
|
||||
fromRelation = unsafeTypedQuery . toSQL
|
||||
fromRelation = unsafeTypedQuery . sqlFromRelation
|
||||
|
||||
|
||||
newtype Update p a = Update { untypeUpdate :: String }
|
||||
|
Loading…
Reference in New Issue
Block a user