Commit Graph

21 Commits

Author SHA1 Message Date
Shane
3cc8099037
Expose unsafeUnnullify and unsafeUnnullifyTable (#343) 2024-09-18 12:48:29 +01:00
Teo Camarasu
b86e397e70
Support ghc-9.10 (#340) 2024-08-23 10:17:45 +01:00
Shane
149ec23c6f
Add aggregate{Just,Left,Right,This,That,Those,Here,There}Table{,1} aggregators (#333)
These provide another way to do aggregation of `MaybeTable`, `EitherTable` and `TheseTable`s than the existing `aggregate{Maybe,Either,These}Table`.
2024-07-15 11:54:22 +01:00
Ollie Charles
4c184471d1
Release 1.5.0.0 (#298) 2024-03-19 14:48:26 +00:00
Shane
2cbf663f59
Switch to WITH _ AS MATERIALIZED (_) for materialize (#284) 2024-01-09 01:31:36 +00:00
Shane
b5789a692e
Add ability to use custom aggregation functions with aggregateFunction (#283) 2024-01-09 01:28:04 +00:00
Shane
2d9b6abc74
Add ordered set aggregation functions (#282) 2024-01-08 21:28:04 +00:00
Shane
9fb416607d
Add index and index1 for indexing arrays (ListTable and NonEmptyTable) (#285) 2023-10-19 18:40:07 +01:00
Shane
d0ba116149
Change window functions to operate on tables rather than columns (#281) 2023-10-07 12:11:29 +00:00
Shane
7636a86fb3
Add DBType instance for Fixed (#280)
This resolves issue #218.
2023-10-06 16:15:35 +01:00
Shane
7eec1f85ee
Add loopDistinct (#277) 2023-10-02 18:33:31 +00:00
Shane
0ebb70f95f
Add array concenation aggregators (#270) 2023-09-27 10:41:27 +00:00
Shane
10eab21d3a
Support nested catListTable (by represented nested arrays as text) (#242)
This is one possible "fix" to #168. With this we can `catListTable` arbitrarily deep trees of `ListTable`s.

It comes at a relatively high cost, however.

Currently we represent nested arrays with anonymous records. This works reasonably well, except that we can't extract the field from the anonymous record when we need it (PostgreSQL [theoretically](https://www.postgresql.org/docs/13/release-13.html#id-1.11.6.16.5.6) suports `.f1` syntax since PG13 but it only works in very limited situations). But it does mean we can decode the results using Hasql's binary decoders, and ordering works how we expect ('array[row(array[9])] < array[row(array[10])]'.

What this PR does is instead represent nested arrays as text. To be able to decode this, we need each 'DBType' to supply a text parser in addition to a binary decoder. It also means that ordering is no longer intuitive, because `array[array[9]::text] > array[array[10]::text]`. However, it does mean we can nest `catListTable`s to our heart's content and it will always just work.
2023-09-27 11:39:04 +01:00
Shane
9e7a44757c
Add length{,1} functions for getting the length of {List,NonEmpty}Tables (#268) 2023-08-15 18:09:13 +00:00
Shane
0e24745497
Allow partial indexes as upsert conflict targets (#264) 2023-08-01 15:00:05 +01:00
Shane
c06bd5f2f1
Expand use of QualifiedName to types, composites, enums (#263)
Types in PostgreSQL can also be qualified with a schema. However, it's not sufficient to just change the type of `TypeInformation`'s `typeName` to `QualifiedName`, because a type isn't *just* a name. Postgres types can also be parameterised by modifiers (e.g., `numeric(7, 2)`) and array types of arbitrary depth (e.g., `int4[][]`).

To accomodate this, a new type is introduced, `TypeName`. Like `QualifiedName`, it has an `IsString` instance, so the common case (`schema` set to `Nothing`, no modifiers, scalar type) will continue working as before.
2023-07-23 17:12:02 +01:00
Shane
7ec674d2a8
Make binaryOperator take a QualifiedName instead of a String (#262) 2023-07-15 16:24:36 +01:00
Shane
9f372dc649
Support selecting from table-returning functions with queryFunction (#241)
This fixes #71.
2023-07-11 14:32:24 +01:00
Shane
bf63d70ff3
Unify function and nullaryFunction (#258)
This does away with the weird variadic arguments thing we had going on with `function`.

Functions with no arguments are now written as:

```haskell
now :: Expr UTCTime
now = function "now" ()
```

Functions with multiple arguments are now written as:

```haskell
quot :: Sql DBIntegral a => Expr a -> Expr a -> Expr a
quot n d = function "div" (n, d)
```

Single-argument functions are written exactly as before.
2023-07-11 14:05:02 +01:00
Shane
c778ac1763
Introduce QualifiedName (fixes #228) (#257)
This adds a new type `QualifiedName` for named PostgreSQL objects (tables, views, functions and sequences) that can optionally be qualified by a schema. Previously only `TableSchema` could be qualified in this way.

`QualifiedName` has an `IsString` instance so the common case (where the schema is `Nothing`) doesn't have to care about schemas (if `OverloadedStrings` is enabled).

This also refactors `TableSchema` to use `QualifiedName` for its `name` field and drops its `schema` field.

Thanks to @elldritch for the bug report and the inspiration.
2023-07-11 12:06:36 +00:00
Ollie Charles
8cec776fa6
Set up scriv and add pending changelog entries (#255) 2023-07-11 11:49:53 +00:00