Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data Table (table :: Symbol) database = Table (Maybe Text) Text
- data Field (table :: Symbol) database (nullable :: Nullable) a = Field Text Text
- newtype Tbl table database (joinType :: JoinType) = Tbl {
- getTableAlias :: forall fieldNull exprNull a. CheckExprNullable (JoinNullable joinType fieldNull) exprNull => Field table database fieldNull a -> Expression exprNull a
- (@@) :: CheckExprNullable (JoinNullable joinType fieldNull) exprNull => Tbl table database (joinType :: JoinType) -> Field table database fieldNull a -> Expression exprNull a
- data Nullable
- data Query database a
- data Selector a
- sel :: FromSql a => Expression 'NotNull a -> Selector a
- selMaybe :: FromSql (Maybe a) => Expression 'Nullable a -> Selector (Maybe a)
- data Expression (nullable :: Nullable) a
- data SomeExpression
- someExpr :: Expression nullable a -> SomeExpression
- type Operator a b c = forall nullable. Expression nullable a -> Expression nullable b -> Expression nullable c
- arg :: ToSql a => a -> Expression nullable a
- argMaybe :: ToSql a => Maybe a -> Expression 'Nullable a
- nullable :: Expression nullable a -> Expression 'Nullable a
- cast :: Castable a => Expression nullable b -> Expression nullable a
- unsafeCast :: Expression nullable a -> Expression nullable b
- op :: (QueryBuilder -> QueryBuilder -> QueryBuilder) -> Operator a b c
- fun1 :: (QueryBuilder -> QueryBuilder) -> Expression nullable a -> Expression nullable b
- fun2 :: (QueryBuilder -> QueryBuilder -> QueryBuilder) -> Expression nullable a -> Expression nullable b -> Expression nullable c
- fun3 :: (QueryBuilder -> QueryBuilder -> QueryBuilder -> QueryBuilder) -> Expression nullable a -> Expression nullable b -> Expression nullable c -> Expression nullable d
- (>.) :: ToSql a => Operator a a Bool
- (<.) :: ToSql a => Operator a a Bool
- (>=.) :: ToSql a => Operator a a Bool
- (<=.) :: ToSql a => Operator a a Bool
- (&&.) :: Operator Bool Bool Bool
- (||.) :: Operator Bool Bool Bool
- substr :: Expression nullable Text -> Expression nullable Int -> Expression nullable Int -> Expression nullable Text
- true_ :: Expression nullable Bool
- false_ :: Expression nullable Bool
- from :: Table table database -> Query database (Tbl table database 'InnerJoined)
- fromSubQuery :: (Generic inExprs, Generic outExprs, SubQueryExpr 'LeftJoined (Rep inExprs ()) (Rep outExprs ())) => Query database inExprs -> Query database outExprs
- innerJoin :: Table table database -> (Tbl table database 'InnerJoined -> Expression nullable Bool) -> Query database (Tbl table database 'InnerJoined)
- leftJoin :: Table table database -> (Tbl table database 'LeftJoined -> Expression nullable Bool) -> Query database (Tbl table database 'LeftJoined)
- joinSubQuery :: (Generic inExprs, Generic outExprs, SubQueryExpr 'InnerJoined (Rep inExprs ()) (Rep outExprs ())) => Query database inExprs -> (outExprs -> Expression nullable Bool) -> Query database outExprs
- leftJoinSubQuery :: (Generic inExprs, Generic outExprs, SubQueryExpr 'LeftJoined (Rep inExprs ()) (Rep outExprs ())) => Query database inExprs -> (outExprs -> Expression nullable Bool) -> Query database outExprs
- where_ :: Expression nullable Bool -> Query database ()
- groupBy_ :: [SomeExpression] -> Query database ()
- having :: Expression nullable Bool -> Query database ()
- orderBy :: [QueryOrdering] -> Query database ()
- limit :: Int -> Query database ()
- limitOffset :: Int -> Int -> Query database ()
- data Insertor (table :: Symbol) database a
- insertValues :: Table table database -> Insertor table database a -> [a] -> Command
- insertSelect :: Table table database -> Query database [Into database table] -> Command
- insertData :: (Generic a, Generic b, InsertGeneric tbl db (Rep a ()) (Rep b ())) => a -> Insertor tbl db b
- skipInsert :: Insertor tbl db a
- into :: Insertable fieldNull fieldType b => (a -> b) -> Field table database fieldNull fieldType -> Insertor table database a
- lensInto :: Insertable fieldNull fieldType b => Getter a b -> Field table database fieldNull fieldType -> Insertor table database a
- insertOne :: Insertable fieldNull fieldType a => Field table database fieldNull fieldType -> Insertor table database a
- exprInto :: CheckExprNullable exprNullable fieldNullable => Expression exprNullable a -> Field table database fieldNullable a -> Into database table
- data Into database (table :: Symbol)
- type Getter s a = (a -> Const a a) -> s -> Const a s
- class ToSql a
- class FromSql a
- subQueryExpr :: Query database (Expression nullable a) -> Expression nullable a
Database Types
newtype Tbl table database (joinType :: JoinType) Source #
An table alias that can be used inside the Query. The function inside the newtype can also be applied directly to create an expression from a field.
Tbl | |
|
(@@) :: CheckExprNullable (JoinNullable joinType fieldNull) exprNull => Tbl table database (joinType :: JoinType) -> Field table database fieldNull a -> Expression exprNull a infixl 9 Source #
Create an expression from an aliased table and a field.
Querying
data Query database a Source #
Instances
Monad (Query database) Source # | |
Functor (Query database) Source # | |
Applicative (Query database) Source # | |
Defined in Database.MySQL.Hasqlator.Typed pure :: a -> Query database a # (<*>) :: Query database (a -> b) -> Query database a -> Query database b # liftA2 :: (a -> b -> c) -> Query database a -> Query database b -> Query database c # (*>) :: Query database a -> Query database b -> Query database b # (<*) :: Query database a -> Query database b -> Query database a # | |
ToQueryBuilder (Query database (Selector a)) Source # | |
Defined in Database.MySQL.Hasqlator.Typed toQueryBuilder :: Query database (Selector a) -> QueryBuilder Source # |
Selectors
Selectors contain the target fields or expressions in a SQL
SELECT statement, and perform the conversion to haskell. Selectors
are instances of Applicative
, so they can return the desired
haskell type.
Instances
Functor Selector Source # | |
Applicative Selector Source # | |
FromSql a => IsString (Selector a) Source # | |
Defined in Database.MySQL.Hasqlator fromString :: String -> Selector a # | |
Semigroup a => Semigroup (Selector a) Source # | |
Monoid a => Monoid (Selector a) Source # | |
ToQueryBuilder (Query database (Selector a)) Source # | |
Defined in Database.MySQL.Hasqlator.Typed toQueryBuilder :: Query database (Selector a) -> QueryBuilder Source # |
selMaybe :: FromSql (Maybe a) => Expression 'Nullable a -> Selector (Maybe a) Source #
make a selector from a column that can be null
Expressions
data Expression (nullable :: Nullable) a Source #
Instances
data SomeExpression Source #
An expression of any type
someExpr :: Expression nullable a -> SomeExpression Source #
Remove types of an expression
type Operator a b c = forall nullable. Expression nullable a -> Expression nullable b -> Expression nullable c Source #
arg :: ToSql a => a -> Expression nullable a Source #
pass an argument
nullable :: Expression nullable a -> Expression 'Nullable a Source #
make expression nullable
cast :: Castable a => Expression nullable b -> Expression nullable a Source #
Safe cast. This uses the SQL CAST function to convert safely from one type to another.
unsafeCast :: Expression nullable a -> Expression nullable b Source #
Cast the return type of an expression to any other type, without changing the query. Since this library adds static typing on top of SQL, you may sometimes want to use this to get back the lenient behaviour of SQL. This opens up more possibilies for runtime errors, so it's up to the programmer to ensure type correctness.
op :: (QueryBuilder -> QueryBuilder -> QueryBuilder) -> Operator a b c Source #
create an operator
fun1 :: (QueryBuilder -> QueryBuilder) -> Expression nullable a -> Expression nullable b Source #
fun2 :: (QueryBuilder -> QueryBuilder -> QueryBuilder) -> Expression nullable a -> Expression nullable b -> Expression nullable c Source #
fun3 :: (QueryBuilder -> QueryBuilder -> QueryBuilder -> QueryBuilder) -> Expression nullable a -> Expression nullable b -> Expression nullable c -> Expression nullable d Source #
substr :: Expression nullable Text -> Expression nullable Int -> Expression nullable Int -> Expression nullable Text Source #
true_ :: Expression nullable Bool Source #
false_ :: Expression nullable Bool Source #
Clauses
fromSubQuery :: (Generic inExprs, Generic outExprs, SubQueryExpr 'LeftJoined (Rep inExprs ()) (Rep outExprs ())) => Query database inExprs -> Query database outExprs Source #
innerJoin :: Table table database -> (Tbl table database 'InnerJoined -> Expression nullable Bool) -> Query database (Tbl table database 'InnerJoined) Source #
leftJoin :: Table table database -> (Tbl table database 'LeftJoined -> Expression nullable Bool) -> Query database (Tbl table database 'LeftJoined) Source #
joinSubQuery :: (Generic inExprs, Generic outExprs, SubQueryExpr 'InnerJoined (Rep inExprs ()) (Rep outExprs ())) => Query database inExprs -> (outExprs -> Expression nullable Bool) -> Query database outExprs Source #
leftJoinSubQuery :: (Generic inExprs, Generic outExprs, SubQueryExpr 'LeftJoined (Rep inExprs ()) (Rep outExprs ())) => Query database inExprs -> (outExprs -> Expression nullable Bool) -> Query database outExprs Source #
groupBy_ :: [SomeExpression] -> Query database () Source #
Insertion
insertData :: (Generic a, Generic b, InsertGeneric tbl db (Rep a ()) (Rep b ())) => a -> Insertor tbl db b Source #
skipInsert :: Insertor tbl db a Source #
into :: Insertable fieldNull fieldType b => (a -> b) -> Field table database fieldNull fieldType -> Insertor table database a Source #
lensInto :: Insertable fieldNull fieldType b => Getter a b -> Field table database fieldNull fieldType -> Insertor table database a Source #
insertOne :: Insertable fieldNull fieldType a => Field table database fieldNull fieldType -> Insertor table database a Source #
exprInto :: CheckExprNullable exprNullable fieldNullable => Expression exprNullable a -> Field table database fieldNullable a -> Into database table Source #
imported from Database.MySQL.Hasqlator
type Getter s a = (a -> Const a a) -> s -> Const a s Source #
A Getter type compatible with the lens library
toSqlValue
Instances
fromSql
Instances
subQueryExpr :: Query database (Expression nullable a) -> Expression nullable a Source #