#26163: Wrong related fields in ._meta.get_fields with multiple database on
foreignkey
-------------------------------------+-------------------------------------
Reporter: aRkadeFR | Owner: nobody
Type: Bug | Status: closed
Component: Database layer | Version: 1.9
(models, ORM) |
Severity: Normal | Resolution: invalid
Keywords: models, meta, | Triage Stage:
get_fields, fields, router, | Unreviewed
multiple, databases |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by aRkadeFR):
We are not doing a cross database relation in our projects.
We have actually 2 distinct project, a "core" project, and a "side"
project we will call them.
The auth_group table is in both the "core" database, and the "side"
database (with extra fields in the "core" database).
The "side" project uses the "core" database as read-only models (through
the router).
And to setup the "side" project, we install both project (as app) at the
same time to makemigrations / migrate etc.
We have a missing attribute error or other error as provided in the
following stacktrace.
I think our real problem is to have 2 different "app" / "project" at the
same time with 2 different django.contrib.auth (in different database).
And we don't know how to set this up.
Can we have your thoughts? Thanks again for the answer
{{{
In [9]: GroupA.objects.all().delete()
---------------------------------------------------------------------------
ProgrammingError Traceback (most recent call
last)
<ipython-input-9-1976efc2649b> in <module>()
----> 1 GroupA.objects.all().delete()
/usr/local/lib/python2.7/dist-packages/django/db/models/query.pyc in
delete(self)
598 collector = Collector(using=del_query.db)
599 collector.collect(del_query)
--> 600 deleted, _rows_count = collector.delete()
601
602 # Clear the result cache, in case this QuerySet gets
reused.
/usr/local/lib/python2.7/dist-packages/django/db/models/deletion.pyc in
delete(self)
290 # fast deletes
291 for qs in self.fast_deletes:
--> 292 count = qs._raw_delete(using=self.using)
293 deleted_counter[qs.model._meta.label] += count
294
/usr/local/lib/python2.7/dist-packages/django/db/models/query.pyc in
_raw_delete(self, using)
612 query. No signals are sent, and there is no protection for
cascades.
613 """
--> 614 return sql.DeleteQuery(self.model).delete_qs(self, using)
615 _raw_delete.alters_data = True
616
/usr/local/lib/python2.7/dist-packages/django/db/models/sql/subqueries.pyc
in delete_qs(self, query, using)
79 self.where = self.where_class()
80 self.add_q(Q(pk__in=values))
---> 81 cursor = self.get_compiler(using).execute_sql(CURSOR)
82 return cursor.rowcount if cursor else 0
83
/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.pyc
in execute_sql(self, result_type)
846 cursor = self.connection.cursor()
847 try:
--> 848 cursor.execute(sql, params)
849 except Exception:
850 cursor.close()
/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.pyc in
execute(self, sql, params)
77 start = time()
78 try:
---> 79 return super(CursorDebugWrapper, self).execute(sql,
params)
80 finally:
81 stop = time()
/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.pyc in
execute(self, sql, params)
62 return self.cursor.execute(sql)
63 else:
---> 64 return self.cursor.execute(sql, params)
65
66 def executemany(self, sql, param_list):
/usr/local/lib/python2.7/dist-packages/django/db/utils.pyc in
__exit__(self, exc_type, exc_value, traceback)
93 if dj_exc_type not in (DataError, IntegrityError):
94 self.wrapper.errors_occurred = True
---> 95 six.reraise(dj_exc_type, dj_exc_value, traceback)
96
97 def __call__(self, func):
/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.pyc in
execute(self, sql, params)
62 return self.cursor.execute(sql)
63 else:
---> 64 return self.cursor.execute(sql, params)
65
66 def executemany(self, sql, param_list):
ProgrammingError: relation "appb_modelb" does not exist
LINE 1: DELETE FROM "appb_modelb" WHERE "appb_modelb"."group_id" IN ...
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/26163#comment:3>
Django <https://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 unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/066.f9b723234e19d447b8d6b81b9939094e%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.