Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module provides functions to consume data types that represent database queries (e.g. ReadRequest, MutateRequest) and SqlFragment to produce SqlQuery type outputs.
Synopsis
Documentation
readRequestToCountQuery :: ReadRequest -> Snippet Source #
SQL query meant for COUNTing the root node of the Tree. It only takes WHERE into account and doesn't include LIMIT/OFFSET because it would reduce the COUNT. SELECT 1 is done instead of SELECT * to prevent doing expensive operations(like functions based on the columns) inside the FROM target. If the request contains INNER JOINs, then the COUNT of the root node will change. For this case, we use a WHERE EXISTS instead of an INNER JOIN on the count query. See https://github.com/PostgREST/postgrest/issues/2009#issuecomment-977473031 Only for the nodes that have an INNER JOIN linked to the root level.