Field.from_db_value no longer supports the context param in 2.0

This commit is contained in:
Jeff Bradberry
2019-06-21 16:32:24 -04:00
parent f24b08316d
commit a6edc46cc3

View File

@@ -77,10 +77,10 @@ class JSONField(upstream_JSONField):
def db_type(self, connection): def db_type(self, connection):
return 'text' return 'text'
def from_db_value(self, value, expression, connection, context): def from_db_value(self, value, expression, connection):
if value in {'', None} and not self.null: if value in {'', None} and not self.null:
return {} return {}
return super(JSONField, self).from_db_value(value, expression, connection, context) return super(JSONField, self).from_db_value(value, expression, connection)
class JSONBField(upstream_JSONBField): class JSONBField(upstream_JSONBField):
@@ -97,7 +97,7 @@ class JSONBField(upstream_JSONBField):
value, connection, prepared value, connection, prepared
) )
def from_db_value(self, value, expression, connection, context): def from_db_value(self, value, expression, connection):
# Work around a bug in django-jsonfield # Work around a bug in django-jsonfield
# https://bitbucket.org/schinckel/django-jsonfield/issues/57/cannot-use-in-the-same-project-as-djangos # https://bitbucket.org/schinckel/django-jsonfield/issues/57/cannot-use-in-the-same-project-as-djangos
if isinstance(value, str): if isinstance(value, str):
@@ -972,7 +972,7 @@ class OAuth2ClientSecretField(models.CharField):
encrypt_value(value), connection, prepared encrypt_value(value), connection, prepared
) )
def from_db_value(self, value, expression, connection, context): def from_db_value(self, value, expression, connection):
if value and value.startswith('$encrypted$'): if value and value.startswith('$encrypted$'):
return decrypt_value(get_encryption_key('value', pk=None), value) return decrypt_value(get_encryption_key('value', pk=None), value)
return value return value