Changes between Initial Version and Version 1 of Ticket #35434, comment 10


Ignore:
Timestamp:
May 5, 2024, 1:02:30 PM (7 months ago)
Author:
Simon Charette

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #35434, comment 10

    initial v1  
    1 There's a difference between lookup against the database (e.g. `filter(pet_id=str(pet.id))`) which performs implicit conversions and direct model attribute assignments. I would argue that if you explicitly assign the string representation of objects meant to be stored in a field to a model instance you are effectively doing things wrong.
     1There's a difference between lookup against the database (e.g. `filter(pet_id=str(pet.id))`) which performs implicit conversions and direct model attribute assignments. I would argue that if you explicitly assign the string representation of objects meant to be stored in a field to a model instance you are effectively doing something wrong.
     2
     3One concrete example of that is model equality `Model.__eq__` which is implemented by comparing the bases and the primary key value of the compared objects. Since `value = uuid.uuid4(); value != str(value)` then `Object(pk=value) != Object(pk=str(value))`.
     4
     5I don't think it's attainable to have the ORM to perform type conversion every time it needs to perform equality checks.
Back to Top