mirror of
https://github.com/khibino/haskell-relational-record.git
synced 2024-12-12 12:09:08 +03:00
Renamed.
This commit is contained in:
parent
bbe66c8dc3
commit
866f188bb2
@ -1,6 +1,7 @@
|
||||
|
||||
module Database.Relational.Query (
|
||||
module Database.Relational.Query.Table,
|
||||
module Database.Relational.Query.SQL,
|
||||
module Database.Relational.Query.Pi,
|
||||
module Database.Relational.Query.Constraint,
|
||||
module Database.Relational.Query.AliasId,
|
||||
@ -14,6 +15,7 @@ module Database.Relational.Query (
|
||||
) where
|
||||
|
||||
import Database.Relational.Query.Table (Table)
|
||||
import Database.Relational.Query.SQL (singleKeyUpdateSQL, insertSQL)
|
||||
import Database.Relational.Query.Pi
|
||||
import Database.Relational.Query.Constraint
|
||||
(Key, recordConstraint, projectionKey,
|
||||
@ -29,6 +31,6 @@ import Database.Relational.Query.Relation (Relation, PrimeRelation, toSQL, fromT
|
||||
import Database.Relational.Query.Join
|
||||
import Database.Relational.Query.Type
|
||||
(Query, untypeQuery, fromRelation,
|
||||
Update, untypeUpdate, typedPrimaryUpdate,
|
||||
Update, untypeUpdate, typedSingleKeyUpdate,
|
||||
Insert, untypeInsert, typedInsert)
|
||||
import Database.Relational.Query.Derives
|
||||
|
@ -1,7 +1,7 @@
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
module Database.Relational.Query.SQL (
|
||||
primaryUpdateSQL', primaryUpdateSQL,
|
||||
singleKeyUpdateSQL', singleKeyUpdateSQL,
|
||||
|
||||
insertSQL', insertSQL
|
||||
) where
|
||||
@ -11,15 +11,15 @@ import qualified Language.SQL.Keyword as SQL
|
||||
import Database.Relational.Query.Table (Table, name, columns)
|
||||
|
||||
|
||||
primaryUpdateSQL' :: String -> [String] -> String -> String
|
||||
primaryUpdateSQL' table cols pkey =
|
||||
singleKeyUpdateSQL' :: String -> [String] -> String -> String
|
||||
singleKeyUpdateSQL' table cols key =
|
||||
SQL.unwordsSQL
|
||||
$ [UPDATE, SQL.word table, SET, assignments `SQL.sepBy` ", ",
|
||||
WHERE, SQL.word pkey, "= ?"]
|
||||
where assignments = map (\f -> SQL.word f .=. "?") . filter (/= pkey) $ cols
|
||||
WHERE, SQL.word key, "= ?"]
|
||||
where assignments = map (\f -> SQL.word f .=. "?") . filter (/= key) $ cols
|
||||
|
||||
primaryUpdateSQL :: Table r -> String -> String
|
||||
primaryUpdateSQL tbl = primaryUpdateSQL' (name tbl) (columns tbl)
|
||||
singleKeyUpdateSQL :: Table r -> String -> String
|
||||
singleKeyUpdateSQL tbl = singleKeyUpdateSQL' (name tbl) (columns tbl)
|
||||
|
||||
|
||||
insertSQL' :: String -> [String] -> String
|
||||
|
@ -2,14 +2,14 @@
|
||||
module Database.Relational.Query.Type (
|
||||
Query (untypeQuery), unsafeTypedQuery, fromRelation,
|
||||
|
||||
Update(untypeUpdate), unsafeTypedUpdate, typedPrimaryUpdate,
|
||||
Update(untypeUpdate), unsafeTypedUpdate, typedSingleKeyUpdate,
|
||||
Insert(untypeInsert), unsafeTypedInsert, typedInsert
|
||||
) where
|
||||
|
||||
import Database.Relational.Query.Relation (PrimeRelation)
|
||||
import qualified Database.Relational.Query.Relation as Relation
|
||||
import Database.Relational.Query.Table (Table)
|
||||
import Database.Relational.Query.SQL (primaryUpdateSQL, insertSQL)
|
||||
import Database.Relational.Query.SQL (singleKeyUpdateSQL, insertSQL)
|
||||
|
||||
|
||||
newtype Query p a = Query { untypeQuery :: String }
|
||||
@ -29,8 +29,8 @@ newtype Update p a = Update { untypeUpdate :: String }
|
||||
unsafeTypedUpdate :: String -> Update p a
|
||||
unsafeTypedUpdate = Update
|
||||
|
||||
typedPrimaryUpdate :: Table r -> String -> Update p r
|
||||
typedPrimaryUpdate tbl = unsafeTypedUpdate . primaryUpdateSQL tbl
|
||||
typedSingleKeyUpdate :: Table r -> String -> Update p r
|
||||
typedSingleKeyUpdate tbl = unsafeTypedUpdate . singleKeyUpdateSQL tbl
|
||||
|
||||
newtype Insert a = Insert { untypeInsert :: String }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user