I ran into a problem with running unit tests against views where it
said that:
HINT: Truncate table "challenges_challenge_attachments" at the same
time, or use TRUNCATE ... CASCADE.
I patched it to be this, only for postgresql. This patch seems to work
quite well. I don't know if there are any pitfalls but this allowed me
to create my own views using the unmanaged model and still test
successfully with foreign keys.
Thanks,
~Ben
Index: django/db/backends/postgresql_psycopg2/operations.py
===================================================================
--- django/db/backends/postgresql_psycopg2/operations.py (revision
16443)
+++ django/db/backends/postgresql_psycopg2/operations.py (working
copy)
@@ -78,9 +78,10 @@
# Perform a single SQL 'TRUNCATE x, y, z...;' statement.
It allows
# us to truncate tables referenced by a foreign key in
any other
# table.
- sql = ['%s %s;' % \
+ sql = ['%s %s %s;' % \
(style.SQL_KEYWORD('TRUNCATE'),
- style.SQL_FIELD(', '.join([self.quote_name(table)
for table in tables]))
+ style.SQL_FIELD(', '.join([self.quote_name(table)
for table in tables])),
+ style.SQL_KEYWORD('CASCADE')
)]
# 'ALTER SEQUENCE sequence_name RESTART WITH 1;'... style
SQL statements
--
You received this message because you are subscribed to the Google Groups
"Django developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-developers?hl=en.