Browse Source

Implemented the emfield_del method in the migration handler

Roland Haroutiounian 8 years ago
parent
commit
1739a009bb
1 changed files with 3 additions and 6 deletions
  1. 3
    6
      lodel/datasource/mongodb/migration_handler.py

+ 3
- 6
lodel/datasource/mongodb/migration_handler.py View File

@@ -92,11 +92,7 @@ class MongoDbMigrationHandler(GenericMigrationHandler):
92 92
             return True
93 93
 
94 94
         if new_state['internal']:
95
-            collection_name = ''
96 95
             # TODO ?
97
-        elif new_state['rel_field_id']:
98
-            class_name = self._class_collection_name_from_field(model, new_state)
99
-            # TODO deal this case
100 96
         else:
101 97
             collection_name = self._class_collection_name_from_field(model, new_state)
102 98
 
@@ -104,8 +100,9 @@ class MongoDbMigrationHandler(GenericMigrationHandler):
104 100
         self._create_field_in_collection(collection_name, uid, field_definition)
105 101
 
106 102
     def emfield_del(self, model, uid, initial_state, new_state):
107
-        # TODO
108
-        pass
103
+        if uid != '_id':
104
+            collection_name = self._class_collection_name_from_field(model, initial_state)
105
+            self.database[collection_name].update_many({field:{'$exists':True}}, {'$unset':{field:1}}, False)
109 106
 
110 107
     def _field_definition(self, fieldtype, options):
111 108
         basic_type = DataHandler.from_name(fieldtype).ftype

Loading…
Cancel
Save