diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2009-03-09 00:07:50 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2009-03-09 00:07:50 +0000 |
| commit | 6fe80b2a93bed40cd7587fe0c9af9438a2308ced (patch) | |
| tree | c021593923d8124cd3e3208440581888b1e954ea /django/db/models/sql | |
| parent | b1fd7650a9f44e3a31b50e1b1393d931ceba57fe (diff) | |
[1.0.X] Pass values through get_db_prep_save() in a QuerySet.update() call.
This removes a long-standing FIXME in the update() handling and allows for
greater flexibility in the values passed in. In particular, it brings updates
into line with saves for django.contrib.gis fields, so fixed #10411.
Thanks to Justin Bronn and Russell Keith-Magee for help with this patch.
Backport of r10003 from trunk.
git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@10004 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/db/models/sql')
| -rw-r--r-- | django/db/models/sql/subqueries.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/django/db/models/sql/subqueries.py b/django/db/models/sql/subqueries.py index 14af34d7c4..1a0197e8f6 100644 --- a/django/db/models/sql/subqueries.py +++ b/django/db/models/sql/subqueries.py @@ -233,9 +233,10 @@ class UpdateQuery(Query): """ from django.db.models.base import Model for field, model, val in values_seq: - # FIXME: Some sort of db_prep_* is probably more appropriate here. - if field.rel and isinstance(val, Model): - val = val.pk + if hasattr(val, 'prepare_database_save'): + val = val.prepare_database_save(field) + else: + val = field.get_db_prep_save(val) # Getting the placeholder for the field. if hasattr(field, 'get_placeholder'): |
