static/v3/changelog/index.html
changeColumn generates incorrect query with ENUM type #7456ARRAY(ENUM) support for Postgres #8703previous method gave wrong value back #7189sourceKey FOR hasMany now also works if a where was specified in an include #7141node-uuid package to uuid #7148VIRTUAL field throw ER_EMPTY_QUERY #6356removeColumn method to support dropping primaryKey column (MSSQL) #7081sourceKey for hasMany relationships #4258afterConnect hooktimestamps and paranoid options from through model on belongsToMany associationgroupedLimit.on association is paranoidrestore now uses field from deletedAtoption.silent for increment and decrement #6793order option value was provided as plain string (not as an array value)typeValidation #6453parent, original and sql properties to UniqueConstraintErrorrestartIdentity option for truncate in postgres #5356Model.count don't include attributes #5057GEOMETRY and GEOGRAPHY SQL injection attacks #6194setAssociation twice on hasOne #5315Utils.mergeDeep - allows lodash to be updated to latest versionbeforeCount hook #5209validationFailed hook #1626addColumn with reference in mysql #5592findAndCountAll generates invalid SQL, subQuery moves to LEFT OUTER JOIN #5445count methods pollute the options.includes #4191unique: true when type: 'UNIQUE'. Fixes #5351updatedAt and createdAt values are now set before validation #5367describeTable maintains proper enum casing in mysql #5321.field (internal API change for queryInterface.upsert) #4755defaultScope is now an empty object. This fixes calling .scope('defaultScope') when no scope is explicitly defined, see #5277retry object now part of global settings and can be overridden per call. The default is 5 retries with a backoff function. retry object can be passed to options with max: 0 to turn off this behavior.IF EXIST to postgres alter enum #4464where fails on JSONB data #5092fieldoptions.include #5106aggregateseparate include now work properly #5080$col keys. #4849aggregate #4764onDelete option to allow the use of onDelete: 'CASCADE', hooks: true.count #4566separate. #4740.scoped, to prevent injection of default scope on includes #4663.previous now returns and object of previous values when called without key. This brings the API in line with .changed$model.field$, refactored to now require $col: 'model.field'include.on.typeValidation flag.attributes when including a scoped model. #4625field #3787[INTERNALS] Updated dependencies #4594
[INTERNALS] Updated devDependencies #4594
[FIXED] Add limit to findOne when using queries like { id: { $gt ... #4416
[FIXED] Include all with scopes #4584
[INTERNALS] Corrected spelling seperate -> separate
[ADDED] Added include and exclude to options.attributes. #4074
[FIXED/INTERNALS] Only recurse on plain objects in mapOptionFieldNames. #4596
search_path for postgres with lots of schemas #4534Sequelize.AssociationbulkCreate now has isNewRecord: false and should be updateable if using returning: true with dialects that support it.mapToModel or returning #3995skip now supports filtering out modewl validators #4528options has been renamed to $options in instance.js #4429targetKey for belongsTo on a target with a primary key will now correctly create foreign key constraints #4455version on Sequelize returning the current npm/package.json version #4459attributes #4420sequelize.where would fail #4334id is added, but not marked as primary key, and no other pk is present. #4139[ADDED] Model.findCreateFind: A more performant findOrCreate that will not work under a transaction (atleast not in postgres)
[FIXED] Show indexes query on Postgres fails to return functional indexes #3911
[FIXED] Custom field names in json queries
[FIXED] JSON cast key using the equality operator. #3824
[FIXED] Map column names with .field in scopes with includes. #4210
[FIXED] addScope when the model does not have any initial scopes #4243
[FIXED] Fixed destroy with limit in PG when the primary key is aliassed #4027
[FIXED] Clone the options object in increment, decrement, destroy, reload, restore, and save. #4023
[FIXED] Throw a Sequelize.Error when authenticate fails #4209
[FIXED] BTM would remove any previously added association getters #4268
[FIXED] Pass through connection mode options to sqlite #4288
[INTERNALS] Updated dependencies #4332
[INTERNALS] Updated devDependencies #4336
include.separate with include.limit support for HasMany associations.validate function from the corresponding datatype, but know that this permanently disables the validation.describeTable now marks the primary key (Reroll of #3703)addScope #3963conformOptions on default scope #4157conformOptions on scopes returned by functions #3991validateIncludedElements should not add an aliassed primary key multiple times #4127runInContext #2281countAssociations - ambigious id when through model has idcountAssociations for hasMany and belongsToManyfindAndCountAll with required includes #4016removeAttributes(id) not setting this.primaryKeys to nullbelongsToManyattributes support for 'reload' #3976Promise#nodeify() and Promise#done() not passing CLS contexttargetKey in a belongs-to relationship for situations where the target key is not the id field.after in options of a field (useful for migrations), only for MySQL. #3166type in sequelize.query was not being set to raw. #3800options.logging was not used correctly #3834Model#destroy() to correctly use options.transactionQueryInterface#showIndex() to correctly pass on options.transactiondeferrable to the references object of a field.include.attributes = [] will no longer force the inclusion of the primary key, making it possible to write aggregates with includes.references property of model attributes has been transformed to an object: {type: Sequelize.INTEGER, references: { model: SomeModel, key: 'some_key' }}. The former format (references and referecesKey) still exists but is deprecated and will be removed in 4.0.3.0.0 cleans up a lot of deprecated code, making it easier for us to develop and maintain features in the future.
through argument.as argument or the target model name pluralized.options.fields instead.sql and options as arguments, the second and fourth argument callee and replacements have been removed and should be set via options.instance / options.model and options.replacements instead.instance.isDirty has been removed, use instance.changed() insteadinstance.values has been removed, use instance.get() insteadinstance.primaryKeyValues has been removed.instance.identifiers has been removed, use instance.where() insteadinstance.isDeleted has been removed, simply check the timestamp with get('deletedAt') insteadinstance.increment/decrement now longer takes a number as it's second argument.where: "raw query" is no longer legal, you must now explicitely use where: ["raw query", [replacements]]instance.changed() would always be false #3727Model.create()/update() no longer attempts to save undefined fields.OF tableFOR KEY SHARE and NO KEY UPDATE for Postgres 9.3+logging: fn in the query option.index.where.changed() now works proactively by setting a flag on set instead of matching reactively. Note that objects and arrays will not be checked for equality on set and will always result in a change if they are set..on('success') or .success() is no longer supported. Try using .then() instead.[BUG] Don't update virtual attributes in Model.update. Fixes #2860
[BUG] Fix for newlines in hstore #3383
[BUG] Fix unique key handling in Model.update #3474
[BUG] Fix issue with Model.create() using fields not specifying and non-incremental primary key #3458
[FEATURE] field support for Model.update #3498
[INTERNALS] Updated dependencies. Most notably we are moving up one major version on lodash. If you are using sequelize.Utils._, notice that the semantics for many matching functions have changed to include a check for hasOwnProperty
[INTERNALS] Updated devDependencies.
Model.hasHook() if no hooks are defiend #3181{$and: []}{$in: []} would result in IN () rather than IN (NULL) #3105 #3132belongsToMany with foreignKey but no otherKey defined would result in 3 keys instead of 2. #2991where: sequelize.json() #3138field with $or/$and #3153DataTypes.ARRAY(DataTypes.STRING(length)) #3106.or([{key: value}, {key: value, key2: value}]) would result in 3 A OR B OR C rather than A OR (B AND C) #3107DataTypes.DECIMAL(10) resulting in 10, undefined #3119WHERE query on Model.update(values, {where: {}}) #3113include.wherefield support for increment and decrement.sequelize.query to use .spread instead of .then, unless you are passing a query type.field in upsertsequelize.query is now RAW - this means that two arguments (results and metadata) will be returned by default and you should use .spreadsequelize.query has been deprecated in favor of options.replacementssequelize.transaction(function() ....deletedAt with a custom field.where: []include.through.whereModel.destroy().order: sequelize.literal('string')clone: true support to .get(). Is needed when using delete on values from a .get() (toJSON(), this.values). (.get() is just a reference to the values for performance reasons when there's no custom getters or includes)sequelize.escape(value) convenience methodfindAll({include: [Model], order: sequelize.literal()})createdAt and updatedAt values to Model.create/Model.bulkCreate when using silent: true (when importing datasets with existing timestamps)instance.update() using default fields will now automatically also save and validate values provided via beforeUpdate hooksfieldDataTypes.ARRAY(DataTypes.JSON) attributeModel.bulkCreate([{}], {returning: true}) will now correctly result in instances with primary key values.instance.save() with fields: [] (as a result of .changed() being []) will no result in a noop instead of an empty update query.findOrCreate could return [null, true] when given a defaults value that triggered a unique constraint error.instance.update() using default fields will now automatically also save and validate values provided via beforeUpdate hookspg-hstore has been moved to a devDependency, Postgres users will have to install pg-hstore manually alongside pg: $ npm install pg pg-hstoreinclude.where and a paranoid main model.#2749/#2769.catch(ValidationError){save: false} for belongsTo relationship setters. user.setOrganization(organization, {save: false}) will then only set the foreign key value, but not trigger a save on user._previousDataValues will now be updated after afterUpdate hooks have been run rather than before allowing you to use changed in afterUpdatevar Owner = Company.belongsTo(User, {as: 'owner'}; Company.findOne({include: [Owner]});_previousDataValues will now be updated after afterUpdate hooks have been run rather than before allowing you to use changed in afterUpdateinflection dependency to v1.5.3Instance.update and how it behaves together with create, fields and more.include.where together with association.scopeInstance.destroy() and field for postgres.field named the same as the attribute in reload, bulkCreate and save #2348Model#destroy() now supports field, this also fixes an issue with N:M#removeAssociation and field{ in: [...] } were not properly converted to SQL when combined with a sequelize method (fn, where etc.). Closes #2077inflection dependency to v1.5.2node-sql, as well as the dependency on that moduleTask.find({include: Worker}) where the table name for through model TaskWorker is TableTaskWorkers used to produce { Worker: { ..., TableTaskWorker: {...} } }. It now produces { Worker: { ..., TaskWorker: {...} } }. Does not affect models where table name is auto-defined by Sequelize, or where table name is model name pluralized.Model#find() with an order clause, the table name is prepended to the ORDER BY SQL. e.g. ORDER BY Task.id rather than ORDER BY id. The change is to avoid ambiguous column names where there are eager-loaded associations with the same column names. A side effect is that code like Task.findAll( { include: [User], order: [[ 'Users.id', 'ASC'] ] } ) will now throw an error. This should be achieved with Task.findAll( { include: [User], order: [[ User, 'id', 'ASC'] ] } ) instead.where: { arr: [1, 2] } where the arr column is an array will now use strict comparison (=) instead of the overlap operator (&&). To obtain the old behaviour, use where: { arr: { overlap: [1, 2] }}fields for Instance#save (when not a new record) is now an intersection of the model attributes and the changed attributes making saves more atomic while still allowing only defined attributes.sequelize.where. Also added the option of specifying a comparatorfield supportfield and name to the object form of foreign key definitionsPromise.done, thus explicitly ending the promise chain by calling done with no arguments. Done with a function argument still continues the promise chain, to maintain BC.scope to hasMany association definitions, provides default values to association setters/finders #2268find() hooksfieldName property, used in associations with a foreign key object (A.hasMany(B, { foreignKey: { ... }}), has been renamed to name to avoid confusion with field.Model.beforeCreate(values) now need to be Model.beforeCreate(values, options) etc.Model.destroy() signature has been changed from (where, options) to (options), options now take a where parameter.Model.update() signature has been changed from (values, where, options) to (values, options), options now take a where parameter.Model.findOrBuild has changed, to be more in line with the rest of the library. Model.findOrBuild(where, defaults); becomes Model.findOrBuild({ where: where, defaults: defaults });.We are working our way to the first 2.0.0 release candidate.
[FEATURE] Added to option of setting a timezone offset in the sequelize constructor (timezone option). This timezone is used when initializing a connection (using SET TIME ZONE or equivalent), and when converting a timestamp string from the DB to a JS date with mysql (postgres stores the timezone, so for postgres we rely on what's in the DB).
[FEATURE] Allow setting plural and singular name on the model (options.name in sequelize.define) and in associations (options.as) to circumvent issues with weird pluralization.
[FEATURE] Added support for passing an indexes array in options to sequelize.define. #1485. See API reference for details.
[FEATURE/INTERNALS] Standardized the output from QueryInterface.showIndex.
[FEATURE] Include deleted rows in find #2083
[FEATURE] Make addSingular and addPlural for n:m associations (fx addUser and addUsers now both accept an array or an instance.
[BUG] Hid dottie.transform on raw queries behind a flag (nest) #2064
[BUG] Fixed problems with transaction parameter being removed / not passed on in associations #1789 and #1968
[BUG] Fix problem with minConnections. #2048
[BUG] Fix default scope being overwritten #2087
[BUG] Fixed updatedAt timestamp not being set in bulk create when validate = true. #1962
[INTERNALS] Replaced lingo with inflection
[INTERNALS] Removed underscore.string dependency and moved a couple of helper functions from Utils._ to Utils
[INTERNALS] Update dependencies
[INTERNALS] Use a transaction inside findOrCreate, and handle unique constraint errors if multiple calls are issues concurrently on the same transaction
We are using a new inflection library, which should make pluralization and singularization in general more robust. However, a couple of pluralizations have changed as a result:
Accesors for models with underscored names are no longer camel cased automatically. For example, if you have a model with name my_model, and my_other_model.hasMany(my_model), the getter will now be instance_of_my_model.getMy_model instead of .getMyModel.
Removed support for setting sequelize.language. If your model names are not in english, use the name option provided by sequelize.name to defined singular and plural forms for your model.
Model names are now used more verbatim in associations. This means that if you have a model named Task (plural T), or an association specifying { as: 'Task' }, the tasks will be returned as relatedModel.Tasks instead of relatedModel.tasks. For more information and how to mitigate this, see https://github.com/sequelize/sequelize/wiki/Upgrading-to-2.0#inflection-replaces-lingo-and-changes-to-naming-conventions
Removed the freezeAssociations option - use model and assocation names instead to provide the plural form yourself
Removed sequelize.language option (not supported by inflection)
Error handling has been refactored. Code that listens for :
get(path) method to find all broken validations for a path on an instance. To migrate existing error handling, switch from array indexing to using the get method:name: {type: DataTypes.STRING, field: 'full_name'}define() stores models in sequelize.models Object e.g. sequelize.models.MyModelset / add / has methods for associations now allow you to pass the value of a primary key, instead of a full Instance object, like so: user.addTask(15);.foreignKey option for associations to support a full data type definition, and not just a stringbulkDeleteQuery was removed from the MySQL / abstract query generator, since it was never used internally. Please use deleteQuery instead.findOrCreate or findOrInitialize). If your current callbacks do not accept the 2nd success parameter you might be seeing an array as the first param. Either use .spread() for these methods or add another argument to your callback: .success(instance) -> .success(instance, created)..success()/.done() and any other non promise methods are now deprecated (we will keep the codebase around for a few versions though). on('sql') persists for debugging purposes.QueryInterface no longer emits global events. This means you can no longer do things like QueryInterface.on('showAllSchemas', function ...sequelize.showAllSchemas now returns an array of schemas, instead of an array containinig an array of schemassequelize.transaction() now returns a promise rather than a instance of Sequelize.TransactionbulkCreate, bulkUpdate and bulkDestroy (and aliases) now take both a hooks and an individualHooks option, hooks defines whether or not to run the main hooks, and individualHooks defines whether to run hooks for each instance affected.M1.belongsTo(M2, { constraints: false})).set when underscored=true. janmeier #1523notNull validator has been removed, use the Schema's allowNull property.M1.hasMany(M2, { through: M3})) and sync the through model explicitly.ignoreDuplicates option for MySQL, SQLite and MariaDB that will use INSERT IGNOREattributes settings. (Motivation was to fix various issues with eager loading)skip as an option #1280sequelize --undo will now actually undo migrations. Its basically an alias for sequelize --migrate --undo. #1059{where: {ne: null}} would result in != NULL instead of IS NOT NULL #1231fields options. #1233field: {type: Sequelize.ENUM(value1, value2)} workserr, newValues). They only take the error argument since values can be changed directly on the model instance.None
db variable #900. thanks to xming<DAOFactory>.bulkCreate(), update (<DAOFactory>.update()) and delete (<DAOFactory>.destroy()) #569. thanks to optiludequeryOptions parameter to DAOFactory.find and DAOFactory.findAll. This allows a user to specify { raw: true }, meaning that the raw result should be returned, instead of built DAOs. Usefull for queries returning large datasets, see #611 janmeierfindOrCreate now returns an additional flag (created), that is true if a model was created, and false if it was found #648. janmeierfindAndCountAll, useful for pagination. #533. Thanks to iamjochenisDirty to model instances. #798. Thanks to mstorgaardimport method is now cached (thanks to janmeier/innofluence)complete function for each finder method (thanks to sstoiana)npm test will run the test suite (thanks to gabrielfalcao)fooTHIS UPDATE CHANGES TABLE STRUCTURES MASSIVELY!
MAKE SURE TO DROP YOUR CURRENT TABLES AND LET THEM CREATE AGAIN!
names of many-to-many-association-tables are chosen from passed association names
foreign keys are chosen from passed association name
added many-to-many association on the same model
added hasManyAndBelongsTo
added hasOneAndBelongsTo
nodejs-mysql-native 0.4.2