Hoogle Search

Within LTS Haskell 24.3 (ghc-9.10.2)

Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.

  1. subList_select :: PersistField a => SqlQuery (SqlExpr (Value a)) -> SqlExpr (ValueList a)

    esqueleto Database.Esqueleto

    Execute a subquery SELECT in an SqlExpression. Returns a list of values.

  2. subSelect :: (PersistField a, NullableFieldProjection a a') => SqlQuery (SqlExpr (Value a)) -> SqlExpr (Value (Maybe a'))

    esqueleto Database.Esqueleto

    Execute a subquery SELECT in a SqlExpr. The query passed to this function will only return a single result - it has a LIMIT 1 passed in to the query to make it safe, and the return type is Maybe to indicate that the subquery might result in 0 rows. If you find yourself writing joinV . subSelect, then consider using subSelectMaybe. If you're performing a countRows, then you can use subSelectCount which is safe. If you know that the subquery will always return exactly one row (eg a foreign key constraint guarantees that you'll get exactly one row), then consider subSelectUnsafe, along with a comment explaining why it is safe.

  3. subSelectCount :: (Num a, PersistField a) => SqlQuery ignored -> SqlExpr (Value a)

    esqueleto Database.Esqueleto

    Performs a COUNT of the given query in a subSelect manner. This is always guaranteed to return a result value, and is completely safe.

  4. subSelectForeign :: (BackendCompatible SqlBackend (PersistEntityBackend val1), PersistEntity val1, PersistEntity val2, PersistField a) => SqlExpr (Entity val2) -> EntityField val2 (Key val1) -> (SqlExpr (Entity val1) -> SqlExpr (Value a)) -> SqlExpr (Value a)

    esqueleto Database.Esqueleto

    Performs a sub-select using the given foreign key on the entity. This is useful to extract values that are known to be present by the database schema. As an example, consider the following persistent definition:

    User
    profile ProfileId
    
    Profile
    name    Text
    
    The following query will return the name of the user.
    getUserWithName =
    select $
    from $ user ->
    pure (user, subSelectForeign user UserProfile (^. ProfileName)
    

  5. subSelectList :: PersistField a => SqlQuery (SqlExpr (Value a)) -> SqlExpr (ValueList a)

    esqueleto Database.Esqueleto

    Execute a subquery SELECT in a SqlExpr that returns a list. This is an alias for subList_select and is provided for symmetry with the other safe subselect functions.

  6. subSelectMaybe :: PersistField a => SqlQuery (SqlExpr (Value (Maybe a))) -> SqlExpr (Value (Maybe a))

    esqueleto Database.Esqueleto

    Execute a subquery SELECT in a SqlExpr. This function is a shorthand for the common joinV . subSelect idiom, where you are calling subSelect on an expression that would be Maybe already. As an example, you would use this function when calling sum_ or max_, which have Maybe in the result type (for a 0 row query).

  7. subSelectUnsafe :: PersistField a => SqlQuery (SqlExpr (Value a)) -> SqlExpr (Value a)

    esqueleto Database.Esqueleto

    Execute a subquery SELECT in a SqlExpr. This function is unsafe, because it can throw runtime exceptions in two cases:

    1. If the query passed has 0 result rows, then it will return a NULL value. The persistent parsing operations will fail on an unexpected NULL.
    2. If the query passed returns more than one row, then the SQL engine will fail with an error like "More than one row returned by a subquery used as an expression".
    This function is safe if you guarantee that exactly one row will be returned, or if the result already has a Maybe type for some reason. For variants with the safety encoded already, see subSelect and subSelectMaybe. For the most common safe use of this, see subSelectCount.

  8. class SqlSelect a r | a -> r, r -> a

    esqueleto Database.Esqueleto.Experimental

    (Internal) Class for mapping results coming from SqlQuery into actual results. This looks very similar to RawSql, and it is! However, there are some crucial differences and ultimately they're different classes.

  9. insertSelect :: forall (m :: Type -> Type) a backend . (MonadIO m, PersistEntity a, SqlBackendCanWrite backend) => SqlQuery (SqlExpr (Insertion a)) -> ReaderT backend m ()

    esqueleto Database.Esqueleto.Experimental

    Insert a PersistField for every selected value.

  10. insertSelectCount :: forall (m :: Type -> Type) a backend . (MonadIO m, PersistEntity a, SqlBackendCanWrite backend) => SqlQuery (SqlExpr (Insertion a)) -> ReaderT backend m Int64

    esqueleto Database.Esqueleto.Experimental

    Insert a PersistField for every selected value, return the count afterward

Page 4 of many | Previous | Next