diff options
| author | Tai Lee <tai.lee@3030.com.au> | 2013-05-04 00:02:10 +1000 |
|---|---|---|
| committer | Anssi Kääriäinen <akaariai@gmail.com> | 2013-07-31 15:54:17 +0300 |
| commit | 31e6d58d46894ca35080b4eab7967e4c6aae82d4 (patch) | |
| tree | 4d77e97f90902bdd0ad77cdeb0735ab893929c58 /django/db/models/sql | |
| parent | 8f5533ab250df07ea84f98d39808806e282468a5 (diff) | |
Fixed #20348 -- Consistently handle Promise objects in model fields.
All Promise objects were passed to force_text() deep in ORM query code.
Not only does this make it difficult or impossible for developers to
prevent or alter this behaviour, but it is also wrong for non-text
fields.
This commit changes `Field.get_prep_value()` from a no-op to one that
resolved Promise objects. All subclasses now call super() method first
to ensure that they have a real value to work with.
Diffstat (limited to 'django/db/models/sql')
| -rw-r--r-- | django/db/models/sql/subqueries.py | 12 |
1 files changed, 0 insertions, 12 deletions
diff --git a/django/db/models/sql/subqueries.py b/django/db/models/sql/subqueries.py index 6aab02bd9a..8beb3fa74a 100644 --- a/django/db/models/sql/subqueries.py +++ b/django/db/models/sql/subqueries.py @@ -11,8 +11,6 @@ from django.db.models.sql.constants import GET_ITERATOR_CHUNK_SIZE, SelectInfo from django.db.models.sql.datastructures import Date, DateTime from django.db.models.sql.query import Query from django.db.models.sql.where import AND, Constraint -from django.utils.functional import Promise -from django.utils.encoding import force_text from django.utils import six from django.utils import timezone @@ -147,10 +145,6 @@ class UpdateQuery(Query): Used by add_update_values() as well as the "fast" update path when saving models. """ - # Check that no Promise object passes to the query. Refs #10498. - values_seq = [(value[0], value[1], force_text(value[2])) - if isinstance(value[2], Promise) else value - for value in values_seq] self.values.extend(values_seq) def add_related_update(self, model, field, value): @@ -210,12 +204,6 @@ class InsertQuery(Query): into the query, for example. """ self.fields = fields - # Check that no Promise object reaches the DB. Refs #10498. - for field in fields: - for obj in objs: - value = getattr(obj, field.attname) - if isinstance(value, Promise): - setattr(obj, field.attname, force_text(value)) self.objs = objs self.raw = raw |
