hasura / hasura/graphql-engine

Handle multiple constraint violations on upsert

Open
#4,163 5 comments 43 reactions 1 assignee Claimed by @0x777 View on GitHub
a/api k/question
Dominant language
TypeScript
Stars
32.1k
Forks
3k
PR merge metrics
PR metrics pending

Description

`graphql-engine: hasura/graphql-engine:v1.1.0.cli-migrations`

How can I go about handling multiple constraint violations?

Say I have two constraints, `[my_first_constraint, my_second_constraint]`

```
on_conflict: {
constraint: my_first_constraint,
update_columns: [updated_at]
}
```

Works for `my_first_constraint` violations, but then errors out when `my_second_constraint` conflicts during an upsert.

I know Postgres doesn't handle multiple constraints, but is there a way to do something like this;

```
on_conflict: {
constraint: null,
update_columns: [updated_at]
}
```

And specify that regardless of the violation, just update `updated_at`? I'm updating the column because I want the row to be returned.

How do I specify an update action regardless of constraint target?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.