id,summary,reporter,owner,description,type,status,component,version,severity,resolution,keywords,cc,stage,has_patch,needs_docs,needs_tests,needs_better_patch,easy,ui_ux 10362,Queryset.update throws ProgrammingError when updating inherited fields,vbmendes,Malcolm Tredinnick,"When trying to batch update an inherited field, using queryset.update() method, a ProgrammingError is thrown. Lets supose I have two models: {{{ class Pessoa(models.Model): nome = models.CharField(max_length=""255"") removido = models.BooleanField(default=False,editable=False) class PessoaJuridica(Pessoa): cnpj = models.CharField(verbose_name=u'CNPJ',max_length=""50"",blank=True) }}} The error is thrown by this code: {{{ >>> import django >>> django.get_version() u'1.1 alpha 1 SVN-9905' >>> from pessoas.models import Pessoa, PessoaJuridica >>> PessoaJuridica.objects.filter(pk__in=[61,]).update(cnpj='123') 1 >>> Pessoa.objects.filter(pk__in=[61,]).update(removido=True) 1 >>> Pessoa.objects.filter(pk__in=[61,]).update(removido=False) 1 >>> PessoaJuridica.objects.filter(pk__in=[61,]).update(removido=True) Traceback (most recent call last): File """", line 1, in File ""/usr/lib/python2.5/site-packages/django/db/models/query.py"", line 450, in update rows = query.execute_sql(None) File ""/usr/lib/python2.5/site-packages/django/db/models/sql/subqueries.py"", line 119, in execute_sql cursor = super(UpdateQuery, self).execute_sql(result_type) File ""/usr/lib/python2.5/site-packages/django/db/models/sql/query.py"", line 2019, in execute_sql sql, params = self.as_sql() File ""/usr/lib/python2.5/site-packages/django/db/models/sql/subqueries.py"", line 131, in as_sql self.pre_sql_setup() File ""/usr/lib/python2.5/site-packages/django/db/models/sql/subqueries.py"", line 201, in pre_sql_setup for rows in query.execute_sql(MULTI): File ""/usr/lib/python2.5/site-packages/django/db/models/sql/query.py"", line 2028, in execute_sql cursor.execute(sql, params) File ""/usr/lib/python2.5/site-packages/django/db/backends/util.py"", line 19, in execute return self.cursor.execute(sql, params) ProgrammingError: syntax error at or near ""WHERE"" LINE 1: SELECT U1.""id"" FROM WHERE U0.""pessoa_ptr_id"" IN (61) ^ >>> }}} So, one can notice that the error only occurs with inherited fields. 'cnpj' is a field of PessoaJuridica and 'removido' is inherited from Pessoa. I read the documentation where it says that batch update doesn't works with related fields. I know that in this case, in database level, 'removido' is a related field. But in object level, it isn't. So I expect the batch update works in this case, but it doesn't happens.",,closed,"Database layer (models, ORM)",dev,,fixed,queryset batch update,,Accepted,0,0,0,0,0,0