Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion oscar/models/fields/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ def contribute_to_class(self, cls, name, **kwargs):
super(NullCharField, self).contribute_to_class(cls, name, **kwargs)
setattr(cls, self.name, Creator(self))

def from_db_value(self, value, expression, connection, context):
#def from_db_value(self, value, expression, connection, context): # removed due to context error
def from_db_value(self, value, expression, connection):
Comment on lines +118 to +119
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: UppercaseCharField.from_db_value() signature is incompatible with Django 5.2.5, expecting a context argument that is no longer passed, causing a TypeError.
Severity: CRITICAL | Confidence: High

🔍 Detailed Analysis

When a model instance containing an UppercaseCharField (e.g., postcode in address models) is retrieved from the database, Django 5.2.5 invokes UppercaseCharField.from_db_value() with three arguments (value, expression, connection). However, the UppercaseCharField.from_db_value() method signature at line 84 still expects four arguments, including context. This mismatch causes a TypeError: from_db_value() missing 1 required positional argument: 'context', leading to a server crash during database queries for address-related models.

💡 Suggested Fix

Update the UppercaseCharField.from_db_value() method signature at line 84 to remove the context parameter, matching the fix applied to NullCharField. The signature should be def from_db_value(self, value, expression, connection):.

🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: oscar/models/fields/__init__.py#L118-L119

Potential issue: When a model instance containing an `UppercaseCharField` (e.g.,
`postcode` in address models) is retrieved from the database, Django 5.2.5 invokes
`UppercaseCharField.from_db_value()` with three arguments (`value`, `expression`,
`connection`). However, the `UppercaseCharField.from_db_value()` method signature at
line 84 still expects four arguments, including `context`. This mismatch causes a
`TypeError: from_db_value() missing 1 required positional argument: 'context'`, leading
to a server crash during database queries for address-related models.

Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 4199600

return self.to_python(value)

def to_python(self, value):
Expand Down
Loading