rel8/docs
Shane 3c0b67f99e
Statements overhaul (support for statement-level WITH) (#250)
The motivation behind this PR is to add support for PostreSQL's `WITH` syntax at the statement level, which gives the ability to, e.g., delete some rows from a table and then re-insert those deleted rows into another table, without any round-trips between the application and the database.

To support this, this PR introduces a new type called `Statement`, which represents a single PostgreSQL statement. It has a `Monad` instance which allows sub-statements (such as `DELETE` and `INSERT` statements) to be composed together and their results bound to values that can be referenced in subsequent sub-statements. These "compound" statements are then rendered as a `WITH` statement.

`select`, `insert`, `update` and `delete` have all been altered to produce the `Statement` type described above instead of the `Hasql.Statement` type.

Some changes were necessary to the `Returning` type. `Returning` previously bundled two different concepts together: whether or not to generate a `RETURNING` clause in the SQL for a manipulation statement, and how to decode the returned rows (if any). It was necessary to break these concepts apart because with `WITH` we need the ability to generate manipulation statements with `RETURNING` clauses that are never actually decoded at all (the results just get passed to the next statement without touching the application).

Now, the `Returning` type is only concerned with whether or not to generate a `RETURNING` clause, and the question of how to decode the returned the result of the statement is handled by the `run` functions. `run` converts a `Statement` into a runnable `Hasql.Statement`, decoding the result of the statement as a list of rows. The other variations, `run_`, `runN`, `run1`, `runMaybe` and `runVector` can be used when you want to decode as something other than a list of rows.

This also gains us support for decoding the result of a query directly to a `Vector` for the first time, which brings a performance improvement over lists for those who need it.
2023-07-07 11:29:15 +01:00
..
concepts Statements overhaul (support for statement-level WITH) (#250) 2023-07-07 11:29:15 +01:00
conf.py Trying to sort out the nav bar 2021-04-03 17:00:58 +01:00
cookbook.rst Update cookbook to use some over listAgg (#154) 2022-03-12 11:48:45 +00:00
index.rst Document INSERT/UPDATE/DELETE (#75) 2021-06-29 12:44:20 +00:00
Makefile Move getting start guide back to Read the Docs 2021-04-01 21:42:52 +01:00
requirements.txt Bump sphinx 2021-04-05 16:41:21 +01:00
tutorial.rst Expand on select needing a connection 2021-06-21 11:38:10 +01:00