maritz / nohm

node.js object relations mapper (orm) for redis
http://maritz.github.io/nohm/
MIT License
500 stars 64 forks source link

fix(relation): fixes some problems with checkEqual and unlinking the same instances #128

Closed maritz closed 6 years ago

maritz commented 6 years ago

BREAKING CHANGE: Changes the checkEqual method to compare 2 model instances so that it now only checks if both have an id and returns true if they are the same. Previously it would additionally check allProperties() for equality and then claim that the instances are the same, even if the instances did not have ids set and could thus be different instances later on simply by saving them individually or other ways.

This shouldn't affect many use-cases, but is still a breaking change. Since the bug is also not critical - as far as I can tell - the fix will not land in the normal v1 version, but instead in a special v1-breaking branch/tag.

Also fixes other bugs in the equality checking and the unlink cleanup check.

Big thanks to lp-belliot!

Continuation of #123

maritz commented 6 years ago

@lp-belliot Can you confirm that my change in 4b97b65 covers your use-case?

lp-belliot commented 6 years ago

Thanks @maritz! This covers my use case. Apologies for the late response.