dcwatson / django-pgcrypto

Python and Django utilities for encrypted fields using pgcrypto.
BSD 2-Clause "Simplified" License
69 stars 23 forks source link

Lookup on EncryptedCharField in shell fails on postgresql #17

Closed MaZZly closed 9 years ago

MaZZly commented 9 years ago

Django: 1.8 Database: PostgreSQL 9.3.3

Doing a lookup on a pgcrypto.EncryptedCharField in the shell throws the error AttributeError: 'Col' object has no attribute 'source'

Stacktrace:

>>> Person.objects.filter(last_name='test')
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/home/ubuntu/www/app/venv/local/lib/python2.7/site-packages/django/db/models/query.py", line 138, in __repr__
    data = list(self[:REPR_OUTPUT_SIZE + 1])
  File "/home/ubuntu/www/app/venv/local/lib/python2.7/site-packages/django/db/models/query.py", line 162, in __iter__
    self._fetch_all()
  File "/home/ubuntu/www/app/venv/local/lib/python2.7/site-packages/django/db/models/query.py", line 965, in _fetch_all
    self._result_cache = list(self.iterator())
  File "/home/ubuntu/www/app/venv/local/lib/python2.7/site-packages/django/db/models/query.py", line 238, in iterator
    results = compiler.execute_sql()
  File "/home/ubuntu/www/app/venv/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 829, in execute_sql
    sql, params = self.as_sql()
  File "/home/ubuntu/www/app/venv/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 387, in as_sql
    where, w_params = self.compile(self.query.where)
  File "/home/ubuntu/www/app/venv/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 357, in compile
    sql, params = node.as_sql(self, self.connection)
  File "/home/ubuntu/www/app/venv/local/lib/python2.7/site-packages/django/db/models/sql/where.py", line 104, in as_sql
    sql, params = compiler.compile(child)
  File "/home/ubuntu/www/app/venv/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 355, in compile
    sql, params = vendor_impl(self, self.connection)
  File "/home/ubuntu/www/app/venv/local/lib/python2.7/site-packages/pgcrypto/fields.py", line 223, in as_postgresql
    params = lhs_params + [self.lhs.source.cipher_key] + rhs_params
AttributeError: 'Col' object has no attribute 'source'