-
Notifications
You must be signed in to change notification settings - Fork 50
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
Wrong max_length value when using south #10
Comments
Please, provide a patch with unittest. |
I didn't manage to pass django_fields tests. Output from manage.py test django_fields: ERROR: test_date_encryption (example.django_fields.tests.DateEncryptTests)Traceback (most recent call last): ERROR: test_date_time_encryption (example.django_fields.tests.DateEncryptTests)Traceback (most recent call last): Ran 22 tests in 0.122s I use Django 1.3.1 |
The problem was in my code |
Hi. @DXist why did you reopened this issue? |
Hi! I figured out that south introspects wrong value for max_length (see #20). It should honour initial max_length value (maximum length of unencrypted data) that is saved in unencrypted_length field attribute. The resulting max_length value is changed to hold encrypted data with padding so it shouldn't be introspected. The pull request contains an introspection rule to fix this problem for EncryptedCharField and subclasses. |
I'm not sure why max_length is calculated this way:
kwargs['max_length'] = max_length * 2 + len(self.prefix)
When I use south I get field length max_length * 2 + len(self.prefix) in my migration file and (max_length * 2 + len(self.prefix))*2 + len(self.prefix) in database.
In my opinion max_length shouldn't be changed if it is in kwargs and another key value like 'unencrypted_max_length' should be used:
The text was updated successfully, but these errors were encountered: