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

Loosen INSERT UNLESS CONFLICT cannot be used on properties or links that have a rewrite rule specified #8305

Open
Gobot1234 opened this issue Feb 5, 2025 · 3 comments

Comments

@Gobot1234
Copy link
Contributor

Gobot1234 commented Feb 5, 2025

I have a rewrite on an email field that lowers them. This however is preventing me from using unless conflict.

e.insert(e.users.User, fetchUser()).unlessConflict(
    // if the user has a new ucard number e.g. they are a post grad researcher or re-registered, update their associated ucard
    (user) => ({
      on: user.email,
      else: e.update(user, () => ({
        set: {
          ucard_number: ldapLibraryToUcardNumber(ucard_number),
          username: ...,
          organisational_unit: ...,
        },
      })),
    }),
  ),
})

There is currently AFAICT no way to accomplish anything like this even using other features (insert ?? update or if exists then update else insert) as they seem to rewrite themselves to an unless conflict. I'm not really too fussed what changes here I just want to be able to do this in edgeql in one go compared to sending multiple queries and using app logic to do it.

Discord thread: https://discord.com/channels/841451783728529451/1309279819359584397

@msullivan
Copy link
Member

There is currently AFAICT no way to accomplish anything like this even using other features (insert ?? update or if exists then update else insert) as they seem to rewrite themselves to an unless conflict.

I don't think that is true? What messages are you getting.

@Gobot1234
Copy link
Contributor Author

I just checked this in the REPL and ?? chaining worked so maybe it was a client issue. Will report back

@Gobot1234
Copy link
Contributor Author

Gobot1234 commented Feb 9, 2025

Apologies @msullivan, ignore my previous comment, I was checking insert and select which works fine with ??
This is the error you get
Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants