#25243: inspectdb crashes if SQLite foreign key references sqlite_master
-------------------------------------+-------------------------------------
Reporter: Stephan Sokolow | Owner: nobody
Type: Bug | Status: new
Component: Core (Management | Version: 1.8
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Claude Paroz):
I'm just posting a temporary test case diff (very WIP):
{{{
#!diff
diff --git a/tests/backends/sqlite/test_introspection.py
b/tests/backends/sqlite/test_introspection.py
index 1695ee549e..6a4508031d 100644
--- a/tests/backends/sqlite/test_introspection.py
+++ b/tests/backends/sqlite/test_introspection.py
@@ -25,3 +25,20 @@ class IntrospectionTests(TestCase):
self.assertEqual(field, expected_string)
finally:
cursor.execute('DROP TABLE test_primary')
+
+ def test_references_sqlite_master(self):
+ with connection.cursor() as cursor:
+ sql = (
+ 'CREATE TABLE todos ('
+ ' id INTEGER PRIMARY KEY,'
+ ' pg INTEGER REFERENCES sqlite_master (root_page)'
+ ')'
+ )
+ res = cursor.execute(sql)
+ try:
+ relations =
connection.introspection.get_relations(cursor, 'todos')
+ # What should we expect here?
+ self.assertEqual(relations, {})
+ finally:
+ # I cannot understand why the following DROP fails (due
to the FK somewhere).
+ cursor.execute('DROP TABLE todos')
}}}
I'm not sure if it's possible to find the relation in any way...
--
Ticket URL: <https://code.djangoproject.com/ticket/25243#comment:4>
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.ff3608ed7248065d2812c0c99481d238%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.