| Copyright | 2013-2018 Kei Hibino |
|---|---|
| License | BSD3 |
| Maintainer | ex8k.hibino@gmail.com |
| Stability | experimental |
| Portability | unknown |
| Safe Haskell | None |
| Language | Haskell2010 |
Database.Relational.Type
Contents
Description
This module defines typed SQL.
- newtype Query p a = Query {}
- unsafeTypedQuery :: String -> Query p a
- relationalQuery' :: Relation p r -> QuerySuffix -> Query p r
- relationalQuery :: Relation p r -> Query p r
- relationalQuerySQL :: Config -> Relation p r -> QuerySuffix -> String
- data KeyUpdate p a = KeyUpdate {
- updateKey :: Pi a p
- untypeKeyUpdate :: String
- unsafeTypedKeyUpdate :: Pi a p -> String -> KeyUpdate p a
- typedKeyUpdate :: Table a -> Pi a p -> KeyUpdate p a
- typedKeyUpdateTable :: TableDerivable r => Relation () r -> Pi r p -> KeyUpdate p r
- keyUpdate :: TableDerivable r => Pi r p -> KeyUpdate p r
- newtype Update p = Update {}
- unsafeTypedUpdate :: String -> Update p
- typedUpdate' :: Config -> Table r -> UpdateTarget p r -> Update p
- update' :: TableDerivable r => Config -> AssignStatement r (PlaceHolders p) -> Update p
- update :: TableDerivable r => AssignStatement r (PlaceHolders p) -> Update p
- updateNoPH :: TableDerivable r => AssignStatement r () -> Update ()
- typedUpdateAllColumn :: PersistableWidth r => Table r -> Restriction p r -> Update (r, p)
- updateAllColumn' :: (PersistableWidth r, TableDerivable r) => Config -> RestrictedStatement r (PlaceHolders p) -> Update (r, p)
- updateAllColumn :: (PersistableWidth r, TableDerivable r) => RestrictedStatement r (PlaceHolders p) -> Update (r, p)
- updateAllColumnNoPH :: (PersistableWidth r, TableDerivable r) => RestrictedStatement r () -> Update r
- updateSQL :: Config -> Table r -> UpdateTarget p r -> String
- data Insert a = Insert {
- untypeInsert :: String
- chunkedInsert :: Maybe (String, Int)
- untypeChunkInsert :: Insert a -> String
- chunkSizeOfInsert :: Insert a -> Int
- unsafeTypedInsert' :: String -> String -> Int -> Insert a
- unsafeTypedInsert :: String -> Insert a
- typedInsert' :: PersistableWidth r => Config -> Table r -> Pi r r' -> Insert r'
- insert :: (PersistableWidth r, TableDerivable r) => Pi r r' -> Insert r'
- typedInsertValue' :: Config -> Table r -> InsertTarget p r -> Insert p
- insertValue' :: TableDerivable r => Config -> Register r (PlaceHolders p) -> Insert p
- insertValue :: TableDerivable r => Register r (PlaceHolders p) -> Insert p
- insertValueNoPH :: TableDerivable r => Register r () -> Insert ()
- insertValueList' :: (TableDerivable r, LiteralSQL r') => Config -> Pi r r' -> [r'] -> [Insert ()]
- insertValueList :: (TableDerivable r, LiteralSQL r') => Pi r r' -> [r'] -> [Insert ()]
- newtype InsertQuery p = InsertQuery {}
- unsafeTypedInsertQuery :: String -> InsertQuery p
- typedInsertQuery' :: Config -> Table r -> Pi r r' -> Relation p r' -> InsertQuery p
- insertQuery :: TableDerivable r => Pi r r' -> Relation p r' -> InsertQuery p
- insertQuerySQL :: Config -> Table r -> Pi r r' -> Relation p r' -> String
- newtype Delete p = Delete {}
- unsafeTypedDelete :: String -> Delete p
- typedDelete' :: Config -> Table r -> Restriction p r -> Delete p
- delete' :: TableDerivable r => Config -> RestrictedStatement r (PlaceHolders p) -> Delete p
- delete :: TableDerivable r => RestrictedStatement r (PlaceHolders p) -> Delete p
- deleteNoPH :: TableDerivable r => RestrictedStatement r () -> Delete ()
- deleteSQL :: Config -> Table r -> Restriction p r -> String
- class UntypeableNoFetch s where
- typedUpdate :: Table r -> UpdateTarget p r -> Update p
- typedInsert :: PersistableWidth r => Table r -> Pi r r' -> Insert r'
- typedInsertValue :: Table r -> InsertTarget p r -> Insert p
- typedInsertQuery :: Table r -> Pi r r' -> Relation p r' -> InsertQuery p
- typedDelete :: Table r -> Restriction p r -> Delete p
- derivedKeyUpdate :: TableDerivable r => Pi r p -> KeyUpdate p r
- derivedUpdate' :: TableDerivable r => Config -> AssignStatement r (PlaceHolders p) -> Update p
- derivedUpdate :: TableDerivable r => AssignStatement r (PlaceHolders p) -> Update p
- derivedUpdateAllColumn' :: (PersistableWidth r, TableDerivable r) => Config -> RestrictedStatement r (PlaceHolders p) -> Update (r, p)
- derivedUpdateAllColumn :: (PersistableWidth r, TableDerivable r) => RestrictedStatement r (PlaceHolders p) -> Update (r, p)
- derivedInsert :: (PersistableWidth r, TableDerivable r) => Pi r r' -> Insert r'
- derivedInsertValue' :: TableDerivable r => Config -> Register r (PlaceHolders p) -> Insert p
- derivedInsertValue :: TableDerivable r => Register r (PlaceHolders p) -> Insert p
- derivedInsertQuery :: TableDerivable r => Pi r r' -> Relation p r' -> InsertQuery p
- derivedDelete' :: TableDerivable r => Config -> RestrictedStatement r (PlaceHolders p) -> Delete p
- derivedDelete :: TableDerivable r => RestrictedStatement r (PlaceHolders p) -> Delete p
Typed query statement
Query type with place-holder parameter p and query result type a.
Constructors
| Query | |
Fields | |
Unsafely make typed Query from SQL string.
relationalQuery' :: Relation p r -> QuerySuffix -> Query p r Source #
relationalQuerySQL :: Config -> Relation p r -> QuerySuffix -> String Source #
From Relation into untyped SQL query string.
Typed update statement
Update type with key type p and update record type a.
Columns to update are record columns other than key columns,
So place-holder parameter type is the same as record type a.
Constructors
| KeyUpdate | |
Fields
| |
unsafeTypedKeyUpdate :: Pi a p -> String -> KeyUpdate p a Source #
Unsafely make typed KeyUpdate from SQL string.
typedKeyUpdateTable :: TableDerivable r => Relation () r -> Pi r p -> KeyUpdate p r Source #
Update type with place-holder parameter p.
Constructors
| Update | |
Fields | |
typedUpdate' :: Config -> Table r -> UpdateTarget p r -> Update p Source #
Make typed Update from Config, Table and UpdateTarget.
update' :: TableDerivable r => Config -> AssignStatement r (PlaceHolders p) -> Update p Source #
Make typed Update from Config, derived table and AssignStatement
update :: TableDerivable r => AssignStatement r (PlaceHolders p) -> Update p Source #
Make typed Update from defaultConfig, derived table and AssignStatement
updateNoPH :: TableDerivable r => AssignStatement r () -> Update () Source #
Make typed Update from defaultConfig, derived table and AssignStatement with no(unit) placeholder.
typedUpdateAllColumn :: PersistableWidth r => Table r -> Restriction p r -> Update (r, p) Source #
Make typed Update from Table and Restriction.
Update target is all column.
updateAllColumn' :: (PersistableWidth r, TableDerivable r) => Config -> RestrictedStatement r (PlaceHolders p) -> Update (r, p) Source #
Make typed Update from Config, derived table and AssignStatement.
Update target is all column.
updateAllColumn :: (PersistableWidth r, TableDerivable r) => RestrictedStatement r (PlaceHolders p) -> Update (r, p) Source #
Make typed Update from defaultConfig, derived table and AssignStatement.
Update target is all column.
updateAllColumnNoPH :: (PersistableWidth r, TableDerivable r) => RestrictedStatement r () -> Update r Source #
Make typed Update from defaultConfig, derived table and AssignStatement
without placeholder other than target table columns.
Update target is all column.
updateSQL :: Config -> Table r -> UpdateTarget p r -> String Source #
Make untyped update SQL string from Table and UpdateTarget.
Typed insert statement
Insert type to insert record type a.
Constructors
| Insert | |
Fields
| |
untypeChunkInsert :: Insert a -> String Source #
Statement to use chunked insert
chunkSizeOfInsert :: Insert a -> Int Source #
Size to use chunked insert
unsafeTypedInsert' :: String -> String -> Int -> Insert a Source #
Unsafely make typed Insert from single insert and chunked insert SQL.
typedInsert' :: PersistableWidth r => Config -> Table r -> Pi r r' -> Insert r' Source #
insert :: (PersistableWidth r, TableDerivable r) => Pi r r' -> Insert r' Source #
Table type inferred Insert.
typedInsertValue' :: Config -> Table r -> InsertTarget p r -> Insert p Source #
Make typed Insert from Config, Table and monadic builded InsertTarget object.
insertValue' :: TableDerivable r => Config -> Register r (PlaceHolders p) -> Insert p Source #
insertValue :: TableDerivable r => Register r (PlaceHolders p) -> Insert p Source #
Make typed Insert from defaultConfig, derived table and monadic builded Register object.
insertValueNoPH :: TableDerivable r => Register r () -> Insert () Source #
Make typed Insert from defaultConfig, derived table and monadic builded Register object with no(unit) placeholder.
insertValueList' :: (TableDerivable r, LiteralSQL r') => Config -> Pi r r' -> [r'] -> [Insert ()] Source #
insertValueList :: (TableDerivable r, LiteralSQL r') => Pi r r' -> [r'] -> [Insert ()] Source #
Make typed Insert list from records list.
newtype InsertQuery p Source #
InsertQuery type.
Constructors
| InsertQuery | |
Fields | |
Instances
| UntypeableNoFetch InsertQuery Source # | |
| Show (InsertQuery p) Source # | Show insert SQL string. |
unsafeTypedInsertQuery :: String -> InsertQuery p Source #
Unsafely make typed InsertQuery from SQL string.
typedInsertQuery' :: Config -> Table r -> Pi r r' -> Relation p r' -> InsertQuery p Source #
Make typed InsertQuery from columns selector Table, Pi and Relation with configuration parameter.
insertQuery :: TableDerivable r => Pi r r' -> Relation p r' -> InsertQuery p Source #
Table type inferred InsertQuery.
Typed delete statement
Delete type with place-holder parameter p.
Constructors
| Delete | |
Fields | |
typedDelete' :: Config -> Table r -> Restriction p r -> Delete p Source #
Make typed Delete from Config, Table and Restriction.
delete' :: TableDerivable r => Config -> RestrictedStatement r (PlaceHolders p) -> Delete p Source #
delete :: TableDerivable r => RestrictedStatement r (PlaceHolders p) -> Delete p Source #
Make typed Delete from defaultConfig, derived table and RestrictContext
deleteNoPH :: TableDerivable r => RestrictedStatement r () -> Delete () Source #
Make typed Delete from defaultConfig, derived table and RestrictContext with no(unit) placeholder.
deleteSQL :: Config -> Table r -> Restriction p r -> String Source #
Make untyped delete SQL string from Table and Restriction.
Generalized interfaces
class UntypeableNoFetch s where Source #
Untype interface for typed no-result type statments
with single type parameter which represents place-holder parameter p.
Minimal complete definition
Methods
untypeNoFetch :: s p -> String Source #
Deprecated
typedUpdate :: Table r -> UpdateTarget p r -> Update p Source #
Deprecated: use typedUpdate defaultConfig` instead of this.
Make typed Update using defaultConfig, Table and UpdateTarget.
typedInsert :: PersistableWidth r => Table r -> Pi r r' -> Insert r' Source #
Deprecated: use typedInsert defaultConfig` instead of this.
typedInsertValue :: Table r -> InsertTarget p r -> Insert p Source #
Deprecated: use typedInsertValue defaultConfig` instead of this.
Make typed Insert from Table and monadic builded InsertTarget object.
typedInsertQuery :: Table r -> Pi r r' -> Relation p r' -> InsertQuery p Source #
Deprecated: use typedInsertQuery defaultConfig` instead of this.
Make typed InsertQuery from columns selector Table, Pi and Relation.
typedDelete :: Table r -> Restriction p r -> Delete p Source #
Deprecated: use typedDelete defaultConfig` instead of this.
Make typed Delete from Table and Restriction.
derivedKeyUpdate :: TableDerivable r => Pi r p -> KeyUpdate p r Source #
derivedUpdate' :: TableDerivable r => Config -> AssignStatement r (PlaceHolders p) -> Update p Source #
Deprecated: use update' instead of this.
Make typed Update from Config, derived table and AssignStatement
derivedUpdate :: TableDerivable r => AssignStatement r (PlaceHolders p) -> Update p Source #
Deprecated: use update instead of this.
Make typed Update from defaultConfig, derived table and AssignStatement
derivedUpdateAllColumn' :: (PersistableWidth r, TableDerivable r) => Config -> RestrictedStatement r (PlaceHolders p) -> Update (r, p) Source #
Deprecated: use updateAllColumn' instead of this.
Make typed Update from Config, derived table and AssignStatement.
Update target is all column.
derivedUpdateAllColumn :: (PersistableWidth r, TableDerivable r) => RestrictedStatement r (PlaceHolders p) -> Update (r, p) Source #
Deprecated: use updateAllColumn instead of this.
Make typed Update from defaultConfig, derived table and AssignStatement.
Update target is all column.
derivedInsert :: (PersistableWidth r, TableDerivable r) => Pi r r' -> Insert r' Source #
derivedInsertValue' :: TableDerivable r => Config -> Register r (PlaceHolders p) -> Insert p Source #
Deprecated: use insertValue' instead of this.
Make typed Insert from Config, derived table and monadic builded Register object.
derivedInsertValue :: TableDerivable r => Register r (PlaceHolders p) -> Insert p Source #
Deprecated: use insertValue instead of this.
Make typed Insert from defaultConfig, derived table and monadic builded Register object.
derivedInsertQuery :: TableDerivable r => Pi r r' -> Relation p r' -> InsertQuery p Source #
Deprecated: use insertQuery instead of this.
Table type inferred InsertQuery.
derivedDelete' :: TableDerivable r => Config -> RestrictedStatement r (PlaceHolders p) -> Delete p Source #
derivedDelete :: TableDerivable r => RestrictedStatement r (PlaceHolders p) -> Delete p Source #
Deprecated: use delete instead of this.
Make typed Delete from defaultConfig, derived table and RestrictContext