bitemyapp / bitemyapp/esqueleto

Can't pass `SqlExpr (Entity e)` to functions

Open
#173 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Haskell
Stars
399
Forks
107
Avg merge
1d 17h
Merged PRs (30d)
1

Description

Consider this query:

```sql
SELECT JSONB_AGG(foo)
FROM foo
```

This gets all the `foo`s, converts them to JSON, and stuffs them in a list. We might try to write this as:

```haskell
jsonbAgg
:: SqlExpr (Entity a)
-> SqlExpr (Value [Entity a])
jsonbAgg = unsafeSqlFunction "jsonb_agg"
```

But this fails, because `unsafeSqlFunction` is written only for `Value`s. There's even a catch-all instance that forces a Value:

```haskell
instance (a ~ Value b) => UnsafeSqlFunctionArgument (SqlExpr a) where
toArgList = (:[]) . veryUnsafeCoerceSqlExprValue
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.