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

insert one on conflict returns nothing #9224

Open
hahn-kev opened this issue Nov 18, 2022 · 0 comments
Open

insert one on conflict returns nothing #9224

hahn-kev opened this issue Nov 18, 2022 · 0 comments
Labels
k/bug Something isn't working

Comments

@hahn-kev
Copy link

Version Information

Server Version: v2.15.0

Environment

local docker dev env

What is the current behaviour?

I've got a query like this. It's a simple users table with an autogenerated id and a default role.

mutation insertIfNewUser($email: String!) {
    insertMseagFinanceUsersOne(
        object: {email: $email},
        onConflict: {
            constraint: users_email_key
        }
    ) {id role}
}

when I run this mutation it will insert a new user and it returns a response. But I don't get any response at all when the user already exists. Also it seems that the sequence is getting incremented even if a user is not created

What is the expected behavior?

I would like the above query to return results in case of a conflict. I would also like the sequence to not increment if there's no record inserted.

How to reproduce the issue?

  1. run the above query with a unique constraint on email
  2. get a result
  3. run it again, nothing is returned

Any possible solutions/workarounds you're aware of?

my workaround is to just query first and then don't run the insert if the user already exists.

@hahn-kev hahn-kev added the k/bug Something isn't working label Nov 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
k/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant