Skip to content

INTPYTHON-527 Add Queryable Encryption support #329

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

aclark4life
Copy link
Collaborator

@aclark4life aclark4life commented Jun 27, 2025

Previous attempts and additional context here:

@aclark4life

This comment was marked as resolved.

@timgraham

This comment was marked as resolved.

@aclark4life

This comment was marked as resolved.

@timgraham

This comment was marked as resolved.

@aclark4life

This comment was marked as resolved.

@aclark4life

This comment was marked as resolved.

@aclark4life

This comment was marked as resolved.

@aclark4life

This comment was marked as resolved.

@timgraham

This comment was marked as resolved.

@aclark4life

This comment was marked as resolved.

@aclark4life

This comment was marked as resolved.

@aclark4life

This comment was marked as resolved.

@timgraham

This comment was marked as resolved.

@aclark4life

This comment was marked as resolved.

@timgraham

This comment was marked as resolved.

aclark4life and others added 9 commits August 13, 2025 12:08
QE Doc flow

- Three top level (or close to it) docs
 - How to guide on QE configuration
 - QE field guide (moved out of model field ref to its own section)
 - Topic guide on QE usage
- Planning to finish QE setup in the how-to doc then switch back to the
  topic doc to explain the workflow.
In the QE topics guide I'm going to explain how to develop a patient model
similar to the Python QE tutorial and the encryption test suite.

If embedding were possible now, I could present the same example. Since
embedded models are a WIP I may either:

- design the guide to work around that issue
- design the guide to anticipate resolution of that issue

In ether case, I'll try to wrap this 24-48 hour docs jam having covered
everything I know about QE and Django and having presented it to Django
folks in a way we can support.
- Configuring the encrypted_fields_map section
- Configuring the Automatic Encryption Shared Library
Copilot

This comment was marked as resolved.

@aclark4life aclark4life requested a review from Copilot August 14, 2025 00:23
Copilot

This comment was marked as resolved.

aclark4life and others added 3 commits August 18, 2025 17:01
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Collaborator

@timgraham timgraham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(a very cursory review of some recent changes; I didn't comment on documentation yet)

@@ -15,7 +15,7 @@

@skipUnlessDBFeature("supports_queryable_encryption")
@override_settings(DATABASE_ROUTERS=[TestEncryptedRouter()])
class QueryableEncryptionTestCase(TransactionTestCase):
class QueryableEncryptionTests(TransactionTestCase):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is indeed a base "TestCase" as it has no tests itself. I think it's useful to keep this class for the shared skipUnless and override settings, even if setUp is removed per my comment below.

from django.db import models


class EncryptedFieldMixin(models.Field):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't remember this inheriting from Field. Was it a recent change? I don't think it should considering the field it's mixed in with should already do that inheriting.


class Command(BaseCommand):
help = """
This command shows the mapping of encrypted fields to attributes
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old wording "Shows..." is more consistent with the built-in command's documentation. Avoid boilerplate like "This command...", "this option..."

``EncryptedFieldMixin``
=======================

.. class:: EncryptedFieldMixin(models.Field)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inheritance isn't documented here, but rather (sometimess) the __init__() signature.
Example from Django's docs: .. class:: TimestampSigner(*, key=None, sep=':', salt=None, algorithm='sha256')

connection = connections["encrypted"]
with connection.schema_editor() as editor:
client = connection.connection
encrypted_fields_map = editor._get_encrypted_fields_map(self.patient, client)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test happens to work with either, but the first argument is supposed to be a model class rather than a model instance.

Comment on lines +23 to +25
"""
Used in schema and field tests.
"""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's not enough shared data to justify a common setUp method. Many of these models are used in only one test, so it's wasteful to create them before every test. If it helps, you can make many of the fields nullable to make creating objects easier. (e.g. test_datefield can create a PatientRecord with only a date).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants