Opened 17 years ago

Closed 17 years ago

#6034 closed (wontfix)

Add boolean option 'load_fixtures' to the django command 'syncdb', default value is True.

Reported by: delimy@… Owned by: nobody
Component: Core (Management commands) Version: dev
Severity: Keywords: syncdb
Cc: ringier-dev@… Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Add boolean option 'load_fixtures' to the django command 'syncdb', default value is True.
We use this option in tests, so load_fixtures=False will not commit a transaction, and we can rollback easily.
There are also other circumstances that we don't want the fixture to load automatically.

Attachments (1)

syncdb_no_fixture.diff (1.3 KB ) - added by delimy@… 17 years ago.

Download all attachments as: .zip

Change History (5)

by delimy@…, 17 years ago

Attachment: syncdb_no_fixture.diff added

comment:1 by Russell Keith-Magee, 17 years ago

Resolution: wontfix
Status: newclosed

If you don't want your fixture to be automatically loaded, don't call your fixture initial_data, and manually load the fixture when you need it.

comment:2 by delimy@…, 17 years ago

The problem is that if you create a model in, for example, doctest, call_command('sync') will do a commit to database after loading fixtures.
We use rollback instead of flush, so it cause problem.

comment:3 by favo, 17 years ago

Cc: ringier-dev@… added
Resolution: wontfix
Status: closedreopened
Triage Stage: UnreviewedDesign decision needed

Hi russellm,

Thanks for your comment. I think it's not bad to give us more control on syncdb command.

django-admin.py syncdb --load_fixtures=False # Don't load fixture automatically. Default is True, so don't break current logic.

The only reason we need to do this like Delimy said above is:

we write some new model in doctest, to help us test our related model( think about you need test your generic tag system, you need a main model.)

"""
Create a test model
    >>> class TestModel(models.Model)
    ...     title = xxx
    >>> call_command('sync')
"""

we also changed django test framework to use rollback instead of flush db, which is more friendly(allow you use a exist db data to test rather than put everything to fixture. sometime fixture can't describe our test data, we have database view, something like this.). so the issue is with in syncdb command will call loaddata command. and in loaddata commend logic, it go into another transcation and commit at the end. which break outside transaction.

So we add an option to syncdb command to across, IMO it's not bad, it's cheap. However we can use django.core.management.sql method instead, of course.

comment:4 by Jacob, 17 years ago

Resolution: wontfix
Status: reopenedclosed

I agree with Russ on this -- more options make for more confusing software. If you're running a custom test framework, you should make this change there.

Note: See TracTickets for help on using tickets.
Back to Top