Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#21457 closed Bug (fixed)

Possible loaddata filename regression

Reported by: Keryn Knight <django@…> Owned by: nobody
Component: Core (Management commands) Version: 1.6
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Just did a pip install --upgrade Django from 1.5.5 to 1.6 to test what changes I'd need to make. Previously, the following worked fine:

python manage.py loaddata initial_data.auth.json

which was a handy way of declaring that some data might be needed on first-usage, without actually having it clobber whatever data is in the DB every time thereafter, as initial_data is wont to do.

As of 1.6, this now results in an error:

CommandError: Problem installing fixture 'initial_data': auth is not a known serialization format.

I can't see mention in the release notes, or the loaddata/dumpdata/fixtures docs suggesting anything has changed in such a way that this is expected behaviour.

Attachments (1)

ticket_21457_tests.diff (2.0 KB ) - added by Baptiste Mispelon 10 years ago.

Download all attachments as: .zip

Change History (8)

comment:1 by Baptiste Mispelon, 10 years ago

Severity: NormalRelease blocker
Triage Stage: UnreviewedAccepted

Hi,

I can reproduce the issue when the filename contains a period (it works fine otherwise).

I tracked down the regression to commit 51aa000378c00a442273f01142acdebc94dec68d.

Thanks for the report.

comment:2 by Baptiste Mispelon, 10 years ago

Cc: Baptiste Mispelon added

Digging a bit deeper, I also found that a TypeError is raised if the filename contains several periods (foo.bar.baz.json for example).

I've added two tests (see attached patch) for these issues and from what I can tell, they fail because of the following lines: https://github.com/django/django/blob/7ad3ab081cf540808a503f9dd18e7720a239bf22/django/core/management/commands/loaddata.py#L178-L182

Unfortunately, removing this causes another test to fail (fixtures_regress.tests.TestFixtures.test_unkown_format).

by Baptiste Mispelon, 10 years ago

Attachment: ticket_21457_tests.diff added

comment:4 by Aymeric Augustin, 10 years ago

Cc: Baptiste Mispelon removed
Severity: Release blockerNormal
Triage Stage: AcceptedUnreviewed

(Posting now a comment I wrote this morning, but disconnected before I could submit it.)

You were apparently relying on undocumented behavior. The pattern supported by Django for fixtures file names is: <filename>.<database>.<format>.<compression> where you need to provide at least <filename> as a command line argument. You should use loaddata initial_data.auth.

loaddata was refactored in 51aa000378c00a442273f01142acdebc94dec68d to locate files more efficiently (10 to 1000 times faster depending on your project). That probably explains the difference you're seeing.

comment:5 by Aymeric Augustin, 10 years ago

Erm, I shouldn't analyze tickets after waking up at 5:30 to catch a train. In fact it's a plain bug.

comment:6 by Claude Paroz <claude@…>, 10 years ago

Resolution: fixed
Status: newclosed

In 97ac22ebfca0a5b0759f495cc5d7bed3f9da6615:

Fixed #21457 -- Allowed fixture file name to contain dots

Thanks Keryn Knight for the report.

comment:7 by Claude Paroz <claude@…>, 10 years ago

In 833f7d11e8f1d0171bac23e2e78c1111a83fbeaa:

[1.6.x] Fixed #21457 -- Allowed fixture file name to contain dots

Thanks Keryn Knight for the report.
Backport of 97ac22ebfc from master.

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