-
Notifications
You must be signed in to change notification settings - Fork 14
Closed
Description
Hi.
I am using SQLite 3 and I have this model
class AuthConfig(models.Model):
username = fields.EncryptedCharField(max_length=150, null=True, blank=True, verbose_name=_("Username"))
password = fields.EncryptedCharField(null=True, blank=True, max_length=150, verbose_name=_("Password"))
token = fields.EncryptedCharField(max_length=1500, null=True, blank=True, verbose_name=_("Token"))
My migration looks like this
migrations.RunPython(
Migrator("integrations", "AuthConfig", "username").encrypt, reverse_code=Migrator("integrations", 'AuthConfig', 'username').decrypt
),
migrations.RunPython(
Migrator("integrations", "AuthConfig", "password").encrypt, reverse_code=Migrator("integrations", 'AuthConfig', 'password').decrypt
),
migrations.RunPython(
Migrator("integrations", "AuthConfig", "token").encrypt, reverse_code=Migrator("integrations", 'AuthConfig', 'token').decrypt
),
When the original field value is saved in the database as NULL
, applying the migration will change the value to a string "None"
because of the string interpolation used to construct an UPDATE
statement in Migrator
s execute()
method.
To reproduce:
- Make a model with an optional field (null=True)
- Create a record with that field being NULL
- Convert the field to an Encrypted field
- Run the migration with Migrator
Metadata
Metadata
Assignees
Labels
No labels