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

Increment or Decrement value using Sequelize upsert() does not work in postgre #16929

Open
hegdd opened this issue Jan 5, 2024 · 1 comment
Labels
pending-approval Bug reports that have not been verified yet, or feature requests that have not been accepted yet type: bug

Comments

@hegdd
Copy link

hegdd commented Jan 5, 2024

Issue Description

In Sequelize with a postgre Database I am using upsert() to insert a new row if it doesn't exist or increment one of its field values by some other value if it exists.

It dose not work

    this.userBalanceModel.upsert({
      address: 'address',
      chainId: 'chainId',
      balance: literal(`balance + 1`) as any
    },{
      fields: ['balance'],
      conflictFields: ['address', 'chainId']
    })

I found a similar closed issue and it showed that it had been fixed in mysql, but I am still experiencing this similar issue in postgre
#12834

What is actually happening?

Environment

  • Sequelize version: v6.35.2
  • Node.js version: v18.16.0
@hegdd hegdd added pending-approval Bug reports that have not been verified yet, or feature requests that have not been accepted yet type: bug labels Jan 5, 2024
@ephys
Copy link
Member

ephys commented Feb 2, 2024

That PR landed in Sequelize 7, but you're on Sequelize 6. I'm not aware of this feature being available in Sequelize 6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending-approval Bug reports that have not been verified yet, or feature requests that have not been accepted yet type: bug
Projects
None yet
Development

No branches or pull requests

2 participants