Added unique indexes to rawAttributes#7196
Conversation
Codecov Report
Continue to review full report at Codecov.
|
lib/model.js
Outdated
| index = this._conformIndex(index); | ||
| //Add unique indexes to rawAttributes | ||
| if (index.unique && index.fields) { | ||
| index.fields.forEach(field => { |
There was a problem hiding this comment.
What will happen in case of unique index on two fields (composite unique index), will it mark both fields as unique? I would like to see a test which works in case of composite unique index
There was a problem hiding this comment.
@sushantdhiman Composite index also works. I have added an unit test for it but I'll add an integration test aswell.
lib/model.js
Outdated
| index = this._conformIndex(index); | ||
| //Add unique indexes to rawAttributes | ||
| if (index.unique && index.fields) { | ||
| index.fields.forEach(field => { |
lib/model.js
Outdated
| //Add unique indexes to rawAttributes | ||
| if (index.unique && index.fields) { | ||
| index.fields.forEach(field => { | ||
| const fieldName = (typeof field === 'string') ? field : (field.name || field.attribute); |
There was a problem hiding this comment.
unneeded parens and space
30c9b1f to
d90bc38
Compare
d90bc38 to
be32db4
Compare
|
@sushantdhiman Looks like the deadlocks still occur. Was this not fixed by #7131? |
* Added unique indexes to rawAttributes * Add changelog entry * Added integration test to cover composite unique keys, review fixes * Fixes failing tests
Pull Request check-list
npm run testornpm run test-DIALECTpass with this change (including linting)?Futurein the changelog?Description of change
indexesdefined via the following snippet are not added toModel.rawAttributes.Model.upsertquery usesrawAttributesto find primary/unique indexes and hence the upsert query would fail in case of the above model definition.Fixes #6842 (comment)