Commits

Waldemar Kornewald committed 05d297f

added quick hack by Jonas Haag to make MongoDB backend's A() queries work. TODO: should be removed as soon as we have a cleaner solution (Jonas is working on it)

Comments (0)

Files changed (1)

djangotoolbox/fields.py

         return self._convert(self.item_field.get_db_prep_save,
                              value, connection=connection)
 
+    # TODO/XXX: Remove this once we have a cleaner solution
+    def get_db_prep_lookup(self, lookup_type, value, connection, prepared=False):
+        if hasattr(value, 'as_lookup_value'):
+            value = value.as_lookup_value(self, lookup_type, connection)
+        return value
+
     def validate(self, values, model_instance):
         try:
             iter(values)
                            '_model'  : embedded_instance.__class__.__name__})
         return values
 
+    # TODO/XXX: Remove this once we have a cleaner solution
+    def get_db_prep_lookup(self, lookup_type, value, connection, prepared=False):
+        if hasattr(value, 'as_lookup_value'):
+            value = value.as_lookup_value(self, lookup_type, connection)
+        return value
+
     def to_python(self, values):
         if not isinstance(values, dict):
             return values