Skip to content

Commit 9716016

Browse files
committed
Fix Router.db_for_read()/write()
1 parent c4cbdc9 commit 9716016

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

.github/workflows/mongodb_settings.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,12 @@
3434

3535

3636
class EncryptedRouter:
37-
# def db_for_read(self, model, **hints):
38-
# if model_has_encrypted_fields(model):
39-
# return "encrypted"
40-
# return "default"
41-
# db_for_write = db_for_read
37+
def db_for_read(self, model, **hints):
38+
if model._meta.app_label == "encryption_":
39+
return "encrypted"
40+
return None
41+
42+
db_for_write = db_for_read
4243

4344
def allow_migrate(self, db, app_label, model_name=None, **hints):
4445
# The encryption_ app's models are only created in the encrypted

tests/encryption_/test_fields.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def test_array(self):
7777
self.assertEqual(len(movie.cast), 2)
7878
self.assertEqual(movie.cast[0].name, "Actor One")
7979
self.assertEqual(movie.cast[1].name, "Actor Two")
80-
# self.assertEncrypted(self.movie, "cast")
80+
self.assertEncrypted(self.movie, "cast")
8181

8282

8383
class FieldTests(EncryptionTestCase):

0 commit comments

Comments
 (0)