1. Waldemar Kornewald
  2. djangoappengine

Commits

Thomas Wanschik  committed b52f10e Merge
  • Participants
  • Parent commits 8ce752b, a4d0839
  • Branches default

Comments (0)

Files changed (1)

File db/compiler.py

View file
                 if not field.null and entity.get(field.column,
                         field.default) is None:
                     raise ValueError("Non-nullable field %s can't be None!" % field.name)
-                result.append(self.convert_value_from_db(field.db_type(),
-                    entity.get(field.column, field.default)))
+                result.append(self.convert_value_from_db(field.db_type(
+                    connection=self.connection), entity.get(field.column, field.default)))
             yield result
 
     def has_results(self):
         return result
 
     def convert_value_from_db(self, db_type, value):
+        if isinstance(value, (list, tuple)) and db_type.startswith('ListField:'):
+            db_sub_type = db_type.split('ListField:')[1]
+            for i, val in enumerate(value):
+                value[i] = self.convert_value_from_db(db_sub_type, val)
+
         # the following GAE database types are all unicode subclasses, cast them
         # to unicode so they appear like pure unicode instances for django
         if isinstance(value, (Category, Email, Link, PhoneNumber, PostalAddress,
         return value
 
     def convert_value_for_db(self, db_type, value):
+        if isinstance(value, (list, tuple)) and db_type.startswith('ListField:'):
+            db_sub_type = db_type.split('ListField:')[1]
+            for i, val in enumerate(value):
+                value[i] = self.convert_value_for_db(db_sub_type, val)
         # long text fields cannot be indexed on GAE so use GAE's database type
         # Text
         if db_type == 'gae_key':