mirror of
https://github.com/django/django.git
synced 2025-10-29 02:52:24 +00:00
Fixed #17530 - Fixture loading with deferred constraints broken for Postgres for fixtures from multiple dirs/files
Thanks to claudep for the review. git-svn-id: http://code.djangoproject.com/svn/django/trunk@17372 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
64229eb388
commit
4e29b70b9d
4 changed files with 152 additions and 109 deletions
|
|
@ -0,0 +1,10 @@
|
|||
[
|
||||
{
|
||||
"pk": 1,
|
||||
"model": "fixtures_regress.book",
|
||||
"fields": {
|
||||
"name": "Cryptonomicon",
|
||||
"author": 4
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
[
|
||||
{
|
||||
"pk": "4",
|
||||
"model": "fixtures_regress.person",
|
||||
"fields": {
|
||||
"name": "Neal Stephenson"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
@ -16,6 +16,7 @@ from django.db import transaction
|
|||
from django.db.models import signals
|
||||
from django.test import (TestCase, TransactionTestCase, skipIfDBFeature,
|
||||
skipUnlessDBFeature)
|
||||
from django.test.utils import override_settings
|
||||
|
||||
from .models import (Animal, Stuff, Absolute, Parent, Child, Article, Widget,
|
||||
Store, Person, Book, NKChild, RefToNKChild, Circle1, Circle2, Circle3,
|
||||
|
|
@ -390,6 +391,25 @@ class TestFixtures(TestCase):
|
|||
stderr.getvalue().startswith('Problem installing fixture')
|
||||
)
|
||||
|
||||
_cur_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
@override_settings(FIXTURE_DIRS=[os.path.join(_cur_dir, 'fixtures_1'),
|
||||
os.path.join(_cur_dir, 'fixtures_2')])
|
||||
def test_loaddata_forward_refs_split_fixtures(self):
|
||||
"""
|
||||
Regression for #17530 - should be able to cope with forward references
|
||||
when the fixtures are not in the same files or directories.
|
||||
"""
|
||||
management.call_command(
|
||||
'loaddata',
|
||||
'forward_ref_1.json',
|
||||
'forward_ref_2.json',
|
||||
verbosity=0,
|
||||
commit=False
|
||||
)
|
||||
self.assertEqual(Book.objects.all()[0].id, 1)
|
||||
self.assertEqual(Person.objects.all()[0].id, 4)
|
||||
|
||||
def test_loaddata_no_fixture_specified(self):
|
||||
"""
|
||||
Regression for #7043 - Error is quickly reported when no fixtures is provided in the command line.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue