New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling `set[association]` twice nullifies relationship #5315

jocull opened this Issue Jan 27, 2016 · 1 comment


2 participants

jocull commented Jan 27, 2016

I have an issue where calling a HasOne setter twice is removing the relationship. Calling it repeatedly switches the relationship on and off.

I have been pairing this with transactions and on subsequent calls my results are different.

Is this by design? It feels like a bug, as I would expect multiple sets to not change the relationships at all.

model: Home
model: Person
association: Person HasOne Home

  .then(() => {
    // Run once: relationship exists
    // Run twice: relationship does not exist

@mickhansen mickhansen added the bug label Jan 27, 2016


This comment has been minimized.


mickhansen commented Jan 27, 2016

Definitely a bug, calling it twice in a row should be as close to a NOOP as possible.

@janmeier janmeier closed this in 7b80ade Apr 2, 2016

jchbh-duplicate pushed a commit to jchbh-duplicate/sequelize that referenced this issue May 7, 2016

Changhai Jiang
Merge pull request sequelize#5 in SKYLINE/skyline-sequelize from upgr…
…ade-sequelize to master

* commit 'ce88acae0e14b20a5341e42f41adf09041f90100': (395 commits)
  remove unused INTARRAY
  bump fix version
  revert undocumented transaction inherits event emitter
  revert unecessary boolean coercion
  revert query 3 argument support
  space issue
  Disables setting AUTOCOMMIT for Postgres >= 9.4.0
  Revert "disable autocommit for postgresql 9.5"
  changelog for v3.21.0
  Support calling setAssociation twice on hasOne. Closes sequelize#5315
  [ci skip] babel-preset-es2015@6.6.0. Closes sequelize#5505
  Rewriting of the benchmarking feature
  Update validation to return null
  Add unit-tests for custom validation functions
  (tests) sequelize#3534, values modified in validate hooks are saved
  fix limit=0 issue
  chore: typo in test description
  add: beforeConnect hook
  add: support single object as Sequelize constructor parameter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment