@@ -99,3 +99,33 @@ For example, to find a patient by their SSN, you can do the following::
9999 >>> patient = Patient.objects.get(ssn="123-45-6789")
100100 >>> patient.name
101101 'Bob'
102+
103+
104+ Limitations
105+ ~~~~~~~~~~~
106+
107+ When using Django QuerySets with MongoDB Queryable Encryption, it’s important to
108+ understand that many typical ORM features are restricted because the database
109+ only sees encrypted ciphertext, not plaintext. This means that only certain
110+ query types are supported, and a lot of filtering, sorting, and aggregating must
111+ be done client-side after decryption. Key limitations include:
112+
113+ - **Equality only filtering ** – You can filter encrypted fields using exact
114+ matches, but operators like contains, startswith, regex, or unsupported range
115+ lookups will not work.
116+ - **No server-side sorting ** – .order_by() on encrypted fields won’t produce
117+ meaningful results; sorting needs to happen after decryption in Python.
118+ - **No server-side aggregation ** – Functions like annotate() or aggregate()
119+ won’t operate on encrypted fields; you must aggregate locally after fetching
120+ data.
121+ - **Index constraints ** – Queries are only possible on encrypted fields that
122+ have a configured queryable encryption index and keys available on the client.
123+ - **No joins on encrypted fields ** – Filtering across relationships using
124+ encrypted foreign keys is unsupported because matching must happen
125+ client-side.
126+ - **Admin/debug limitations ** – You’ll need to integrate client-side decryption
127+ for Django admin or tools, otherwise you’ll see ciphertext.
128+
129+ In short, when working with Queryable Encryption, design your queries to use
130+ exact matches only on encrypted fields, and plan to handle any sorting or
131+ aggregation after results are decrypted in your application code.
0 commit comments