Clone doesn't work as expected
- Dominant language
- Python
- Stars
- 263
- Forks
- 90
- PR merge metrics
- No merged PRs in 30d
Description
Just to note, this issue was in couchdbkit before the recent changes to clone. And it's still here after the recent commits.
(It just so happens that this affected me at around the same time!)
Also I am not sure if this is an issue or bug, or if its unexpected behaviour.
```
>>> from couchdbkit import *
>>> class Person(Document):
... name = StringProperty()
...
>>> person_one = Person()
>>> person_two = person_one.clone()
>>> person_one.name = 'XYZ'
>>> person_two.name
u'XYZ'
>>> person_one
<__main__.Person object at 0x027EA170>
>>> person_two
<__main__.Person object at 0x04562530>
```
As you can see. If I change a property in person_one it is changing all the names for anything that was cloned from person_one, even though the new object coming back from clone() is a brand new object.
It just seems it's only making a copy of the Document object, while the property objects inside the new copy are still pointing to the old property objects.
I have tried copy and deepcopy from the copy module;
copy runs, but I get the same result.
deepcopy throws an error.
I am using the latest version of couchdbkit.
Thanks.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.