#14025 closed (fixed)
Flush command not fully supporting multi database support
Reported by: | linovia | Owned by: | linovia |
---|---|---|---|
Component: | Uncategorized | Version: | 1.2 |
Severity: | Keywords: | ||
Cc: | xordoquy@… | Triage Stage: | Unreviewed |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Flush has not been reworked with multi database
Story:
If one use two different databases (ie, with different models in both) flush emits the emit_post_sync_signal on EVERY model for EVERY database.
However since models may not be present (no django_site on legacy databases for example) an exception is raised which in turn breaks tests.
I ran into this even if I had no fixtures or no database access:
ERROR: test_basic_addition (modulemanagement.tests.SimpleTest) ---------------------------------------------------------------------- Traceback (most recent call last): File "/virtualenvs/django1.2/lib/python2.6/site-packages/Django-1.2.1-py2.6.egg/django/test/testcases.py", line 256, in __call__ self._pre_setup() File "/virtualenvs/django1.2/lib/python2.6/site-packages/Django-1.2.1-py2.6.egg/django/test/testcases.py", line 223, in _pre_setup self._fixture_setup() File "/virtualenvs/django1.2/lib/python2.6/site-packages/Django-1.2.1-py2.6.egg/django/test/testcases.py", line 487, in _fixture_setup return super(TestCase, self)._fixture_setup() File "/virtualenvs/django1.2/lib/python2.6/site-packages/Django-1.2.1-py2.6.egg/django/test/testcases.py", line 235, in _fixture_setup call_command('flush', verbosity=0, interactive=False, database=db) File "/virtualenvs/django1.2/lib/python2.6/site-packages/Django-1.2.1-py2.6.egg/django/core/management/__init__.py", line 166, in call_command return klass.execute(*args, **defaults) File "/virtualenvs/django1.2/lib/python2.6/site-packages/Django-1.2.1-py2.6.egg/django/core/management/base.py", line 218, in execute output = self.handle(*args, **options) File "/virtualenvs/django1.2/lib/python2.6/site-packages/Django-1.2.1-py2.6.egg/django/core/management/base.py", line 347, in handle return self.handle_noargs(**options) File "/virtualenvs/django1.2/lib/python2.6/site-packages/Django-1.2.1-py2.6.egg/django/core/management/commands/flush.py", line 69, in handle_noargs emit_post_sync_signal(models.get_models(), verbosity, interactive, db) File "/virtualenvs/django1.2/lib/python2.6/site-packages/Django-1.2.1-py2.6.egg/django/core/management/sql.py", line 185, in emit_post_sync_signal interactive=interactive, db=db) File "/virtualenvs/django1.2/lib/python2.6/site-packages/Django-1.2.1-py2.6.egg/django/dispatch/dispatcher.py", line 162, in send response = receiver(signal=self, sender=sender, **named) File "/virtualenvs/django1.2/lib/python2.6/site-packages/Django-1.2.1-py2.6.egg/django/contrib/sites/management.py", line 14, in create_default_site s.save(using=db) File "/virtualenvs/django1.2/lib/python2.6/site-packages/Django-1.2.1-py2.6.egg/django/contrib/sites/models.py", line 46, in save super(Site, self).save(*args, **kwargs) File "/virtualenvs/django1.2/lib/python2.6/site-packages/Django-1.2.1-py2.6.egg/django/db/models/base.py", line 435, in save self.save_base(using=using, force_insert=force_insert, force_update=force_update) File "/virtualenvs/django1.2/lib/python2.6/site-packages/Django-1.2.1-py2.6.egg/django/db/models/base.py", line 528, in save_base result = manager._insert(values, return_id=update_pk, using=using) File "/virtualenvs/django1.2/lib/python2.6/site-packages/Django-1.2.1-py2.6.egg/django/db/models/manager.py", line 195, in _insert return insert_query(self.model, values, **kwargs) File "/virtualenvs/django1.2/lib/python2.6/site-packages/Django-1.2.1-py2.6.egg/django/db/models/query.py", line 1479, in insert_query return query.get_compiler(using=using).execute_sql(return_id) File "/virtualenvs/django1.2/lib/python2.6/site-packages/Django-1.2.1-py2.6.egg/django/db/models/sql/compiler.py", line 783, in execute_sql cursor = super(SQLInsertCompiler, self).execute_sql(None) File "/virtualenvs/django1.2/lib/python2.6/site-packages/Django-1.2.1-py2.6.egg/django/db/models/sql/compiler.py", line 727, in execute_sql cursor.execute(sql, params) File "/virtualenvs/django1.2/lib/python2.6/site-packages/Django-1.2.1-py2.6.egg/django/db/backends/postgresql_psycopg2/base.py", line 44, in execute return self.cursor.execute(query, args) DatabaseError: relation "django_site" does not exist
Attachments (2)
Change History (10)
by , 14 years ago
Attachment: | flush.patch added |
---|
comment:1 by , 14 years ago
by , 14 years ago
Attachment: | flush-multi-db.diff added |
---|
Patch for Flush command to support multi database more correctly
comment:3 by , 14 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:4 by , 14 years ago
Cc: | added |
---|
comment:5 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
comment:6 by , 14 years ago
Note:
See TracTickets
for help on using tickets.
I apologize the patch isn't against the subversion trunk, I just don't have access to Django's trunk yet.
I'll update it tonight.