Ticket #2144: patch-django-db-models-query_parameter_convertion_#2144

File patch-django-db-models-query_parameter_convertion_#2144, 817 bytes (added by trbs, 18 years ago)
Line 
1Index: django/db/models/query.py
2===================================================================
3--- django/db/models/query.py (revision 3335)
4+++ django/db/models/query.py (working copy)
5@@ -902,8 +902,14 @@
6 # Last query term was a normal field.
7 column = field.column
8
9+ ## see ticket #2144
10 where.append(get_where_clause(lookup_type, current_table + '.', column, value))
11- params.extend(field.get_db_prep_lookup(lookup_type, value))
12+ def _hack_pvalue(value):
13+ from django.db.models import Model as hack_Model
14+ if isinstance(value, hack_Model):
15+ return value.id
16+ return value
17+ params.extend([_hack_pvalue(param) for param in field.get_db_prep_lookup(lookup_type, value)])
18
19 return joins, where, params
20
Back to Top