#29852: Infinite migrations when using SimpleLazyObject in field arguments
------------------------------+------------------------------------
Reporter: Javier Buzzi | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------
Changes (by Simon Charette):
* needs_better_patch: 0 => 1
* has_patch: 0 => 1
Comment:
As I mentioned on the PR serializing
`MinValueValidator(SimpleLazyObject(datetime.datetime.now))` to
`MinValueValidator(datetime.datetime.now)` won't work as it generates
broken code
{{{#!python
> from datetime import datetime
> from django.core.validators import MinValueValidator
> MinValueValidator(datetime.now)(datetime(2018, 5, 15))
TypeError: can't compare datetime.datetime to builtin_function_or_method
}}}
The only solution I can think of involves adjusting
`SimpleLazyObject.__eq__(other)` to special case `isinstance(other,
SimpleLazyObject)` but that would break some assumptions
e.g. if it was to be changed
{{{#!python
> datetime.datetime.now() == datetime.datetime.now()
False
> SimpleLazyObject(datetime.datetime.now) ==
SimpleLazyObject(datetime.datetime.now)
True # Currently False
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/29852#comment:4>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/069.4bc48256f55a91585f345534168bc65a%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.