From 8cec776fa64049eba283307ad7ffb8a463e9923e Mon Sep 17 00:00:00 2001 From: Ollie Charles Date: Tue, 11 Jul 2023 12:49:53 +0100 Subject: [PATCH] Set up scriv and add pending changelog entries (#255) --- changelog.d/20230707_182829_ollie_scriv.md | 3 ++ changelog.d/20230707_183519_ollie_scriv.md | 3 ++ changelog.d/20230707_184221_ollie_scriv.md | 3 ++ changelog.d/20230707_184703_ollie_scriv.md | 20 +++++++++++ changelog.d/20230707_185221_ollie_scriv.md | 3 ++ changelog.d/20230707_185339_ollie_scriv.md | 3 ++ changelog.d/20230707_185534_ollie_scriv.md | 39 ++++++++++++++++++++++ changelog.d/20230707_191301_ollie_scriv.md | 3 ++ changelog.d/scriv.ini | 3 ++ 9 files changed, 80 insertions(+) create mode 100644 changelog.d/20230707_182829_ollie_scriv.md create mode 100644 changelog.d/20230707_183519_ollie_scriv.md create mode 100644 changelog.d/20230707_184221_ollie_scriv.md create mode 100644 changelog.d/20230707_184703_ollie_scriv.md create mode 100644 changelog.d/20230707_185221_ollie_scriv.md create mode 100644 changelog.d/20230707_185339_ollie_scriv.md create mode 100644 changelog.d/20230707_185534_ollie_scriv.md create mode 100644 changelog.d/20230707_191301_ollie_scriv.md create mode 100644 changelog.d/scriv.ini diff --git a/changelog.d/20230707_182829_ollie_scriv.md b/changelog.d/20230707_182829_ollie_scriv.md new file mode 100644 index 0000000..f699b6e --- /dev/null +++ b/changelog.d/20230707_182829_ollie_scriv.md @@ -0,0 +1,3 @@ +### Added + +- Support PostgreSQL's `inet` type (which maps to the Haskell `NetAddr IP` type). ([#227](https://github.com/circuithub/rel8/pull/227)) \ No newline at end of file diff --git a/changelog.d/20230707_183519_ollie_scriv.md b/changelog.d/20230707_183519_ollie_scriv.md new file mode 100644 index 0000000..93f8ab5 --- /dev/null +++ b/changelog.d/20230707_183519_ollie_scriv.md @@ -0,0 +1,3 @@ +### Added + +- `Rel8.materialize` and `Rel8.Tabulate.materialize`, which add a materialization/optimisation fence to `SELECT` statements by binding a query to a `WITH` subquery. Note that Rel8 doesn't currently add `MATERIALIZE` to this, but may in the future. ([#180](https://github.com/circuithub/rel8/pull/180)) diff --git a/changelog.d/20230707_184221_ollie_scriv.md b/changelog.d/20230707_184221_ollie_scriv.md new file mode 100644 index 0000000..4165e9c --- /dev/null +++ b/changelog.d/20230707_184221_ollie_scriv.md @@ -0,0 +1,3 @@ +### Fixed + +- Fixed a bug with `catListTable` and `catNonEmptyTable` where invalid SQL could be produced. ([#240](https://github.com/circuithub/rel8/pull/240)) diff --git a/changelog.d/20230707_184703_ollie_scriv.md b/changelog.d/20230707_184703_ollie_scriv.md new file mode 100644 index 0000000..e602a51 --- /dev/null +++ b/changelog.d/20230707_184703_ollie_scriv.md @@ -0,0 +1,20 @@ +### Changed + +- Rel8's API regarding aggregation has changed significantly, and is now a closer match to Opaleye. + + The previous aggregation API had `aggregate` transform a `Table` from the `Aggregate` context back into the `Expr` context: + + ```haskell + myQuery = aggregate do + a <- each tableA + return $ liftF2 (,) (sum (foo a)) (countDistinct (bar a)) + ``` + + This API seemed convenient, but has some significant shortcomings. The new API requires an explicit `Aggregator` be passed to `aggregate`: + + ```haskell + myQuery = aggregate (liftA2 (,) (sumOn foo) (countDistinctOn bar)) do + each tableA + ``` + + For more details, see [#235](https://github.com/circuithub/rel8/pull/235) diff --git a/changelog.d/20230707_185221_ollie_scriv.md b/changelog.d/20230707_185221_ollie_scriv.md new file mode 100644 index 0000000..e4052bd --- /dev/null +++ b/changelog.d/20230707_185221_ollie_scriv.md @@ -0,0 +1,3 @@ +### Fixed + +- A partial fix for nesting `catListTable`. The underlying issue in [#168](https://github.com/circuithub/rel8/issues/168) is still present, but we've made a bit of progress to reduce when this bug can happen. ([#243](https://github.com/circuithub/rel8/pull/243)) diff --git a/changelog.d/20230707_185339_ollie_scriv.md b/changelog.d/20230707_185339_ollie_scriv.md new file mode 100644 index 0000000..09afb65 --- /dev/null +++ b/changelog.d/20230707_185339_ollie_scriv.md @@ -0,0 +1,3 @@ +### Added + +- `Rel8.head`, `Rel8.headTable`, `Rel8.last`, `Rel8.lastExpr` for accessing the first/last elements of arrays and `ListTable`s. We have also added variants for non-empty arrays/`NonEmptyTable` with the `1` suffix (e.g., `head1`). ([#245](https://github.com/circuithub/rel8/pull/245)) diff --git a/changelog.d/20230707_185534_ollie_scriv.md b/changelog.d/20230707_185534_ollie_scriv.md new file mode 100644 index 0000000..8da4755 --- /dev/null +++ b/changelog.d/20230707_185534_ollie_scriv.md @@ -0,0 +1,39 @@ +### Added + +- Rel8 now has extensive support for `WITH` statements and data-modifying statements (https://www.postgresql.org/docs/current/queries-with.html#QUERIES-WITH-MODIFYING). + + This work offers a lot of new power to Rel8. One new possibility is "moving" rows between tables, for example to archive rows in one table into a log table: + + ```haskell + import Rel8 + + archive :: Statement () + archive = do + deleted <- + delete Delete + { from = mainTable + , using = pure () + , deleteWhere = \foo -> fooId foo ==. lit 123 + , returning = Returning id + } + + insert Insert + { into = archiveTable + , rows = deleted + , onConflict = DoNothing + , returning = NoReturninvg + } + ``` + + This `Statement` will compile to a single SQL statement - essentially: + + ```sql + WITH deleted_rows (DELETE FROM main_table WHERE id = 123 RETURNING *) + INSERT INTO archive_table SELECT * FROM deleted_rows + ``` + + This feature is a significant performant improvement, as it avoids an entire roundtrip. + + This change has necessitated a change to how a `SELECT` statement is ran: `select` now will now produce a `Rel8.Statement`, which you have to `run` to turn it into a Hasql `Statement`. Rel8 offers a variety of `run` functions depending on how many rows need to be returned - see the various family of `run` functions in Rel8's documentation for more. + + [#250](https://github.com/circuithub/rel8/pull/250) diff --git a/changelog.d/20230707_191301_ollie_scriv.md b/changelog.d/20230707_191301_ollie_scriv.md new file mode 100644 index 0000000..18c8b59 --- /dev/null +++ b/changelog.d/20230707_191301_ollie_scriv.md @@ -0,0 +1,3 @@ +### Added + +- - `Rel8.loop`, which allows writing `WITH .. RECURSIVE` queries. ([#180](https://github.com/circuithub/rel8/pull/180)) \ No newline at end of file diff --git a/changelog.d/scriv.ini b/changelog.d/scriv.ini new file mode 100644 index 0000000..94954cc --- /dev/null +++ b/changelog.d/scriv.ini @@ -0,0 +1,3 @@ +[scriv] +format = md +output_file = Changelog.md