How do I test a database view
|Reported by:||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
I have a database which has views in it. I need to run tests against this, so I created unmanaged models. Now I run tests and I get the error:
DETAIL: Table X references Y
HINT: Truncate table Z at the same time, or use TRUNCATE ... CASCADE.
which is basically caused by the fact that foreign keys are based off of the view. I get this when the TRUNCATE statement is run between tests. What worked was when I went into the DB and ran the same statement as a TRUNCATE CASCADE, but I can't figure out where this truncate statement is run from the django side.
Another possible fix is the use of essentially #IFDEF statements in c, but I don't know if any variable is defined for django when it is running tests. I also don't honestly know why the TRUNCATE isn't a CASCADE since all of the data is destroyed between tests anyway. Is there a known work around for this?
Thanks so much