ent / ent/ent

How to upsert with required relation?

Open
#2,249 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Go
Stars
17.2k
Forks
1k
PR merge metrics
No merged PRs in 30d

Description

- [X] The issue is present in the latest release.
- [X] I have searched the [issues](https://github.com/ent/ent/issues) of this repository and believe that this is not a duplicate.

## Current Behavior 😯

Imagine a simple 1o1 connection. One API must have an Orangization. I can't [upsert](https://entgo.io/docs/crud#upsert-one) because the connection already exists and I can't omit the `.AddOrganizationIDs` method because it is required.

## Expected Behavior 🤔

Ent should detect that the relationship isn't affected and upsert the row.

## Steps to Reproduce 🕹

## Your Environment 🌎

| Tech | Version |
| ----------- | ------- |
| Go | 1.17.5 |
| Ent | 0.9.1 |
| Database | Postgres |
| Driver | github.com/jackc/pgx/v4 |

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.