UNPKG

sequelize

Version:

Multi dialect ORM for Node.JS/io.js

609 lines (515 loc) 94 kB
# Future - [ADDED] Ability to run transactions on a read-replica by marking transactions as read only [#7323](https://github.com/sequelize/sequelize/issues/7323) - [FIXED] Add quotes around column names for unique constraints in sqlite [#4407](https://github.com/sequelize/sequelize/issues/4407) # 3.30.2 - [FIXED] `previous` method gave wrong value back [#7189](https://github.com/sequelize/sequelize/pull/7189) - [FIXED] Fixes setAssociation with scope [#7223](https://github.com/sequelize/sequelize/pull/7223) - [FIXED] Including a virtual field can give an empty query [#7164](https://github.com/sequelize/sequelize/pull/7164) - [FIXED] Fixes creation of polymorphic belongsToMany associations in one step #7159 [#7181](https://github.com/sequelize/sequelize/pull/7181) # 3.30.1 - [FIXED] `sourceKey` FOR `hasMany` now also works if a `where` was specified in an `include` [#7141](https://github.com/sequelize/sequelize/issues/7141) - [CHANGED] Updated deprecated `node-uuid` package to `uuid` [#7148](https://github.com/sequelize/sequelize/pull/7148) - [FIXED] Updating `VIRTUAL` field throw `ER_EMPTY_QUERY` [#6356](https://github.com/sequelize/sequelize/issues/6356) # 3.30.0 - [FIXED] `removeColumn` method to support dropping primaryKey column (MSSQL) [#7081](https://github.com/sequelize/sequelize/pull/7081) - [ADDED] Support `sourceKey` for `hasMany` relationships [#4258](https://github.com/sequelize/sequelize/issues/4258) # 3.29.0 - [FIXED] Transaction Name too long, transaction savepoints for SQL Server [#6972](https://github.com/sequelize/sequelize/pull/6972) # 3.28.0 - [FIXED] Soft-delete not returning number of affected rows on mssql [#6916](https://github.com/sequelize/sequelize/pull/6916) - [ADDED] `afterConnect` hook - [FIXED] Range integer parsing [#6897](https://github.com/sequelize/sequelize/pull/6897) - [FIXED] Upsert return value for mysql [#6963](https://github.com/sequelize/sequelize/pull/6963) # 3.27.0 - [FIXED] Incorrect column name for generateThroughJoin [#6878](https://github.com/sequelize/sequelize/pull/6878) - [ADDED] Support condition objects in utility functions [#6685](https://github.com/sequelize/sequelize/pull/6685) # 3.26.0 - [ADDED] Backport of mssql upsert [#6875](https://github.com/sequelize/sequelize/pull/6875) # 3.25.1 - [FIXED] fix instance.set '1970-01-01' to null field [#6839](https://github.com/sequelize/sequelize/pull/6839) - [FIXED] Can not execute raw SQL queries for sqlite3 [#6865](https://github.com/sequelize/sequelize/pull/6865) # 3.25.0 - [FIXED] Set `timestamps` and `paranoid` options from through model on `belongsToMany` association - [FIXED] Properly apply paranoid condition when `groupedLimit.on` association is `paranoid` - [FIXED] `restore` now uses `field` from `deletedAt` - [ADDED] `option.silent` for increment and decrement [#6793](https://github.com/sequelize/sequelize/pull/6793) # 3.24.7 - [FIXED] MSSQL bulkInsertQuery when options and attributes are not passed [#6782] # 3.24.6 - [FIXED] groupedLimit.through.where support # 3.24.5 - [FIXED] GroupedLimit when foreignKey has a field alias # 3.24.4 - [FIXED] - ORDER clause was not included in subquery if `order` option value was provided as plain string (not as an array value) - [FIXED] Issue with belongsTo association and foreign keys [#6400](https://github.com/sequelize/sequelize/issues/6400) - [FIXED] Check that parent exists before appending attributes [#6472](https://github.com/sequelize/sequelize/issues/6472) - [FIXED] Default options for insert queries [#6644](https://github.com/sequelize/sequelize/pull/6644) # 3.24.3 - [ADDED] Backport of grouped limit include support - [ADDED] Export datatypes [#6578](https://github.com/sequelize/sequelize/pull/6578) # 3.24.2 - [FIXED] Accept dates as string while using `typeValidation` [#6453](https://github.com/sequelize/sequelize/issues/6453) # 3.24.1 - [FIXED] Add `parent`, `original` and `sql` properties to `UniqueConstraintError` # 3.24.0 - [ADDED] `restartIdentity` option for truncate in postgres [#5356](https://github.com/sequelize/sequelize/issues/5356) # 3.23.5 # 3.23.4 - [FIXED] Fixed an issue where custom-named model fields break when offsetting, ordering, and including hasMany simultaneously. [#5985](https://github.com/sequelize/sequelize/issues/5985) - [FIXED] Don't remove includes from count queries and unify findAndCount and count queries. [#6123](https://github.com/sequelize/sequelize/issues/6123) - [FIXED] `Model.count` don't include attributes [#5057](https://github.com/sequelize/sequelize/issues/5057) - [SECURITY] `GEOMETRY` and `GEOGRAPHY` SQL injection attacks [#6194](https://github.com/sequelize/sequelize/issues/6194) # 3.23.3 - [FIXED] Pass ResourceLock instead of raw connection in MSSQL disconnect handling # 3.23.2 - [FIXED] Type validation now works with non-strings due to updated validator@5.0.0 [#5861](https://github.com/sequelize/sequelize/pull/5861) - [FIXED] Improved offset and limit support for SQL server 2008 [#5616](https://github.com/sequelize/sequelize/pull/5616) - [FIXED] options object cloned in all Sequelize methods (so not modified within Sequelize) # 3.23.1 - [FIXED] Postgres DECIMAL precision. (PostgreSQL) [#4893](https://github.com/sequelize/sequelize/issues/4893) - [FIXED] removeColumn tries to delete non-existant foreign key constraint (mysql) [#5808](https://github.com/sequelize/sequelize/issues/5808) - [FIXED] Relation constraints not being applied correctly [#5865](https://github.com/sequelize/sequelize/issues/5865) # 3.23.0 - [FIXED] Invalid query generated when using LIKE + ANY [#5736](https://github.com/sequelize/sequelize/issues/5736) - [FIXED] Method QueryInterface.bulkDelete no longer working when the model parameter is missing. (PostgreSQL) [#5615](https://github.com/sequelize/sequelize/issues/5615) - [ADDED] Context and custom options for deep creation - [FIXED] Dates with millisecond precision are inserted correctly in MySQL [#5855](https://github.com/sequelize/sequelize/pull/5855) # 3.22.0 - [FIXED] Fix defaultValues getting overwritten on build - [FIXED] Queue queries against tedious connections - [ADDED] Enable type validation for all queries # 3.21.0 - [FIXED] Confirmed that values modified in validation hooks are preserved [#3534](https://github.com/sequelize/sequelize/issues/3534) - [FIXED] Support lower case type names in SQLite [#5482](https://github.com/sequelize/sequelize/issues/5482) - [FIXED] Support calling `setAssociation` twice on `hasOne` [#5315](https://github.com/sequelize/sequelize/issues/5315) - [INTERNALS] Removed dependency on wellknown in favor of terraformer-wkt-parser - [ADDED] Benchmarking feature [#2494](https://github.com/sequelize/sequelize/issues/2494) - [INTERNALS] Add `Utils.mergeDeep` - allows lodash to be updated to latest version # 3.20.0 - [ADDED] rejectOnEmpty mode [#272](https://github.com/sequelize/sequelize/issues/272) [#5480](https://github.com/sequelize/sequelize/issues/5480) - [ADDED] `beforeCount` hook [#5209](https://github.com/sequelize/sequelize/pull/5209) - [ADDED] `validationFailed` hook [#1626](https://github.com/sequelize/sequelize/issues/1626) - [ADDED] Support for IEEE floating point literals in postgres and sqlite [#5194](https://github.com/sequelize/sequelize/issues/5194) - [FIXED] `addColumn` with reference in mysql [#5592](https://github.com/sequelize/sequelize/issues/5592) - [FIXED] `findAndCountAll` generates invalid SQL, subQuery moves to LEFT OUTER JOIN [#5445](https://github.com/sequelize/sequelize/issues/5445) - [FIXED] `count` methods pollute the options.includes [#4191](https://github.com/sequelize/sequelize/issues/4191) - [FIXED] Invalid SQL generated when using group option along with attributes [#3009](https://github.com/sequelize/sequelize/issues/3009) - [FIXED] Mark index as `unique: true` when `type: 'UNIQUE'`. Fixes [#5351](https://github.com/sequelize/sequelize/issues/5351) - [FIXED] Improper escaping of bound arrays of strings on Postgres, SQLite, and Microsoft SQL Server # 3.19.3 - [FIXED] `updatedAt` and `createdAt` values are now set before validation [#5367](https://github.com/sequelize/sequelize/pull/5367) - [FIXED] `describeTable` maintains proper enum casing in mysql [#5321](https://github.com/sequelize/sequelize/pull/5321) - [FIXED] Parsing of dates in MySQL, when a named timezone is used [#4208](https://github.com/sequelize/sequelize/issues/4208) - [FIXED] Truncating in Postgres, when table has a schema [#4306](https://github.com/sequelize/sequelize/issues/4306) - [FIXED] Moved initialization of scopes later in the model init process. Fixes attribute exclusion in scopes, [#4735](https://github.com/sequelize/sequelize/issues/4735) and [#4925](https://github.com/sequelize/sequelize/issues/4925) - [FIXED] Multiple custom unique validation messages being overwritten by the first-defined message, [#4920](https://github.com/sequelize/sequelize/issues/4920) # 3.19.0 - [ADDED] Geography support for postgres - [FIXED] Migrations failed to add foreign key [#966](https://github.com/sequelize/sequelize/issues/966) - [FIXED] Prevent race condition after transaction finished [#5222](https://github.com/sequelize/sequelize/issues/5222) - [FIXED] Fixed Instance.reload issues ([#4844](https://github.com/sequelize/sequelize/issues/4844) and [#4452](https://github.com/sequelize/sequelize/issues/4452)) - [FIXED] Fix upsert when primary key contains `.field` (internal API change for `queryInterface.upsert`) [#4755](https://github.com/sequelize/sequelize/issues/4755) - [FIXED] Default value for `defaultScope` is now an empty object. This fixes calling `.scope('defaultScope')` when no scope is explicitly defined, see [#5277](https://github.com/sequelize/sequelize/issues/5277) # 3.18.0 - [ADDED] Support silent: true in bulk update [#5200](https://github.com/sequelize/sequelize/issues/5200) - [ADDED] `retry` 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. - [ADDED] Sqlite now retries database queries that return SQL_BUSY as the status. - [ADDED] Add `IF EXIST` to postgres alter enum [#4464](https://github.com/sequelize/sequelize/pull/4464) - [FIXED] Postgres destroy with `where` fails on JSONB data [#5092](https://github.com/sequelize/sequelize/issues/5092) - [FIXED] hasMany.separate with foreign keys having `field` # 3.17.3 - [FIXED] Regression with array values from security fix in 3.17.2 # 3.17.2 - [SECURITY] Force non-buffer blob values to string, https://github.com/nodejs/node/issues/4660 # 3.17.1 - [FIXED] Reverted benchmarking feature since it does not compile on Node v4.0 # 3.17.0 - [SECURITY] Fixed injection vulnerability for order/limit - [FIXED] MySQL throws error when null GEOMETRY data results in empty buffer [#4953](https://github.com/sequelize/sequelize/issues/4953) # 3.16.0 - [ADDED] PostgreSQL tsrange (Range of timestamp without time zone) data type support. - [ADDED] hasOne scope support [#5113](https://github.com/sequelize/sequelize/pull/5113) - [FIXED] attributes from multiple scopes does not merge [#4856](https://github.com/sequelize/sequelize/issues/4856) - [FIXED] Support Unicode strings in mssql [#3752](https://github.com/sequelize/sequelize/issues/3752) - [FIXED] Do not inject include twice in `options.include` [#5106](https://github.com/sequelize/sequelize/pull/5106) - [FIXED] Expand and validate include in `aggregate` # 3.15.1 - [FIXED] calling Model.update() modifies passed values [#4520](https://github.com/sequelize/sequelize/issues/4520) - [FIXED] Instance can be chained on .set() and other methods [#4702](https://github.com/sequelize/sequelize/issues/4702) - [FIXED] includes nested from a `separate` include now work properly [#5080](https://github.com/sequelize/sequelize/pull/5080) # 3.15.0 - [ADDED] Improve support for pg range type to handle unbound ranges, +/-infinity bounds and empty ranges - [FIXED] Postgres issue when using named timezone [#4307](https://github.com/sequelize/sequelize/issues/4307) - [FIXED] Add support for Babel/ES6 imports [#4881](https://github.com/sequelize/sequelize/issues/4881) # 3.14.2 - [FIXED] Model.aggregate methods now support attributes and where conditions with fields. [#4935](https://github.com/sequelize/sequelize/issues/4935) - [FIXED] Don't overwrite options.foreignKey in associations [#4927](https://github.com/sequelize/sequelize/pull/4927) - [FIXED] Support nested `$col` keys. [#4849](https://github.com/sequelize/sequelize/issues/4849) # 3.14.1 - [FIXED] Issue with transaction options leaking and certain queries running outside of the transaction connection. # 3.14.0 - [FIXED] Apply scopes to `aggregate` [#4764](https://github.com/sequelize/sequelize/issues/4764) - [FIXED] Improved postgres enum schema handling [#4796](https://github.com/sequelize/sequelize/issues/4796) - [ADDED/FIXED] Lower case `onDelete` option to allow the use of `onDelete: 'CASCADE', hooks: true`. - [FIXED] Ignore attributes in `count` [#4566](https://github.com/sequelize/sequelize/issues/4566) # 3.13.0 - [FIXED] timestamp columns are no longer undefined for associations loaded with `separate`. [#4740](https://github.com/sequelize/sequelize/issues/4740) - [FIXED] Mark unscoped model as `.scoped`, to prevent injection of default scope on includes [#4663](https://github.com/sequelize/sequelize/issues/4663) - [ADDED] `.previous` now returns and object of previous values when called without `key`. This brings the API in line with `.changed` # 3.12.1 - [FIXED] Mark postgres connection as invalid if the connection is reset [#4661](https://github.com/sequelize/sequelize/pull/4661) - [FIXED] Remove usage of "limit" in cases where it's unnecessary, which fixes some of the cases mentioned in [#4404] (https://github.com/sequelize/sequelize/issues/4404) - [SECURITY] Security concern with `$model.field$`, refactored to now require `$col: 'model.field'` # 3.12.0 - [ADDED] Preliminary support for `include.on`. - [FIXED] Partial rollback of datatype validations by hiding it behind the `typeValidation` flag. - [FIXED] Don't try to select the primary key for models without primary key [#4607](https://github.com/sequelize/sequelize/issues/4607) - [FIXED] Apply `attributes` when including a scoped model. [#4625](https://github.com/sequelize/sequelize/issues/4625) - [FIXED] Use bits instead of strings for mssql booleans. [#4621](https://github.com/sequelize/sequelize/pull/4621) - [FIXED] BulkCreate validation fails for properties with `field` [#3787](https://github.com/sequelize/sequelize/issues/3787) # 3.11.0 - [INTERNALS] Updated dependencies [#4594](https://github.com/sequelize/sequelize/pull/4594) + bluebird@2.10.1 + dottie@1.0.0 + wellknown@0.4.0 - [INTERNALS] Updated devDependencies [#4594](https://github.com/sequelize/sequelize/pull/4594) + mysql@2.9.0 - coffee-script - [FIXED] Add limit to `findOne` when using queries like `{ id: { $gt ...` [#4416](https://github.com/sequelize/sequelize/issues/4416) - [FIXED] Include all with scopes [#4584](https://github.com/sequelize/sequelize/issues/4584) - [INTERNALS] Corrected spelling seperate -> separate - [ADDED] Added `include` and `exclude` to `options.attributes`. [#4074](https://github.com/sequelize/sequelize/issues/4074) - [FIXED/INTERNALS] Only recurse on plain objects in `mapOptionFieldNames`. [#4596](https://github.com/sequelize/sequelize/issues/4596) # 3.10.0 - [ADDED] support `search_path` for postgres with lots of schemas [#4534](https://github.com/sequelize/sequelize/pull/4534) - [ADDED] Expose Association constructor as `Sequelize.Association` - [ADDED] beforeSync/afterSync/beforeBulkSync/afterBulksync hooks [#4479](https://github.com/sequelize/sequelize/issues/4479) - [FIXED] Calling set with dot.separated key on a JSON/JSONB attribute will not flag the entire object as changed [#4379](https://github.com/sequelize/sequelize/pull/4379) - [FIXED] instances returned from `bulkCreate` now has `isNewRecord: false` and should be updateable if using `returning: true` with dialects that support it. - [FIXED] Find with Include with a where clause generates wrong SQL [#3940](https://github.com/sequelize/sequelize/issues/3940) - [FIXED] ON DELETE constraint should default to CASCADE if foreignKey has allowNull: false] [#2831](https://github.com/sequelize/sequelize/issues/2831) - [FIXED] sqlite file handle leak # 3.9.0 - [ADDED] beforeRestore/afterRestore hooks [#4371](https://github.com/sequelize/sequelize/issues/4371) - [ADDED] Map raw fields back to attributes names when using `mapToModel` or `returning` [#3995](https://github.com/sequelize/sequelize/pull/3995) - [ADDED] `skip` now supports filtering out modewl validators [#4528](https://github.com/sequelize/sequelize/pull/4528) - [INTERNALS] `options` has been renamed to `$options` in instance.js [#4429](https://github.com/sequelize/sequelize/pull/4429) - [FIXED] Reload doesn't synchronize a null include [#4353](https://github.com/sequelize/sequelize/issues/4353) - [FIXED] commit/rollback multiple times on same transaction [#4491](https://github.com/sequelize/sequelize/issues/4491) - [FIXED] memory leak / options mangle for scopes with include [#4470](https://github.com/sequelize/sequelize/issues/4470) - [FIXED] custom `targetKey` for belongsTo on a target with a primary key will now correctly create foreign key constraints [#4455](https://github.com/sequelize/sequelize/issues/4455) # 3.8.0 - [ADDED] `version` on `Sequelize` returning the current npm/package.json version [#4459](https://github.com/sequelize/sequelize/pull/4459) # 3.7.0 - [ADDED] Define field dependencies for VIRTUAL types that are automatically pulled into `attributes` [#4420](https://github.com/sequelize/sequelize/pull/4420) - [FIXED] Fall back to a default version when parsing the DB version fails [#4368](https://github.com/sequelize/sequelize/issues/4368) - [FIXED] Fix a bug where passing null as the second parameter to `sequelize.where` would fail [#4334](https://github.com/sequelize/sequelize/issues/4334) - [FIXED] An error is thrown if a column called `id` is added, but not marked as primary key, and no other pk is present. [#4139](https://github.com/sequelize/sequelize/issues/4139) - [FIXED] Cast to boolean when querying JSON [#4257](https://github.com/sequelize/sequelize/issues/4257) # 3.6.0 - [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](https://github.com/sequelize/sequelize/issues/3911) - [FIXED] Custom field names in json queries - [FIXED] JSON cast key using the equality operator. [#3824](https://github.com/sequelize/sequelize/issues/3824) - [FIXED] Map column names with `.field` in scopes with includes. [#4210](https://github.com/sequelize/sequelize/issues/4210) - [FIXED] `addScope` when the model does not have any initial scopes [#4243](https://github.com/sequelize/sequelize/issues/4243) - [FIXED] Fixed destroy with limit in PG when the primary key is aliassed [#4027](https://github.com/sequelize/sequelize/pull/4027) - [FIXED] Clone the options object in `increment`, `decrement`, `destroy`, `reload`, `restore`, and `save`. [#4023](https://github.com/sequelize/sequelize/pull/4023) - [FIXED] Throw a `Sequelize.Error` when `authenticate` fails [#4209](https://github.com/sequelize/sequelize/pull/4209) - [FIXED] BTM would remove any previously added association getters [#4268](https://github.com/sequelize/sequelize/pull/4268) - [FIXED] Pass through connection mode options to sqlite [#4288](https://github.com/sequelize/sequelize/issues/4288) - [INTERNALS] Updated dependencies [#4332](https://github.com/sequelize/sequelize/pull/4332) + toposort-class@1.0.1 + validator@4.0.4 + wkx@0.1.0 - [INTERNALS] Updated devDependencies [#4336](https://github.com/sequelize/sequelize/pull/4336) + chai-spies@0.7.0 + dox@0.8.0 + mysql@2.8.0 # 3.5.1 - [FIXED] Fix bug with nested includes where a middle include results in a null value which breaks $findSeparate. # 3.5.0 - [ADDED] `include.separate` with `include.limit` support for HasMany associations. - [ADDED] Added default validation based on attribute types. [#3472](https://github.com/sequelize/sequelize/pull/3472). The validation _cannot_ be disabled. If you really want to completely disable it, you can remove the `validate` function from the corresponding datatype, but know that this permanently disables the validation. - [ADDED] `describeTable` now marks the primary key (Reroll of [#3703](https://github.com/sequelize/sequelize/pull/3703)) - [ADDED] Automatically determine the version of the database upon first connection [#4192](https://github.com/sequelize/sequelize/pull/4192). This will be useful going forward in order to provide support for older database versions. - [ADDED] `addScope` [#3963](https://github.com/sequelize/sequelize/issues/3963) - [FIXED] Fix findOrCreate regression trying to add a transaction even if there is none - [FIXED] Fix save to be noop when nothing changed - [FIXED] Call `conformOptions` on default scope [#4157](https://github.com/sequelize/sequelize/issues/4157) - [FIXED] Call `conformOptions` on scopes returned by functions [#3991](https://github.com/sequelize/sequelize/issues/3991) - [FIXED] Calling `validateIncludedElements` should not add an aliassed primary key multiple times [#4127](https://github.com/sequelize/sequelize/issues/4127) - [FIXED] Handle scoped model in includes properly [#3700](https://github.com/sequelize/sequelize/issues/3700) - [FIXED] Enum naming with schemas [#3171](https://github.com/sequelize/sequelize/issues/3171) and [#3563](https://github.com/sequelize/sequelize/issues/3563) - [FIXED] Prevent polution of the lodash object by using `runInContext` [#2281](https://github.com/sequelize/sequelize/issues/2281) # 3.4.1 - [FIXED] Fix belongs-to-many `countAssociations` - ambigious id when through model has id # 3.4.0 - [ADDED] `countAssociations` for hasMany and belongsToMany - [ADDED] Geometry support for postgres - [FIXED] Fix wrong count for `findAndCountAll` with required includes [#4016](https://github.com/sequelize/sequelize/pull/4016) - [FIXED] Fix problems related to parsing of unique constraint errors [#4017](https://github.com/sequelize/sequelize/issues/4017) and [#4012](https://github.com/sequelize/sequelize/issues/4012) - [FIXED] Fix postgres path variable being surrounded by quotes to often in unique constraint errors [#4034](https://github.com/sequelize/sequelize/pull/4034) - [FIXED] Fix `removeAttributes(id)` not setting `this.primaryKeys` to null - [FIXED] Run validations on the through model during add, set and create for `belongsToMany` # 3.3.2 - [FIXED] upsert no longer updates with default values each time [#3994](https://github.com/sequelize/sequelize/pull/3994) # 3.3.1 - [FIXED] regression in `attributes` support for 'reload' [#3976](https://github.com/sequelize/sequelize/issues/3976) # 3.3.0 - [FIXED] Fix `Promise#nodeify()` and `Promise#done()` not passing CLS context - [FIXED] Creating and dropping enums in transaction, only for PostgreSQL [#3782](https://github.com/sequelize/sequelize/issues/3782) - [FIXED] $or/$and inside a where clause always expects the input to be an array [#3767](https://github.com/sequelize/sequelize/issues/3767) - [ADDED] Unique constraints may now include custom error messages - [ADDED] It's possible now to remove a hook by name - [ADDED] Hook name can be passed via the direct method [#3901](https://github.com/sequelize/sequelize/issues/3901) # 3.2.0 - [ADDED] Add support for new option `targetKey` in a belongs-to relationship for situations where the target key is not the id field. - [ADDED] Add support for keyword `after` in options of a field (useful for migrations), only for MySQL. [#3166](https://github.com/sequelize/sequelize/pull/3166) - [ADDED] There's a new sequelize.truncate function to truncate all tables defined through the sequelize models [#2671](https://github.com/sequelize/sequelize/pull/2671) - [ADDED] Add support for MySQLs TINYTEXT, MEDIUMTEXT and LONGTEXT. [#3836](https://github.com/sequelize/sequelize/pull/3836) - [ADDED] Provide warnings if you misuse data types. [#3839](https://github.com/sequelize/sequelize/pull/3839) - [FIXED] Fix a case where Postgres arrays containing JSONB type was being generated as JSON type. - [FIXED] Fix a case where `type` in `sequelize.query` was not being set to raw. [#3800](https://github.com/sequelize/sequelize/pull/3800) - [FIXED] Fix an issue where include all was not being properly expanded for self-references [#3804](https://github.com/sequelize/sequelize/issues/3804) - [FIXED] Fix instance.changed regression to not return false negatives for not changed null values [#3812](https://github.com/sequelize/sequelize/issues/3812) - [FIXED] Fix isEmail validator to allow args: true [#3770](https://github.com/sequelize/sequelize/issues/3770) - [FIXED] Fix all occasions where `options.logging` was not used correctly [#3834](https://github.com/sequelize/sequelize/issues/3834) - [FIXED] Fix `Model#destroy()` to correctly use `options.transaction` - [FIXED] Fix `QueryInterface#showIndex()` to correctly pass on `options.transaction` # 3.1.1 - [FIXED] Always quote aliases, even when quoteIdentifiers is false [#1589](https://github.com/sequelize/sequelize/issues/1589) - [FIXED] No longer clones Instances in model finder options - [FIXED] Fix regression in util.toDefaultValue not returning the data types [#3733](https://github.com/sequelize/sequelize/pull/3733) # 3.1.0 - [ADDED] It is now possible to defer constraints in PostgreSQL by added a property `deferrable` to the `references` object of a field. - [FIXED] Fix an issue with the build in isIP validator returning false negatives [#3756](https://github.com/sequelize/sequelize/pull/3756) # 3.0.1 - [FIXED] `include.attributes = []` will no longer force the inclusion of the primary key, making it possible to write aggregates with includes. - [CHANGED] The `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 3.0.0 cleans up a lot of deprecated code, making it easier for us to develop and maintain features in the future. - [ADDED] findById / findByPrimary takes a single value as argument representing the primary key to find. - [CHANGED] belongsToMany relations MUST now be given a `through` argument. - [CHANGED] findOne / findAll / findAndCount / findOrCreate now only takes a single options argument instead of a options and queryOptions argument. So set transaction, raw, etc on the first options argument. - [CHANGED] The accessor for belongsToMany relationships is now either the `as` argument or the target model name pluralized. - [REMOVED] N:M relationships can no longer be represented by 2 x hasMany - [REMOVED] Model.create / Model.bulkCreate / Instance.save no longer takes an array of fields as its second argument, use `options.fields` instead. - [REMOVED] Query Chainer has been removed - [REMOVED] Migrations have been removed, use umzug instead - [REMOVED] Model.findAllJoin has been removed - [REMOVED] sequelize.query now only takes `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. - [REMOVED] `instance.isDirty` has been removed, use `instance.changed()` instead - [REMOVED] `instance.values` has been removed, use `instance.get()` instead - [REMOVED] `instance.primaryKeyValues` has been removed. - [REMOVED] `instance.identifiers` has been removed, use `instance.where()` instead - [REMOVED] `instance.isDeleted` has been removed, simply check the timestamp with `get('deletedAt')` instead - [REMOVED] `instance.increment/decrement` now longer takes a number as it's second argument. - [REMOVED/SECURITY] findOne no longer takes a string / integer / binary argument to represent a primaryKey. Use findById instead - [REMOVED/SECURITY] `where: "raw query"` is no longer legal, you must now explicitely use `where: ["raw query", [replacements]]` - [FIXED] Fix showIndexQuery so appropriate indexes are returned when a schema is used - [FIXED] Fix addIndexQuery error when the model has a schema - [FIXED] Fix app crash in sqlite while running in special unique constraint errors [#3730](https://github.com/sequelize/sequelize/pull/3730) - [FIXED] Fix bulkCreate: do not insert NULL for undefined values [#3729](https://github.com/sequelize/sequelize/pull/3729) - [FIXED] Fix trying to roll back a comitted transaction if an error occured while comitting resulting in an unhandled rejection [#3726](https://github.com/sequelize/sequelize/pull/3726) - [FIXED] Fix regression in beforeUpdate hook where `instance.changed()` would always be false [#3727](https://github.com/sequelize/sequelize/pull/3727) - [FIXED] Fix trying to roll back a comitted transaction if an error occured while comitting #### Backwards compatibility changes - Most of the changes in 3.0.0 are BC breaking, read the changelog for 3.0.0 carefully. - The error that is thrown when a column is declared to be an enum but without any values used to "Values for ENUM haven't been defined" and is now "Values for ENUM have not been defined". # 2.1.3 - [BUG] Fix regression introduced in 2.1.2: updatedAt not set anymore [#3667](https://github.com/sequelize/sequelize/pull/3667) - [BUG] Fix managed transactions not rolling back if no thenable was provided in the transaction block [#3667](https://github.com/sequelize/sequelize/pull/3667) # 2.1.2 - [BUG] `Model.create()/update()` no longer attempts to save undefined fields. # 2.1.1 - [BUG] .get() now passes along options correctly when using a custom getter - [BUG] Fix managed transactions not rolling back if an error occured the transaction block [#3661](https://github.com/sequelize/sequelize/pull/3661) - [BUG] Fix a node-webkit issue [#3650](https://github.com/sequelize/sequelize/pull/3650) - [FEATURE] Lock modes in Postgres now support `OF table` - [FEATURE] New transaction lock modes `FOR KEY SHARE` and `NO KEY UPDATE` for Postgres 9.3+ - [FEATURE/REFACTOR] Rewritten scopes with complete support for includes and scopes across associations # 2.1.0 - [BUG] Enable standards conforming strings on connection in postgres. Adresses [#3545](https://github.com/sequelize/sequelize/issues/3545) - [BUG] instance.removeAssociation(s) do not fire the select query twice anymore - [BUG] Error messages thrown by the db in languages other than english do not crash the app anymore (mysql, mariadb and postgres only) [#3567](https://github.com/sequelize/sequelize/pull/3567) - [FEATURE] [JSONB](https://github.com/sequelize/sequelize/issues/3471) - [FEATURE] All querys can be logged individually by inserting `logging: fn` in the query option. - [FEATURE] Partial index support for Postgres with `index.where` - [REFACTOR] `.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`. - [DEPRECATED] The query-chainer is deprecated and will be removed in version 2.2. Please use promises instead. - [REMOVED] Events are no longer supported. - [INTERNALS] Updated dependencies. + bluebird@2.9.24 #### Backwards compatibility changes - Events support have been removed so using `.on('success')` or `.success()` is no longer supported. Try using `.then()` instead. - Trying to apply a scope that does not exist will always throw an error # 2.0.6 - [BUG] Don't update virtual attributes in Model.update. Fixes [#2860](https://github.com/sequelize/sequelize/issues/2860) - [BUG] Fix for newlines in hstore [#3383](https://github.com/sequelize/sequelize/issues/3383) - [BUG] Fix unique key handling in Model.update [#3474](https://github.com/sequelize/sequelize/issues/3474) - [BUG] Fix issue with Model.create() using fields not specifying and non-incremental primary key [#3458](https://github.com/sequelize/sequelize/issues/3458) - [FEATURE] `field` support for Model.update [#3498](https://github.com/sequelize/sequelize/pull/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` + dottie@0.3.1 + inflection@1.6.0 + lodash@3.5.0 + validator@3.34 + generic-pool@2.2.0 - [INTERNALS] Updated devDependencies. + coffee-script@1.9.1 + dox@0.7.1 + mysql@2.6.2 # 2.0.5 - [FEATURE] Highly experimental support for nested creation [#3386](https://github.com/sequelize/sequelize/pull/3386) # 2.0.4 - [BUG] Fixed support for 2 x belongsToMany without foreignKey defined and association getter/adder [#3185](https://github.com/sequelize/sequelize/issues/3185) - [BUG] No longer throws on `Model.hasHook()` if no hooks are defiend [#3181](https://github.com/sequelize/sequelize/issues/3181) - [BUG] Fixed issue with `{$and: []}` - [BUG] Fixed issue with N:M relations with primary keys with field defined # 2.0.3 - [BUG] Support for plain strings, ints and bools on JSON insert - [BUG] Fixed regression where `{$in: []}` would result in `IN ()` rather than `IN (NULL)` [#3105](https://github.com/sequelize/sequelize/issues/3105) [#3132](https://github.com/sequelize/sequelize/issues/3132) - [BUG] Fixed bug where 2 x `belongsToMany` with `foreignKey` but no `otherKey` defined would result in 3 keys instead of 2. [#2991](https://github.com/sequelize/sequelize/issues/2991) - [BUG] Fixed regression with `where: sequelize.json()` [#3138](https://github.com/sequelize/sequelize/issues/3138) - [BUG] Fixed support for `field` with `$or`/`$and` [#3153](https://github.com/sequelize/sequelize/issues/3153) # 2.0.2 - [BUG] Fixed regression with `DataTypes.ARRAY(DataTypes.STRING(length))` [#3106](https://github.com/sequelize/sequelize/issues/3106) - [BUG] Fixed regression where `.or([{key: value}, {key: value, key2: value}])` would result in 3 `A OR B OR C` rather than `A OR (B AND C)` [#3107](https://github.com/sequelize/sequelize/issues/3107) - [BUG] Fixed regression with `DataTypes.DECIMAL(10)` resulting in `10, undefined` [#3119](https://github.com/sequelize/sequelize/issues/3119) - [BUG] Fixed issue with dangling `WHERE ` query on `Model.update(values, {where: {}})` [#3113](https://github.com/sequelize/sequelize/issues/3113) # 2.0.1 - [BUG] Fixed issue with empty `include.where` - [BUG] Fixed issue with otherKey generation for self-association N:M # 2.0.0 - [BUG] Fixed `field` support for `increment` and `decrement`. - [FEATURE/BUG] Raw queries always return all results (including affected rows etc). This means you should change all promise listeners on `sequelize.query` to use `.spread` instead of `.then`, unless you are passing a query type. - [BUG] Support for composite primary keys in upsert [#3065](https://github.com/sequelize/sequelize/pull/3065) - [BUG] Support for `field` in upsert - [FEATURE] Support for setting an initial autoincrement option in mysql [#3076](https://github.com/sequelize/sequelize/pull/3076) - [FEATURE] Test coverage for Node.js 0.12 and io.js 1.x #### Backwards compatibility changes - The default query type for `sequelize.query` is now `RAW` - this means that two arguments (results and metadata) will be returned by default and you should use `.spread` - The 4th argument to `sequelize.query` has been deprecated in favor of `options.replacements` # 2.0.0-rc8 - [FEATURE] CLS Support. CLS is also used to automatically pass the transaction to any calls within the callback chain when using `sequelize.transaction(function() ...`. - [BUG] Fixed issue with paranoid deletes and `deletedAt` with a custom field. - [BUG] No longer crahes on `where: []` - [FEATURE] Validations are now enabled by default for upsert. - [FEATURE] Preliminary support for `include.through.where` - [SECURITY/BUG] Fixed injection issue in direction param for order # 2.0.0-rc7 - [FEATURE] Throw an error if no where clause is given to `Model.destroy()`. - [BUG] Fixed issue with `order: sequelize.literal('string')` - [FEATURE] add `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) - [FEATURE] add `sequelize.escape(value)` convenience method - [BUG] Fixes crash with `findAll({include: [Model], order: sequelize.literal()})` - [FEATURE] Now possible to pass `createdAt` and `updatedAt` values to `Model.create`/`Model.bulkCreate` when using silent: true (when importing datasets with existing timestamps) - [FEATURE] `instance.update()` using default fields will now automatically also save and validate values provided via `beforeUpdate` hooks - [BUG] Fixed bad SQL when updating a JSON attribute with a different `field` - [BUG] Fixed issue with creating and updating values of a `DataTypes.ARRAY(DataTypes.JSON)` attribute - [BUG] `Model.bulkCreate([{}], {returning: true})` will now correctly result in instances with primary key values. - [BUG] `instance.save()` with `fields: []` (as a result of `.changed()` being `[]`) will no result in a noop instead of an empty update query. - [BUG] Fixed case where `findOrCreate` could return `[null, true]` when given a `defaults` value that triggered a unique constraint error. #### Backwards compatibility changes - `instance.update()` using default fields will now automatically also save and validate values provided via `beforeUpdate` hooks - Sequelize no longer supports case insensitive mysql enums - `pg-hstore` has been moved to a devDependency, Postgres users will have to install `pg-hstore` manually alongside `pg`: `$ npm install pg pg-hstore` # 2.0.0-rc6 - [BUG] Fixed issue with including by association reference and where # 2.0.0-rc5 - [BUG] Fixed issue with subquery creating `include.where` and a paranoid main model.#2749/#2769 - UniqueConstraintErrors will now extend from ValidationError making it possible to catch both with `.catch(ValidationError)` - [FEATURE] Adds `{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`. - [FEATURE] When updating an instance `_previousDataValues` will now be updated after `afterUpdate` hooks have been run rather than before allowing you to use `changed` in `afterUpdate` - [BUG] Sequelize will no longer fail on a postgres constraint error not defined by Sequelize - [FEATURE] It's now possible to pass an association reference to include. `var Owner = Company.belongsTo(User, {as: 'owner'}; Company.findOne({include: [Owner]});` #### Backwards compatibility changes - When updating an instance `_previousDataValues` will now be updated after `afterUpdate` hooks have been run rather than before allowing you to use `changed` in `afterUpdate` # 2.0.0-rc4 - [INTERNALS] Update `inflection` dependency to v1.5.3 - [FEATURE] Replaced string error messages for connection errors with error objects. [#2576](https://github.com/sequelize/sequelize/pull/2576) - [FEATURE] Support for updating fields on duplicate key in bulk update (mysql only) [#2692](https://github.com/sequelize/sequelize/pull/2692) - [FEATURE] Basic support for Microsoft SQL Server - [INTERNALS] Deprecate migration logic. This is now implemented in [umzug](https://github.com/sequelize/umzug) and the [CLI](https://github.com/sequelize/cli). - [BUG] Fixed various inconsistencies with `Instance.update` and how it behaves together with `create`, `fields` and more. - [BUG] Fixed crash/bug when using `include.where` together with `association.scope` - [BUG] Fixed support for `Instance.destroy()` and `field` for postgres. #### Backwards compatibility changes - Some of the string error messages for connection errors have been replaced with actual error instances. Checking for connection errors should now be more consistent. # 2.0.0-rc3 - [FEATURE] Added the possibility of removing multiple associations in 1 call [#2338](https://github.com/sequelize/sequelize/issues/2338) - [FEATURE] Undestroy method for paranoid models [#2540](https://github.com/sequelize/sequelize/pull/2540) - [FEATURE] Support for UPSERT - [BUG] Add support for `field` named the same as the attribute in `reload`, `bulkCreate` and `save` [#2348](https://github.com/sequelize/sequelize/issues/2348) - [BUG] Copy the options object in association getters. [#2311](https://github.com/sequelize/sequelize/issues/2311) - [BUG] `Model#destroy()` now supports `field`, this also fixes an issue with `N:M#removeAssociation` and `field` - [BUG] Customized error message can now be set for unique constraint that was created manually (not with sync, but e.g. with migrations) or that has fields with underscore naming. This was problem at least with postgres before. - [BUG] Fixed a bug where plain objects like `{ in: [...] }` were not properly converted to SQL when combined with a sequelize method (`fn`, `where` etc.). Closes [#2077](https://github.com/sequelize/sequelize/issues/2077) - [BUG] Made the default for array search in postgres exact comparison instead of overlap - [BUG] Allow logging from individual functions even though the global logging setting is false. Closes [#2571](https://github.com/sequelize/sequelize/issues/2571) - [BUG] Allow increment/decrement operations when using schemata - [BUG] Allow createTable with schema - [BUG] Fix some issues with findAndCount and include - [INTERNALS] Update `inflection` dependency to v1.5.2 - [REMOVED] Remove query generation syntactic sugar provided by `node-sql`, as well as the dependency on that module #### Backwards compatibility changes - When eager-loading a many-to-many association, the attributes of the through table are now accessible through an attribute named after the through model rather than the through table name singularized. i.e. `Task.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. - When using `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. - Nested HSTORE objects are no longer supported. Use DataTypes.JSON instead. - In PG `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] }}` - The default `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. - Syntactic sugar for query generation was removed. You will no longer be able to call Model.dataset() to generate raw sql queries # 2.0.0-rc2 - [FEATURE] Added to posibility of using a sequelize object as key in `sequelize.where`. Also added the option of specifying a comparator - [FEATURE] Added countercache functionality to hasMany associations [#2375](https://github.com/sequelize/sequelize/pull/2375) - [FEATURE] Basic JSON support [#2314](https://github.com/sequelize/sequelize/pull/2314) - [BUG] Fixes regression bug with multiple hasMany between the same models with different join tables. Closes [#2316](https://github.com/sequelize/sequelize/issues/2316) - [BUG] Don't set autocommit in nested transactions [#2418](https://github.com/sequelize/sequelize/issues/2418) - [BUG] Improved `field` support # 2.0.0-rc1 - [BUG] Fixed an issue with foreign key object syntax for hasOne and belongsTo - [FEATURE] Added `field` and `name` to the object form of foreign key definitions - [FEATURE] Added support for calling `Promise.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. - [FEATURE] Added `scope` to hasMany association definitions, provides default values to association setters/finders [#2268](https://github.com/sequelize/sequelize/pull/2268) - [FEATURE] We now support transactions that automatically commit/rollback based on the result of the promise chain returned to the callback. - [BUG] Only try to create indexes which don't already exist. Closes [#2162](https://github.com/sequelize/sequelize/issues/2162) - [FEATURE] Hooks are passed options - [FEATURE] Hooks need not return a result - undefined return is interpreted as a resolved promise - [FEATURE] Added `find()` hooks #### Backwards compatibility changes - The `fieldName` property, used in associations with a foreign key object `(A.hasMany(B, { foreignKey: { ... }})`, has been renamed to `name` to avoid confusion with `field`. - The naming of the join table entry for N:M association getters is now singular (like includes) - Signature of hooks has changed to pass options to all hooks. Any hooks previously defined like `Model.beforeCreate(values)` now need to be `Model.beforeCreate(values, options)` etc. - Results returned by hooks are ignored - changes to results by hooks should be made by reference - `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. - The syntax for `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 });`. # v2.0.0-dev13 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](https://github.com/sequelize/sequelize/issues/1485). See API reference for details. - [FEATURE/INTERNALS] Standardized the output from `QueryInterface.showIndex`. - [FEATURE] Include deleted rows in find [#2083](https://github.com/sequelize/sequelize/pull/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](https://github.com/sequelize/sequelize/pull/2064) - [BUG] Fixed problems with transaction parameter being removed / not passed on in associations [#1789](https://github.com/sequelize/sequelize/issues/1789) and [#1968](https://github.com/sequelize/sequelize/issues/1968) - [BUG] Fix problem with minConnections. [#2048](https://github.com/sequelize/sequelize/issues/2048) - [BUG] Fix default scope being overwritten [#2087](https://github.com/sequelize/sequelize/issues/2087) - [BUG] Fixed updatedAt timestamp not being set in bulk create when validate = true. [#1962](https://github.com/sequelize/sequelize/issues/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 + validator 3.2.0 -> 3.16.1 + moment 2.5.0 -> 2.7.0 + generic-pool 2.0.4 -> 2.1.1 + sql 0.35.0 -> 0.39.0 - [INTERNALS] Use a transaction inside `findOrCreate`, and handle unique constraint errors if multiple calls are issues concurrently on the same transaction #### Backwards compatibility changes - 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: + Person is now pluralized as people instead of persons - 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/sequeliz