Repository navigation
Releases
Releases · tormozz48/postgrelize
v1.9.17
Fixed
reload()marks the instance as loaded by a query like v6, soget()andtoJSON()no longer list the virtualgetterMethodsafter a reload and a reloaded instance deep-equals the same row from a finder. Differential test intests/compat/reload-queried.test.ts. (#288)belongsToManythrough a model that declares its own primary key keeps that key and gives the two foreign keys a unique key (uniqueKey,through.unique) like v6. It added both foreign keys to the primary key, soinstance.update()of one was silently ignored. A junction model that declares only the foreign keys no longer keeps the automaticid, and a later association on a junction foreign key keeps its key. Behaviour change:primaryKeyAttributes,findByPk,upsertconflict target and thesync()schema of such models change; see the migrating guide. Differential test intests/compat/btm-through-declared-pk.test.ts. (#290)
v1.9.16
Fixed
- Two
belongsToManythrough the same model now take the other side'sforeignKeyasotherKeyand itssourceKeyastargetKeywhen these are not given (an extra column was generated andadd/setfailed), associations expose v6'sidentifier,foreignIdentifier,foreignIdentifierField,sourceKeyFieldandtargetKeyField, and an attribute withreferences: nullno longer crashessync. Behaviour change: the junction table of such pairs gets different columns. Differential tests intests/compat. (#257) belongsTo/hasOne/hasMany/belongsToManywithout a model throw v6's "called with something that's not a subclass of Sequelize.Model", and an unknownsourceKey/targetKeyofbelongsTo,hasOneandhasManythrows (it was accepted). Differential test intests/compat/association-definition-errors.test.ts. (#261)- Declaring an association again under its default alias replaces it instead of throwing
AssociationError; only a repeated explicitasthrows. Differential test intests/compat/default-alias-redefine.test.ts. (#262) - Behaviour change, deletes rows: the foreign key of
hasOne/hasManythat cannot beNULLnow getsON DELETE CASCADE(it wasNO ACTION), like Sequelize v6: oncesynccreates such a constraint, deleting a parent row deletes its children.belongsTokeepsNO ACTION. PassonDelete: 'NO ACTION'to keep the old behaviour. Differential test intests/compat/has-fk-delete-action.test.ts. (#263) countXandhasXofbelongsToManyread only the junction keys (they failed when the join table had no timestamp columns). Differential test intests/compat/btm-count-without-timestamps.test.ts. (#272)
v1.9.15
Fixed
Deferrable.INITIALLY_IMMEDIATE(),INITIALLY_DEFERRED()andNOT()work like in v6 (they threwis not a function). Differential test intests/compat/deferrable-callable.test.ts.sync({ alter: true })still does not update a changed mode (filed asB-alter-deferrable-not-updated). (#254)queryInterface.addIndexacceptsnulloptions (it threwTypeError) andsequelize.sync()without models checks the connection like v6 (it resolved against an unreachable server). Differential tests intests/compat/sync-addindex-inputs.test.ts. (#259)- Index field objects may name their column with v6's
attributekey in modelindexesandaddIndex(syncthrewTypeError). Differential test intests/compat/index-attribute-key.test.ts. (#264) - Removing a constraint that does not exist rejects with
UnknownConstraintError(it was a plainDatabaseError). Differential test intests/compat/unknown-constraint.test.ts. (#265) sequelize.drop()removes the foreign keys first when tables reference each other in a cycle (it failed with "other objects depend on it"). Differential test intests/compat/drop-cyclic.test.ts. (#266)- A foreign key named like the column of another attribute (
foreignKey: 'user_id'next touserId: { field: 'user_id' }) makes one column onsync(it failed with "column specified more than once"). Differential test intests/compat/fk-field-collision.test.ts. (#268) STRING,CHAR,TEXT,BLOB,DECIMAL,FLOAT,REALandDOUBLEaccept v6's options object (STRING({ length: 12 })threw). Differential test intests/compat/data-type-options-object.test.ts. (#270)createFunctionacceptsnulloptions andnull/{}characteristics, andcreateFunction/dropFunctionreport missing arguments with v6's messages (some threwTypeError). Differential test intests/compat/function-arguments.test.ts. (#271)- When several models are mapped to one table,
sequelize.syncsyncs only the last one (it synced each, which could fail). Differential test intests/compat/two-models-one-table.test.ts. (#275)
v1.9.14
Fixed
group: [['col']]groups by the column (the value was bound as a parameter). Differential test intests/compat/group-nested-array.test.ts. (#260)- In raw queries a
$inside an identifier (foo$bar) is no longer read as a bind parameter, and an array inside an array replacement is written as a row(..)instead of being flattened. Differential tests intests/compat/raw-query-tokens.test.ts. (#267) aggregateselects the givenattributesnext to the aggregate, sogroupmay name an alias, and a query with the deprecatedlogging: truelogs toconsole.loginstead of failing. Differential test intests/compat/aggregate-alias-group.test.ts. (#273)- A pooled connection that was closed while idle is no longer handed out, a connection that fails while checked out leaves the pool at once (with
pool.max: 1the pool stayed exhausted), andconnectionManager.validateis available. Differential test intests/compat/pool-dead-connection.test.ts. (#276)
v1.9.13
Fixed
Model.aggregatejoins itsinclude(also the one of a scope), so awhereon the include filters the rows, like v6. Differential test intests/compat/aggregate-include.test.ts. (#250)Model.updateignoresundefinedvalues and keys that are no attribute (they becameNULLor a missing column), sends no query and resolves to[0]when nothing is left, and without options throws v6'sMissing where attributeerror instead of aTypeError. Differential test intests/compat/update-values.test.ts. (#251)Model.primaryKeyFieldandinstance.rawAttributesexist like in v6, andcountXsof ahasManyassociation withgroupresolves to the count of the first group. Differential test intests/compat/model-v6-properties.test.ts. (#252)- Connection, constraint and aggregate errors can be constructed without arguments or with
nulllike in v6 (they threwTypeError),DatabaseErrorkeeps thesqlandparametersof its parent, andString(aggregateError)lists the errors like v6. Differential test intests/compat/error-constructors.test.ts. (#255) define/initthrow v6's errors for an unknown data type,ARRAYwithout an element type, anotNullvalidator on a nullable attribute, two auto increment attributes and invalidvalidateentries, and acceptunique: null(it threwTypeError). Behaviour change: such definitions were accepted before. Differential test intests/compat/definition-checks.test.ts. (#256)- An attribute named like an instance method (
set,where,changed) no longer replaces the method; read and write it withget/set, as in Sequelize v6. Behaviour change:instance.<name>is the method, not the value. Differential test intests/compat/attribute-named-like-method.test.ts. (#269)
v1.9.12
Fixed
Validator(alsoSequelize.Validatorandsequelize.Validator) is a copy of validator.js with the v6 additions andextend(), and validators registered with it work invalidateof attributes. Differential test intests/compat/validator-extend.test.ts. (#253)Model.scope('name')with a function scope calls it without arguments (it threw). Differential test intests/compat/scope-function-by-name.test.ts. (#258)- A nested
createwith abelongsToparent and aNOT NULLforeign key succeeds (it failed with "notNull Violation" before the parent was saved). Differential test intests/compat/belongs-to-include-not-null.test.ts. (#274)
v1.9.11
Fixed
- Regression since 1.9.7: after
update()(orsave({ fields })) on a model withversion, the nextsaveof the same instance threwOptimisticLockError. Differential test intests/compat/version-after-update.test.ts. (#277)
v1.9.10
Fixed
- An index declared with a truthy
uniquethat is nottrue(indexes: [{ unique: 'users_name_address', fields }]) is created as a unique index and used as the conflict target ofupsertandupdateOnDuplicate, like v6 (upsertinserted a duplicate row). Differential test intests/compat/upsert-named-unique-index.test.ts; one v6 suite baseline entry and the causeB-upsert-named-unique-indexare gone. (#224) queryInterface.createTable(name, attributes, { schema })creates the table (and its enum types) in that schema, anddescribeTable(name, 'schema')reads it, like v6 (the table went to the default schema). Differential test intests/compat/create-table-schema.test.ts; three v6 suite baseline entries and the causesC-createtable-schema-optionandB-describetable-schema-argare gone. (#232)queryInterface.createTable(name, attributes, { uniqueKeys })creates the composite unique constraints, like v6 (the option was ignored). Differential test intests/compat/create-table-unique-keys.test.ts; one v6 suite baseline entry and the causeC-createtable-uniquekeysare gone. (#232)- Behaviour change: a foreign key added by
addConstraintwithout anameis called<table>_<fields>_<referenced table>_fklike in v6 (it was<table>_<fields>_fkey), so migrations that remove it by the v6 name work. Differential test intests/compat/constraint-default-name.test.ts; one v6 suite baseline entry and the causeC-fk-default-constraint-nameare gone. (#234) getForeignKeyReferencesForTablereturns every field of v6 (tableName,tableSchema,tableCatalog,constraintSchema,constraintCatalog,referencedTableSchema,referencedTableCatalog,deferrable) besides the four it had. Differential test intests/compat/foreign-key-references.test.ts; one v6 suite baseline entry and the causeC-fk-references-fieldsare gone. (#232)queryInterface.changeColumnwithreferencesadds the foreign key (withonDelete/onUpdate), like v6, which then leaves the type and defaults of the column as they are (the references were ignored). Differential test intests/compat/change-column-references.test.ts; two v6 suite baseline entries and the causeC-changecolumn-referencesare gone. (#236)- An index with
type: 'unique'is created unique, and aJSONBattribute declared withindex: truegets aginindex atsync, like v6. Differential test intests/compat/index-conform.test.ts; the causeD-index-options-ignoredis gone (its two v6 titles read the privateModel._indexesand are filed as harness). (#224)
v1.9.9
Fixed
- A cast suffix on a nested JSON
wherekey ({ meta: { 'level::integer': { [Op.gt]: 3 } } }) casts the value like v6 instead of being part of the key name (which matched no rows); unknown cast types are rejected withInvalid cast type. Differential test intests/compat/json-where-cast.test.ts; three v6 suite baseline entries and the causeB-json-key-castare gone. (#208) sequelize.json('col.list[0].name')reads the array element like v6, inattributesandwhere, instead of treatinglist[0]as a key name. Differential test intests/compat/json-path-index.test.ts; three v6 suite baseline entries and the causeB-json-path-indexare gone. (#209){ id: { [Op.not]: [1, 2] } }isNOT INlike v6, instead of comparing the column with an array. Differential test intests/compat/where-op-not-array.test.ts; two v6 suite baseline entries and the causeA-op-not-arrayare gone. (#214)- In a
sequelize.querywithbind,$$inside a string literal stands for$like v6 (it stayed doubled); dollar-quoted blocks are left as they are. Differential test intests/compat/bind-dollar-escape.test.ts; two v6 suite baseline entries and the causeC-bind-dollar-escapeare gone. (#225) - The
fieldMapoption ofsequelize.queryrenames the columns of SELECT rows like v6 (it was ignored). Differential test intests/compat/query-field-map.test.ts; two v6 suite baseline entries and the causeC-query-fieldmapare gone. (#226) - Behaviour change:
sequelize.query('SHOW ...')without atyperesolves to the rows alone, like v6, instead of[rows, result]. Differential test intests/compat/query-show-result.test.ts; three v6 suite baseline entries (two of them filed underC-client-min-messages) and the causeC-raw-show-result-shapeare gone. (#226) - Parameters of a connection URI's query string that
pgunderstands (options,application_name,statement_timeout, ...) andhostare used like in v6 (they were ignored). Differential test intests/compat/connection-uri-options.test.ts; one v6 suite baseline entry and the causeC-uri-query-optionsare gone. (#228)
v1.9.8
Fixed
- The
typeValidationSequelize option works like in v6: a value that does not fit the data type of its attribute (a string forINTEGERorDECIMAL, an unknownENUMlabel, ...) is rejected withValidationErroron writes and inwherebefore the statement runs. Differential test intests/compat/type-validation.test.ts; five v6 suite baseline entries and the causesD-typevalidation-ignoredandC-typevalidation-optionare gone. (#205) - Includes of merged scopes and find options behave like v6: includes of different models are all kept (a non-array
includereplaced the other one) and entries of the same model and alias become one (the table was joined twice:table name specified more than once). Differential test intests/compat/scope-include-merge.test.ts; five v6 suite baseline entries and the causesA-scope-include-replacedandA-include-merge-same-modelare gone. (#217) - When
save()writes the changed attributes, a new value that abeforeUpdatehook gives to any of them is validated again, like v6; an invalid value set by a hook on an attribute that was already changed was saved. Differential test intests/compat/hook-changes-revalidated.test.ts; two v6 suite baseline entries and the causeB-hook-changes-not-revalidatedare gone. (#218) - A
Datein a nested JSONwhereis compared astimestamptzlike v6 (it was bound as quoted JSON text and never matched), andIN/BETWEENon a JSON path cast by the type of their values. Differential test intests/compat/json-date-where.test.ts; one v6 suite baseline entry and the causeB-json-date-whereare gone. (#205) - Behaviour change: like v6, a hook in the model options replaces the
define.hookshook of the same name instead of running after it. Differential test intests/compat/define-hooks-override.test.ts; one v6 suite baseline entry and the causeD-define-hooks-mergeare gone. (#229)