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
This commit is contained in:
Tim Graham 2016-09-19 15:56:53 -04:00
parent 3347dc6b4e
commit b5aac66b28
1 changed files with 8 additions and 7 deletions

View File

@ -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