lanto03 / couchdb-python

Automatically exported from code.google.com/p/couchdb-python
Other
0 stars 0 forks source link

ListFields share the same default list instance #107

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

>>> from couchdb.schema import *
>>> class Foo(Document):
...     a = ListField(TextField())
... 
>>> print Foo.a.default
[]
>>> foo0 = Foo(id='foo0') #completely new doc
>>> print foo0.a
[]
>>> 
>>> print Foo.a.default
[]
>>> 
>>> foo1 = Foo.wrap({'_id': 'foo1', '_rev': 1, 'a': ['alpha']}) #emulate load
>>> print foo1.a
['alpha']
>>> 
>>> print Foo.a.default
[]
>>> 
>>> foo2 = Foo.wrap({'_id': 'foo2', '_rev': 1}) #property 'a' is missing
>>> foo2.a.append('omega')
>>> print foo2.a
['omega']
>>> print Foo.a.default
['omega']
>>> 
>>> foo3 = Foo(id='foo3') #another new doc
>>> print foo3.a #should be an empty list
[u'omega']
>>> print Foo.a.default
['omega']
>>> 

What is the expected output? What do you see instead?

The default list is expected to stay untouched, but it has changed.

What version of the product are you using? On what operating system?

0.6.0 and 0.6.1 under Mac OS X 10.6.

Please provide any additional information below.

This is issue is quite similar to the following one:
http://code.google.com/p/couchdb-python/issues/detail?id=101.

Original issue reported on code.google.com by ru.w31...@gmail.com on 14 Dec 2009 at 3:15

GoogleCodeExporter commented 8 years ago
Ah! I tried a bunch of simpler cases and couldn't reproduce anything that 
looked like
this could happen, so I went forward with the release. Will check this out, 
though.

Original comment by djc.ochtman on 14 Dec 2009 at 3:27

GoogleCodeExporter commented 8 years ago

Original comment by djc.ochtman on 14 Dec 2009 at 3:27

GoogleCodeExporter commented 8 years ago
Fixed in r7a4cdec02fc7. Thanks for the test case!

Original comment by djc.ochtman on 24 Dec 2009 at 9:54