Commits

Rufus Pollock committed 5ea387b

[sqlalchemy/model,bugfix][s]: fix for handling of serialization of properties that aren't lists (e.g. simple foreign keys and dicts -- dicts not tested yet!).

* Wonder whether this right way to go -- may be better to require client code to provide dictization

Comments (0)

Files changed (1)

vdm/sqlalchemy/model.py

             a,u,d = attributes.get_history(obj, prop.key)
             if d or a:
                 obj_changed = True
-            attr[prop.key] = [get_object_id(x) for x in getattr(obj, prop.key)
-                    or [] ]
+            propvalue = getattr(obj, prop.key)
+            if isinstance(propvalue, list):
+                attr[prop.key] = [get_object_id(x) for x in propvalue]
+            elif isinstance(propvalue, dict):
+                attr[prop.key] = [(key,get_object_id(x)) for key,x in
+                        propvalue.items()]
+            elif propvalue is None:
+                attr[prop.key] = None
+            else:
+                attr[prop.key] = get_object_id(propvalue)
 
     if not obj_changed and operation_type == ChangeObject.OperationType.UPDATE:
         return