Hoogle Search

Within LTS Haskell 24.4 (ghc-9.10.2)

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

  1. 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.Legacy

    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)
    

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

    esqueleto Database.Esqueleto.Legacy

    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.

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

    esqueleto Database.Esqueleto.Legacy

    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).

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

    esqueleto Database.Esqueleto.Legacy

    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.

  5. insertSelectWithConflict :: forall a (m :: Type -> Type) val backend . (FinalResult a, KnowResult a ~ Unique val, MonadIO m, PersistEntity val, SqlBackendCanWrite backend) => a -> SqlQuery (SqlExpr (Insertion val)) -> (SqlExpr (Entity val) -> SqlExpr (Entity val) -> [SqlExpr (Entity val) -> SqlExpr Update]) -> ReaderT backend m ()

    esqueleto Database.Esqueleto.PostgreSQL

    Inserts into a table the results of a query similar to insertSelect but allows to update values that violate a constraint during insertions. Example of usage:

    mkPersist sqlSettings [persistLowerCase|
    Bar
    num Int
    deriving Eq Show
    Foo
    num Int
    UniqueFoo num
    deriving Eq Show
    |]
    
    action = do
    insertSelectWithConflict
    UniqueFoo -- (UniqueFoo undefined) or (UniqueFoo anyNumber) would also work
    (do
    b <- from $ table @Bar
    return $ Foo <# (b ^. BarNum)
    )
    (\current excluded ->
    [FooNum =. (current ^. FooNum) +. (excluded ^. FooNum)]
    )
    
    Inserts to table Foo all Bar.num values and in case of conflict SomeFooUnique, the conflicting value is updated to the current plus the excluded.

  6. insertSelectWithConflictCount :: forall a val (m :: Type -> Type) backend . (FinalResult a, KnowResult a ~ Unique val, MonadIO m, PersistEntity val, SqlBackendCanWrite backend) => a -> SqlQuery (SqlExpr (Insertion val)) -> (SqlExpr (Entity val) -> SqlExpr (Entity val) -> [SqlExpr (Entity val) -> SqlExpr Update]) -> ReaderT backend m Int64

    esqueleto Database.Esqueleto.PostgreSQL

    Same as insertSelectWithConflict but returns the number of rows affected.

Page 8 of many | Previous | Next