couchdbkit icon indicating copy to clipboard operation
couchdbkit copied to clipboard

Buggy SchemaDictProperty

Open sirex opened this issue 13 years ago • 2 comments

Here is patch to tests, that demonstrates, how to reprodice this bug:

diff --git a/tests/test_schema.py b/tests/test_schema.py
index d141ebf..f7c8058 100644
--- a/tests/test_schema.py
+++ b/tests/test_schema.py
@@ -1353,6 +1353,10 @@ class PropertyTestCase(unittest.TestCase):
         self.assert_(b1.d['v1'].i == 123)
         self.assert_(b1.d[23].i == 42)

+        b1.d = {23: {'i': 321}}
+        b1.set_db(self.db)
+        b1.save()
+

     def testListProperty(self):
         from datetime import datetime

This bug only occurs, when trying to assign dictionary to bounded object. When I try to do this on new object, everything works ok.

sirex avatar Feb 16 '12 19:02 sirex

can you add the trace you have ?

benoitc avatar Feb 16 '12 23:02 benoitc

======================================================================
ERROR: testSchemaDictProperty (tests.test_schema.PropertyTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/sirex/devel/couchdbkit/tests/test_schema.py", line 1356, in testSchemaDictProperty
    b1.d = {23: {'i': 321}}
  File "/home/sirex/devel/couchdbkit/couchdbkit/schema/base.py", line 216, in __setattr__
    object.__setattr__(self, key, value)
  File "/home/sirex/devel/couchdbkit/couchdbkit/schema/properties.py", line 109, in __set__
    value = self.validate(value, required=False)
  File "/home/sirex/devel/couchdbkit/couchdbkit/schema/properties_proxy.py", line 318, in validate
    value = self.validate_dict_schema(value, required=required)
  File "/home/sirex/devel/couchdbkit/couchdbkit/schema/properties_proxy.py", line 323, in validate_dict_schema
    v.validate(required=required)
AttributeError: 'dict' object has no attribute 'validate'

sirex avatar Feb 17 '12 06:02 sirex