Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data Query (ctx :: Type)
- data RowsOf (ctx :: Type)
- class DBWhere qry ctx where
- class DBRender a where
- renderSQL :: a -> ByteString
- newtype Expr (ctx :: Type) (ty :: Type) = Expr {}
- data SortExpr (ctx :: Type)
- class KnownSymbol tbl => HasTable (ctx :: Type) (tbl :: Symbol) | ctx -> tbl
- class KnownSymbol col => HasColumn (ctx :: Type) (col :: Symbol) (ty :: Type) | ctx col -> ty
- class Inline ty where
- query :: forall ctx. Query ctx
- rowsOf :: forall ctx. RowsOf ctx
- where_ :: DBWhere qry ctx => Expr ctx Bool -> qry -> qry
- orderBy :: Seq (SortExpr ctx) -> Query ctx -> Query ctx
- limit :: Word64 -> Query ctx -> Query ctx
- offset :: Word64 -> Query ctx -> Query ctx
- asc :: Expr ctx ty -> SortExpr ctx
- desc :: Expr ctx ty -> SortExpr ctx
- (.&&) :: Expr ctx Bool -> Expr ctx Bool -> Expr ctx Bool
- (.||) :: Expr ctx Bool -> Expr ctx Bool -> Expr ctx Bool
- (.==) :: Expr ctx a -> Expr ctx a -> Expr ctx Bool
- (./=) :: Expr ctx a -> Expr ctx a -> Expr ctx Bool
- true :: Expr ctx Bool
- false :: Expr ctx Bool
- isNull :: Expr ctx a -> Expr ctx Bool
- isNotNull :: Expr ctx a -> Expr ctx Bool
- (&) :: a -> (a -> b) -> b
Documentation
class DBWhere qry ctx where Source #
whereCond :: Lens' qry (Maybe (Expr ctx Bool)) Source #
A convenience function for when the user doesn't want to specify any conditions.
class DBRender a where Source #
renderSQL :: a -> ByteString Source #
Instances
DBRender (RowsOf ctx) Source # | |
Defined in Database.Quibble renderSQL :: RowsOf ctx -> ByteString Source # | |
DBRender (Query ctx) Source # | |
Defined in Database.Quibble renderSQL :: Query ctx -> ByteString Source # |
newtype Expr (ctx :: Type) (ty :: Type) Source #
The constructor is exposed in case you need to unsafely construct | expressions. But you shouldn't rely on it too much.
Instances
(KnownSymbol tbl, HasTable ctx tbl, HasColumn ctx col ty) => IsLabel col (Expr ctx ty) Source # | |
Defined in Database.Quibble | |
(Show a, Fractional a) => Fractional (Expr ctx a) Source # | |
(Show a, Num a) => Num (Expr ctx a) Source # | |
Defined in Database.Quibble | |
IsString (Expr ctx String) Source # | |
Defined in Database.Quibble fromString :: String -> Expr ctx String # | |
IsString (Expr ctx Text) Source # | |
Defined in Database.Quibble fromString :: String -> Expr ctx Text # | |
IsString (Expr ctx Text) Source # | |
Defined in Database.Quibble fromString :: String -> Expr ctx Text # | |
IsString (Expr ctx ByteString) Source # | |
Defined in Database.Quibble fromString :: String -> Expr ctx ByteString # | |
IsString (Expr ctx ByteString) Source # | |
Defined in Database.Quibble fromString :: String -> Expr ctx ByteString # |
data SortExpr (ctx :: Type) Source #
You can think of this as a wrapper around Expr
that adds sorting direction.
| Unfortunately, we can't allow ASC NULLS LAST
or friends here because that's
| not portable across database.
class KnownSymbol tbl => HasTable (ctx :: Type) (tbl :: Symbol) | ctx -> tbl Source #
Allows us to lookup table name by type.
class KnownSymbol col => HasColumn (ctx :: Type) (col :: Symbol) (ty :: Type) | ctx col -> ty Source #
Allows us to infer the column type from the table type and column name.
class Inline ty where Source #
Instances
Inline Bool Source # | |
Inline Int16 Source # | |
Inline Int32 Source # | |
Inline Int64 Source # | |
Inline Word16 Source # | |
Inline Word32 Source # | |
Inline Word64 Source # | |
Inline String Source # | |
Inline ByteString Source # | |
Defined in Database.Quibble inline :: ByteString -> Expr ctx ByteString Source # | |
Inline ByteString Source # | |
Defined in Database.Quibble inline :: ByteString -> Expr ctx ByteString Source # | |
Inline Text Source # | |
Inline Text Source # | |
Inline UTCTime Source # | |
Inline UUID Source # | |
query :: forall ctx. Query ctx Source #
A Query
is meant to represent everything in a SELECT
statement, other
| than the columns selection and the joined tables.
| This is meant to be used with -XTypeApplications
, like query @Foo
.
rowsOf :: forall ctx. RowsOf ctx Source #
A RowsOf
is meant to represent the conditions of an UPDATE
or DELETE
.
| This is meant to be used with -XTypeApplications
, like rowsOf @Foo
.
orderBy :: Seq (SortExpr ctx) -> Query ctx -> Query ctx Source #
Specify how the output should be sorted. If orderBy
is used multiple times,
| all sort expressions are concatenated together, with later calls having
| lower sort precedence.
|
| -XOverloadedLists
can help make specifying the list of sort expressions
| simpler.
|
| > query @Foo
| > & orderBy [asc col2]
limit :: Word64 -> Query ctx -> Query ctx Source #
Set the number of rows specified by a LIMIT
. If limit
is used multiple
| times, only the result of the last call matters.
|
| > query @Foo
| > & limit 50
offset :: Word64 -> Query ctx -> Query ctx Source #
Set the number of rows specified by an OFFSET
. If offset
is used
| multiple times, only the result of the last call matters.
|
| > query Foo
| > & offset 100
|
| Note that in the general case, your query will still pay the cost of
| looking up all the rows that were skipped! Be careful when using
OFFSET@.