diff options
| author | Tim Graham <timograham@gmail.com> | 2016-09-19 15:56:53 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-09-20 10:14:47 -0400 |
| commit | b5aac66b28c615b2bda63548cbd695dbb5a0c381 (patch) | |
| tree | fe85eef15ca74d42d407af32dca6597da127555e | |
| parent | 3347dc6b4e1987ed1bb70e9033be69c426f53e84 (diff) | |
Refs #27025 -- Fixed ArrayField querying on Python 3.6.
Python 3.6 parses strings like '0_1' as numeric literals.
http://bugs.python.org/issue26331
| -rw-r--r-- | django/contrib/postgres/fields/array.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/django/contrib/postgres/fields/array.py b/django/contrib/postgres/fields/array.py index d123ce769d..e570a3273d 100644 --- a/django/contrib/postgres/fields/array.py +++ b/django/contrib/postgres/fields/array.py @@ -129,13 +129,14 @@ class ArrayField(Field): transform = super(ArrayField, self).get_transform(name) if transform: return transform - try: - index = int(name) - except ValueError: - pass - else: - index += 1 # postgres uses 1-indexing - return IndexTransformFactory(index, self.base_field) + if '_' not in name: + try: + index = int(name) + except ValueError: + pass + else: + index += 1 # postgres uses 1-indexing + return IndexTransformFactory(index, self.base_field) try: start, end = name.split('_') start = int(start) + 1 |
