-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support selecting from table-returning functions with
queryFunction
(…
- Loading branch information
1 parent
bf63d70
commit 9f372dc
Showing
7 changed files
with
106 additions
and
20 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
changelog.d/20230711_132805_shane.obrien_query_function.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<!-- | ||
A new scriv changelog fragment. | ||
Uncomment the section that is right (remove the HTML comment wrapper). | ||
--> | ||
<!-- | ||
### Removed | ||
- A bullet item for the Removed category. | ||
--> | ||
### Added | ||
|
||
- Added `queryFunction` for `SELECT`ing from table-returning functions such as `jsonb_to_recordset`. | ||
|
||
<!-- | ||
### Changed | ||
- A bullet item for the Changed category. | ||
--> | ||
<!-- | ||
### Deprecated | ||
- A bullet item for the Deprecated category. | ||
--> | ||
### Fixed | ||
|
||
- Fixes [#71](https://github.com/circuithub/rel8/issues/71). | ||
|
||
<!-- | ||
### Security | ||
- A bullet item for the Security category. | ||
--> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{-# language FlexibleContexts #-} | ||
{-# language MonoLocalBinds #-} | ||
|
||
module Rel8.Query.Function | ||
( queryFunction | ||
) | ||
where | ||
|
||
-- base | ||
import Prelude | ||
|
||
-- opaleye | ||
import qualified Opaleye.Internal.Operators as Opaleye | ||
|
||
-- rel8 | ||
import Rel8.Expr (Expr) | ||
import Rel8.Expr.Function (Arguments, primFunction) | ||
import Rel8.Query (Query) | ||
import Rel8.Query.Opaleye (fromOpaleye) | ||
import Rel8.Schema.QualifiedName (QualifiedName) | ||
import Rel8.Table (Table) | ||
import Rel8.Table.Opaleye (castTable, relExprPP) | ||
|
||
|
||
-- | Select each row from a function that returns a relation. This is | ||
-- equivalent to @FROM function(input)@. | ||
queryFunction :: (Arguments input, Table Expr output) | ||
=> QualifiedName -> input -> Query output | ||
queryFunction name input = fmap castTable $ fromOpaleye $ | ||
Opaleye.relationValuedExprExplicit relExprPP (const expr) | ||
where | ||
expr = primFunction name input |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters