mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Fixed #34165 -- Made permissions creation respect the "using" parameter.
This commit is contained in:
committed by
Mariusz Felisiak
parent
0bd2c0c901
commit
5aaad5f39c
@@ -1485,3 +1485,22 @@ class CreatePermissionsTests(TestCase):
|
||||
codename=codename,
|
||||
).exists()
|
||||
)
|
||||
|
||||
|
||||
class DefaultDBRouter:
|
||||
"""Route all writes to default."""
|
||||
|
||||
def db_for_write(self, model, **hints):
|
||||
return "default"
|
||||
|
||||
|
||||
@override_settings(DATABASE_ROUTERS=[DefaultDBRouter()])
|
||||
class CreatePermissionsMultipleDatabasesTests(TestCase):
|
||||
databases = {"default", "other"}
|
||||
|
||||
def test_set_permissions_fk_to_using_parameter(self):
|
||||
Permission.objects.using("other").delete()
|
||||
with self.assertNumQueries(6, using="other") as captured_queries:
|
||||
create_permissions(apps.get_app_config("auth"), verbosity=0, using="other")
|
||||
self.assertIn("INSERT INTO", captured_queries[-1]["sql"].upper())
|
||||
self.assertGreater(Permission.objects.using("other").count(), 0)
|
||||
|
||||
Reference in New Issue
Block a user