JSONField_cmp.diff
src/authentic2/compat.py | ||
---|---|---|
20 | 20 |
from django.db import connection |
21 | 21 |
from django.db.utils import OperationalError |
22 | 22 |
from django.core.exceptions import ImproperlyConfigured |
23 |
from django.db.models import Field |
|
23 | 24 | |
24 | 25 |
from django.contrib.auth.tokens import PasswordResetTokenGenerator |
25 | 26 | |
... | ... | |
43 | 44 |
__dj11_field = None |
44 | 45 |
__jsonfield_field = None |
45 | 46 |
__name = None |
47 |
creation_counter = 0 |
|
46 | 48 | |
47 | 49 |
def __init__(self, *args, **kwargs): |
48 | 50 |
self.__args = args |
... | ... | |
58 | 60 |
self.__jsonfield_field = JSONField(*args, **kwargs) |
59 | 61 |
except ImportError: |
60 | 62 |
pass |
63 |
self.creation_counter = Field.creation_counter |
|
64 |
Field.creation_counter += 1 |
|
61 | 65 | |
62 | 66 |
def __real_field__(self): |
63 | 67 |
if use_django_native_field(): |
... | ... | |
108 | 112 |
new.__jsonfield_field = new.__jsonfield_field.clone() |
109 | 113 |
return new |
110 | 114 | |
115 |
# used by bisect |
|
116 |
def __eq__(self, other): |
|
117 |
if isinstance(other, Field): |
|
118 |
return self.creation_counter == other.creation_counter |
|
119 |
return NotImplemented |
|
120 | ||
121 |
def __lt__(self, other): |
|
122 |
if isinstance(other, Field): |
|
123 |
return self.creation_counter < other.creation_counter |
|
124 |
return NotImplemented |
|
111 | 125 | |
112 | 126 |
try: |
113 | 127 |
import jsonfield.fields |