Commit Graph

14 Commits

Author SHA1 Message Date
Ollie Charles
15ae3c5bb7 Drop some coverage conditions from tests
These are just making tests flaky. For now, they are removed. In the
future we should make these tests more likely to have full coverage.

Fixes #86.
2021-06-29 14:44:40 +01:00
Ollie Charles
bf193950ab
Require Opaleye >= 0.7.3 (#81)
0.7.3 has important changes to where lateral joins are introduced, and fixes #72.
2021-06-28 17:33:55 +01:00
Shane O'Brien
bac704ce01
Fix catListTable and friends
The implemtation before would produce incorrect results if tried to get the cartesian product of two queries built out of `unnest`. Which makes sense, because Postgres seems to special case products of `unnest` to have a `ZipList` semantics rather than the normal `[]`.

The solution is to use `rebind` (from `Rel8.Query.Evaluate`) to rebind the results of such queries, so there is no `unnest` in the expressions we're `<*>`ing.
2021-06-22 11:54:35 +01:00
Shane O'Brien
d63063940d
Simplify eval to run directly inside the Query monad
@tomjaguarpaw at ZuriHac questioned whether the `Evaluation` monad was really unnecessary.

And yes, it turns out that the `Evaluation` monad wasn't actually really adding any value. The real issue was Postgres's unspecified evaluation order (which in practice behaved like the broken `ListT` from transformers).

We now maintain a stack of bindings from previous subselects in the `Query` monad, which future queries can reference. So for `evalulation`, to ensure that Postgres doesn't try to run a function once where we expect it to be run multiple times, we modify the expression to contain a bunch of superfluous lateral references to the previous queries. This ensures that it gets run every time.
2021-06-22 11:50:34 +01:00
Ollie Charles
ef272c4a45 Fix tests 2021-06-18 09:47:32 +01:00
Shane O'Brien
a3b32bde12
unnest support 2021-06-14 18:34:45 +01:00
Shane O'Brien
04fdf2732d
Make Rel8able have kind ((X -> Type) -> Type) -> Constraint
Previous it was `((Type -> Type) -> Type) -> Constraint`. The problem is this clashes with things like `HKD` from `higgledy`. We can use GADTs and PolyKinds hacks to get around this while mostly retaining the same API. The only major difference is we use `Result` in places where we used `Identity` before.
2021-04-15 17:00:12 +01:00
Shane O'Brien
f1e287ea9f
Rename all the null things 2021-04-07 22:35:40 +01:00
Shane O'Brien
0b34a1425e
Clean up Serializable and introduce litTable
Also teach Sql to be smart enough to know that if you have a `DBType a`, then you can always make an `Sql DBType a` from that. This, along with the `lit`/`Serializable` fixes, lets us remove a lot of nonsense constraints from the test suite.
2021-03-25 05:03:58 +00:00
Ollie Charles
05564f4851 Only export Rel8 2021-03-24 13:04:21 +00:00
Ollie Charles
b95592efe1 Flip the argument order for statements
Connection first is much easier to work with, especially when running
queries in the REPL.
2021-03-24 09:34:09 +00:00
Shane O'Brien
9b5abf299f Use data family for HTable contexts 2021-03-24 02:14:38 +00:00
Shane O'Brien
e891d517c0 Restore test suite 2021-03-23 18:16:33 +00:00
Shane O'Brien
6360f10fb7 The beginning of rel8 1.0
Co-authored-by: Ollie Charles <ollie@ocharles.org.uk>
2021-03-23 13:34:02 +00:00