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.
-
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)
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.
-
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).
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:
- 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.
- 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".
-
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. -
esqueleto Database.Esqueleto.PostgreSQL Same as insertSelectWithConflict but returns the number of rows affected.