diff options
author | Tim Graham <timograham@gmail.com> | 2013-07-16 09:10:04 -0400 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2013-07-24 06:56:33 -0400 |
commit | 31c13a99bb9ebdaf12ccab4e880c5da930d86e79 (patch) | |
tree | d7b2fcf5cbc526bf63ffe1a3b521ccc0e3f1d39c /tests/fixtures_model_package | |
parent | c928725b933ff479c04e8a7fb74c4dc2ba138aa7 (diff) | |
download | django-31c13a99bb9ebdaf12ccab4e880c5da930d86e79.tar.gz |
Fixed #14300 -- Fixed initial SQL location if models is a package.
Thanks al_the_x for the report and fheinz for the draft patch.
Diffstat (limited to 'tests/fixtures_model_package')
-rw-r--r-- | tests/fixtures_model_package/models/sql/book.sql | 2 | ||||
-rw-r--r-- | tests/fixtures_model_package/sql/book.sql | 1 | ||||
-rw-r--r-- | tests/fixtures_model_package/tests.py | 17 |
3 files changed, 20 insertions, 0 deletions
diff --git a/tests/fixtures_model_package/models/sql/book.sql b/tests/fixtures_model_package/models/sql/book.sql new file mode 100644 index 0000000000..9b3918f4d7 --- /dev/null +++ b/tests/fixtures_model_package/models/sql/book.sql @@ -0,0 +1,2 @@ +-- Deprecated search path for custom SQL -- remove in Django 1.9 +INSERT INTO fixtures_model_package_book (name) VALUES ('My Deprecated Book'); diff --git a/tests/fixtures_model_package/sql/book.sql b/tests/fixtures_model_package/sql/book.sql new file mode 100644 index 0000000000..21b1d9465b --- /dev/null +++ b/tests/fixtures_model_package/sql/book.sql @@ -0,0 +1 @@ +INSERT INTO fixtures_model_package_book (name) VALUES ('My Book'); diff --git a/tests/fixtures_model_package/tests.py b/tests/fixtures_model_package/tests.py index ad82267da3..1e22ac9833 100644 --- a/tests/fixtures_model_package/tests.py +++ b/tests/fixtures_model_package/tests.py @@ -5,6 +5,7 @@ import warnings from django.core import management from django.db import transaction from django.test import TestCase, TransactionTestCase +from django.utils.six import StringIO from .models import Article, Book @@ -110,3 +111,19 @@ class FixtureTestCase(TestCase): ], lambda a: a.headline, ) + + +class InitialSQLTests(TestCase): + + def test_custom_sql(self): + """ + #14300 -- Verify that custom_sql_for_model searches `app/sql` and not + `app/models/sql` (the old location will work until Django 1.9) + """ + out = StringIO() + management.call_command("sqlcustom", "fixtures_model_package", stdout=out) + output = out.getvalue() + self.assertTrue("INSERT INTO fixtures_model_package_book (name) " + "VALUES ('My Book')" in output) + # value from deprecated search path models/sql (remove in Django 1.9) + self.assertTrue("Deprecated Book" in output) |