I read related Django code and I think that Postgres message "cannot
truncate a table referenced in a foreign key constraint" is not a
Satchmo specific problem, rather you can have the same problem with
every Django application with two nonempy related tables, with similar
customization and on the same machine.
Maybe it is one of the following or combination:
A) You have Postgres 8.0 or older (for which Django does multiple
individual DELETE commands for flush) and you use Autocommit, which
combination is not supported by Django.
Newer Postgres versions use TRUNCATE ... "product_product",...
"downloadable_downloadableproduct",...;
all in one command. The order of installed apps should be not
important for this.
B) You added a Downloadable product automatically to the database by
fixtures.
C) You wrote a custom test derived directly from TransactionTestCase
not from TestCase, which I never tried.
D) You have and old test database from an previous interrupted test
and you did not permitted to remove it when you have been asked.
You can add temporary a line
import pprint; pprint.pprint(sql_list)
after
sql_list = sql_flush(self.style, connection, only_django=True)
and then try that commands execute manually from normal database after
syncdb.
Hynek
On 17 říj, 22:49, Marco <[email protected]> wrote:
> I was indeed running pg. The tests ran properly with sqlite.
>
> Side note: The idea in this blog
> post:http://seanhayes.name/2010/01/09/test-database-django/
> came in handy to circumvent the problem with pg only when testing.
>
> Thanks
>
> On Oct 17, 4:11 pm, Chris Moffitt <[email protected]> wrote:
>
>
>
>
>
>
>
> > What db are you using? There is a known issue with Postgresql and latest
> > Django running the test cases correctly. Try sqlite and see if you get the
> > same result.
>
> > -Chris
>
> > On Mon, Oct 17, 2011 at 1:51 PM, Marco <[email protected]> wrote:
> > > Has any one else had this problem when running ./manage.py test in
> > > their Satchmo project?
>
> > > ./manage.py test
> > > Creating test database for alias 'default'...
> > > Error: Database test_store couldn't be flushed. Possible reasons:
> > > * The database isn't running or isn't configured correctly.
> > > * At least one of the expected database tables doesn't exist.
> > > * The SQL was invalid.
> > > Hint: Look at the output of 'django-admin.py sqlflush'. That's the
> > > SQL this command wasn't able to run.
> > > The full error: cannot truncate a table referenced in a foreign
> > > key constraint
> > > DETAIL: Table "product_downloadableproduct" references
> > > "product_product".
> > > HINT: Truncate table "product_downloadableproduct" at the same
> > > time, or use TRUNCATE ... CASCADE.
>
> > > The hint given is useless, as ./manage.py sqlflush acts on the main db
> > > and not the test db (right?).
>
> > > I am not sure even where to begin to look. Any help is appreciated.
>
> > > Thanks
>
> > > --
> > > You received this message because you are subscribed to the Google Groups
> > > "Satchmo users" 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/satchmo-users?hl=en.
--
You received this message because you are subscribed to the Google Groups
"Satchmo users" 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/satchmo-users?hl=en.