Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- from :: ToFrom a a' => a -> SqlQuery a'
- type RawFn = NeedParens -> IdentInfo -> (Builder, [PersistValue])
- newtype From a = From {}
- class ToFrom a r | a -> r where
- data Table a = Table
- table :: forall ent. PersistEntity ent => From (SqlExpr (Entity ent))
- newtype SubQuery a = SubQuery a
- selectQuery :: (SqlSelect a r, ToAlias a, ToAliasReference a) => SqlQuery a -> From a
Documentation
from :: ToFrom a a' => a -> SqlQuery a' Source #
FROM
clause, used to bring entities into scope.
Internally, this function uses the From
datatype.
Unlike the old from
, this does not
take a function as a parameter, but rather a value that
represents a JOIN
tree constructed out of instances of From
.
This implementation eliminates certain
types of runtime errors by preventing the construction of
invalid SQL (e.g. illegal nested-from
).
type RawFn = NeedParens -> IdentInfo -> (Builder, [PersistValue]) Source #
Data type defining the From language. This should not constructed directly in application code.
A From
is a SqlQuery which returns a reference to the result of calling from
and a function that produces a portion of a FROM clause. This gets passed to
the FromRaw FromClause constructor directly when converting
from a From
to a SqlQuery
using from
Since: 3.5.0.0
class ToFrom a r | a -> r where Source #
A helper class primarily designed to allow using SqlQuery
directly in
a From expression. This is also useful for embedding a SqlSetOperation
,
as well as supporting backwards compatibility for the
data constructor join tree used prior to 3.5.0.0
Since: 3.5.0.0
Instances
Deprecated: @since 3.5.0.0 - use table
instead
table :: forall ent. PersistEntity ent => From (SqlExpr (Entity ent)) Source #
Bring a PersistEntity into scope from a table
select $ from $ table @People
Since: 3.5.0.0
Deprecated: Since: 3.4.0.0 - It is no longer necessary to tag SqlQuery
values with SubQuery
selectQuery :: (SqlSelect a r, ToAlias a, ToAliasReference a) => SqlQuery a -> From a Source #
Select from a subquery, often used in conjuction with joins but can be
used without any joins. Because SqlQuery
has a ToFrom
instance you probably
dont need to use this function directly.
select $ p <- from $ selectQuery do p <- from $ table @Person limit 5 orderBy [ asc p ^. PersonAge ] ...
Since: 3.5.0.0