Clone doesn't work as expected
@benoitc đang làm issue này rồi.
Từ ngày 5/5/2011.
Đánh giá
Issue này chưa được đánh giá.
Mô tả
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.
- Ngôn ngữ chính
- Python
- Star
- 261
- Fork
- 90
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của benoitc/couchdbkit
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
benoitc/couchdbkit#181 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
benoitc/couchdbkit#196 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
benoitc/couchdbkit#194 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 30/100
benoitc/couchdbkit#193 · 2 bình luận · 1 reaction ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 48/100
benoitc/couchdbkit#192 ·
Tất cả issue của benoitc/couchdbkit
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
-
area:other help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
WingedGuardian/GENesis-AGI#4734 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
peach-mitao/peach#693 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Failed result serialization destroys a previously saved JSON resultCó thể đã có người làm @chessing234 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
huggingface/evaluate#867 ·
-
FTP reads inside a transaction use a nonexistent staging pathCó thể đã có người làm @Harsh23Kashyap đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
fsspec/filesystem_spec#2463 ·
Maintainer thường phản hồi trong vòng 1 ngày