You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[docs] Does creating a new instance with the same primary key after a soft delete work? #9885
I can't tell from the docs what will happen if I soft delete instance 42 on a paranoid mode model, and then later create a new instance with that same key. Does Sequelize overwrite the fields on the soft deleted row and set deletedAt to null in that case, or does it throw a duplicate key error?
SequelizeUniqueConstraintError: ValidationerroratQuery.formatError(/var/www/github/sequelize/lib/dialects/postgres/query.js:326:18)atquery.catch.err(/var/www/github/sequelize/lib/dialects/postgres/query.js:86:18)Fromprevious event:
atQuery.run(/var/www/github/sequelize/lib/dialects/postgres/query.js:79:23)atPromise.try.then.connection(/var/www/github/sequelize/lib/sequelize.js:547:20)Fromprevious event:
atPromise.resolve.retryParameters(/var/www/github/sequelize/lib/sequelize.js:544:8)at/var/www/github/sequelize/node_modules/retry-as-promised/index.js:58:21atnewPromise(<anonymous>)
at retryAsPromised (/var/www/github/sequelize/node_modules/retry-as-promised/index.js:48:10)
at Sequelize.query (/var/www/github/sequelize/lib/sequelize.js:443:28)
at QueryInterface.insert (/var/www/github/sequelize/lib/query-interface.js:837:27)
at Promise.try.then.then.then (/var/www/github/sequelize/lib/model.js:3779:53)
at runCallback (timers.js:810:20)
at tryOnImmediate (timers.js:768:5)
at processImmediate [as _immediateCallback] (timers.js:745:5)
From previous event:
at model.save (/var/www/github/sequelize/lib/model.js:3755:8)
at Function.create (/var/www/github/sequelize/lib/model.js:2187:8)
at /var/www/github/sequelize/sscce.js:20:27
at <anonymous>
@sushantdhiman also, since the behavior wasn't documented, I couldn't assume that the actual behavior is the intended behavior and not a bug, which is why it's important to ask these kinds of questions
Activity
sushantdhiman commentedon Sep 13, 2018
Easy to test
jedwards1211 commentedon Sep 13, 2018
@sushantdhiman Yes, but the main issue is that we should document it.
jedwards1211 commentedon Sep 13, 2018
@sushantdhiman also, since the behavior wasn't documented, I couldn't assume that the actual behavior is the intended behavior and not a bug, which is why it's important to ask these kinds of questions