haskell-beam / haskell-beam/beam

onConflictUpdateSetWhere has wrong type?

Open
#644 3 comments 0 reactions 0 assignees View on GitHub
docs good first issue
Dominant language
Haskell
Stars
635
Forks
193
PR merge metrics
No merged PRs in 30d

Description

I noticed that this function's type is

```haskell
onConflictUpdateSetWhere :: Beamable table
=> (forall s. table (QField s) -> table (QExpr be s) -> QAssignment be s)
-> (forall s. table (QField s) -> table (QExpr be s) -> QExpr be s Bool)
-> SqlConflictAction be table
```

The first callback controls the assignments for the ON CONFLICT UPDATE clause, while the second callback controls the WHERE. It has two arguments,

* `table (QField s)` -- this represents the existing table
* `table (QExpr be s)` -- this represents the "excluded" row, i.e. the one that would have been inserted if there were no conflict.

I'm confused about the first argument. Shouldn't it be a `table (QExpr be s)` instead of `table (QField s)`? If the purpose is to use it to write a `QExpr be s Bool`, then it seems wrong for it to have this `QField` type (unless there's a conversion function I'm missing).

I'm also comparing it with functions like `conflictingFieldsWhere`, which also use the `table (QExpr be s)` type.

Please let me know if I'm missing something obvious :)

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.