#4102: Allow UPDATE of only specific fields in model.save() --------------------------------------------------------+------------------- Reporter: Collin Grady <cgr...@the-magi.us> | Owner: cgrady Status: new | Milestone: 1.1 Component: Database layer (models, ORM) | Version: SVN Resolution: | Keywords: Stage: Design decision needed | Has_patch: 0 Needs_docs: 1 | Needs_tests: 0 Needs_better_patch: 1 | --------------------------------------------------------+------------------- Changes (by seandong):
* has_patch: 1 => 0 * milestone: => 1.1 Comment: If query at the same time use function 'select_related' and 'only', it will be wrong. >>> s = Station_Info.objects.select_related('player_info').only('name','player_info__nickname').get(pk=1) >>> s.name='test11' >>> s.save() Traceback (most recent call last): File "<console>", line 1, in <module> File "/usr/lib/python2.6/dist-packages/django/db/models/base.py", line 420, in save self.save_base(force_insert=force_insert, force_update=force_update) File "/usr/lib/python2.6/dist-packages/django/db/models/base.py", line 462, in save_base self.save_base(cls=parent, origin=org) File "/usr/lib/python2.6/dist-packages/django/db/models/base.py", line 487, in save_base rows = manager.filter(pk=pk_val)._update(values) File "/usr/lib/python2.6/dist-packages/django/db/models/query.py", line 449, in _update return query.execute_sql(None) File "/usr/lib/python2.6/dist- packages/django/db/models/sql/subqueries.py", line 120, in execute_sql cursor = super(UpdateQuery, self).execute_sql(result_type) File "/usr/lib/python2.6/dist-packages/django/db/models/sql/query.py", line 2385, in execute_sql cursor.execute(sql, params) File "/usr/lib/python2.6/dist-packages/django/db/backends/util.py", line 19, in execute return self.cursor.execute(sql, params) File "/usr/lib/python2.6/dist- packages/django/db/backends/mysql/base.py", line 89, in execute raise Database.IntegrityError(tuple(e)) IntegrityError: (1048, "Column 'map_info_id' cannot be null") -- Ticket URL: <http://code.djangoproject.com/ticket/4102#comment:43> Django <http://code.djangoproject.com/> The Web framework for perfectionists with deadlines. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-updates@googlegroups.com To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-updates?hl=en -~----------~----~----~----~------~----~------~--~---