lanto03 / couchdb-python

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

Document.store behaviour changed #133

Closed GoogleCodeExporter closed 8 years ago

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

#From the inline-documentation.

class Person(Document):
    name = TextField()
    age = IntegerField()
    added = DateTimeField(default=datetime.now)      

person = Person(name='John Doe', age=42)
person.store(db)  
person = Person.load(db, person.id)
person.name = 'John R. Doe'
person.store(db)             

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

 I expect to see one document created and then updated.

 I actually TWO documents created.  This has changed since the previous release.

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

python-couchdb 0.7, couchdb 0.9

Please provide any additional information below.

The changes seems to be because mapping.py/Document.store now calls directly to 
Database.save, which always creates a new document.
Schema.py/Document.store used to check for the existance of an id and 
save/update as needed.

Original issue reported on code.google.com by trvrmgn@gmail.com on 15 Jun 2010 at 7:39

GoogleCodeExporter commented 8 years ago
Seems CouchDB changed behaviour sometime. In 0.9 it used to *always* create a 
new document for POST (with an incorrect _rev if there an _id was present, 
AFAICT); newer versions update the existing doc if possible.

I think the fix should be easy enough.

Original comment by matt.goo...@gmail.com on 15 Jun 2010 at 8:55

GoogleCodeExporter commented 8 years ago
Fixed in revision 1176aa5b72.

Original comment by matt.goo...@gmail.com on 15 Jun 2010 at 9:18