Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return conflicting rows on batch import #4072

Open
5 tasks done
zepatrik opened this issue Sep 2, 2024 · 0 comments
Open
5 tasks done

Return conflicting rows on batch import #4072

zepatrik opened this issue Sep 2, 2024 · 0 comments
Assignees
Labels
feat New feature or request.

Comments

@zepatrik
Copy link
Member

zepatrik commented Sep 2, 2024

Preflight checklist

Ory Network Project

No response

Describe your problem

The error you get from the batch import when one identity conflicts does not specify which one caused the conflict.

Describe your ideal solution

A list of identities that cannot be imported, optionally importing all others that do not conflict.

Workarounds or alternatives

Implementing a search on which identity/identities fails to import. This is a lot of unnecessary work.

Version

latest

Additional Context

POC:

create table t (i int primary key);

with
  -- define values
  v (i, external_id) as (values (1, '1x'), (2, '2x'), (3, '3x')),
  -- insert all non-conflicting values
  tt as (
    insert into t (i)
    (select i from v)
    on conflict do nothing
    returning i
  )
-- get all values including the external ID for identification, and see which ones were inserted
select v.i, v.external_id, tt.i is null as ignored_because_conflict
from v
left join tt on v.i = tt.i;
@zepatrik zepatrik added the feat New feature or request. label Sep 2, 2024
@hperl hperl self-assigned this Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat New feature or request.
Projects
None yet
Development

No branches or pull requests

2 participants