⚠️ BREAKING CHANGE: This change is a security fix that patches a serious SQL injection vulnerability, however it is possible that your application made use of it and broke as a result of this change. Please see this issue for more information.
GroupedCountResultItem
interface (#14154) (a81b7ab)Model.update
(#14155) (b80aeed)count
and findAndCountAll
(#13786) (cf27c66)$nested.syntax$
in WhereAttributeHash (#13983) (f72bb1e)Sequelize.where
(#14018) (308ace0)Sequelize#query
method (#13881) (4c8fa9a)InferAttributes
utility type (#13909) (7eff04a)count
and findAndCountAll
(#13786) (b06c1fc)isIn
validator (#12962) (d511d91)findCreateFind
to work with postgres transactions (#13482) (84421d7)subQuery
to false
(#13490) (0943339)Transactionable
compatible with TransactionOptions
(#13334) (cd2de40)ARRAY(ENUM)
(#13210) (1cfbd33)ignoreDuplicates
option (#13220) (b33d78e)schema
for queryInterface methods (#13223) (6b0b532)returning
can specify column names (#13215) (143cc84)ON CONFLICT
with unique index (#13345) (6dcb565)AND
in sql for not
/between
(#13043) (a663c54)(keyof TAttributes)[]
in UpdateOptions.returning
(#13130) (97ba242)string
from Order
type (#13057) (ac39f8a)Sequelize v6 is the next major release after v5. Below is a list of breaking changes to help you upgrade.
Breaking Changes Support for Node 10 and upSequelize v6 will only support Node 10 and up #10821.
CLSYou should now use cls-hooked package for CLS support.
const cls = require('cls-hooked');
const namespace = cls.createNamespace('....');
const Sequelize = require('sequelize');
Sequelize.useCLS(namespace);
Database Engine Support
We have updated our minimum supported database engine versions. Using older database engine will show SEQUELIZE0006
deprecation warning. Please check ENGINE.md for version table.
Sequelize.Promise
is no longer available.sequelize.import
method has been removed.options.returning
Option returning: true
will no longer return attributes that are not defined in the model. Old behavior can be achieved by using returning: ['*']
instead.
Model.changed()
This method now tests for equality with _.isEqual
and is now deep aware for JSON objects. Modifying a nested value for a JSON object won't mark it as changed (since it is still the same object).
const instance = await MyModel.findOne();
instance.myJsonField.someProperty = 12345; // Changed from something else to 12345
console.log(instance.changed()); // false
await instance.save(); // this will not save anything
instance.changed('myJsonField', true);
console.log(instance.changed()); // ['myJsonField']
await instance.save(); // will save
Model.bulkCreate()
This method now throws Sequelize.AggregateError
instead of Bluebird.AggregateError
. All errors are now exposed as errors
key.
Model.upsert()
Native upsert is now supported for all dialects.
const [instance, created] = await MyModel.upsert({});
Signature for this method has been changed to Promise<Model,boolean | null>
. First index contains upserted instance
, second index contains a boolean (or null
) indicating if record was created or updated. For SQLite/Postgres, created
value will always be null
.
Note for Postgres users: If upsert payload contains PK field, then PK will be used as the conflict target. Otherwise first unique constraint will be selected as the conflict key.
QueryInterfaceaddConstraint
This method now only takes 2 parameters, tableName
and options
. Previously the second parameter could be a list of column names to apply the constraint to, this list must now be passed as options.fields
property.
queryInterface.addIndex
#11844plain
option in sequelize.query
#11596comparator
arg of Sequelize.where
#11843hooks
to CreateOptions
#11736options.storage
#11853idle_in_transaction_session_timeout
connection option #11775