Commits

Alex Burgel committed ce31fd8

complex keys (like from appengine) are not slicable

Comments (0)

Files changed (1)

djangotoolbox/db/basecompiler.py

         elif isinstance(value, str):
             value = str(value)
 
-        if lookup_type in ('startswith', 'istartswith'):
-            value = value[:-1]
-        elif lookup_type in ('endswith', 'iendswith'):
-            value = value[1:]
-        elif lookup_type in ('contains', 'icontains'):
-            value = value[1:-1]
+        if hasattr(value, '__getitem__'):
+            if lookup_type in ('startswith', 'istartswith'):
+                value = value[:-1]
+            elif lookup_type in ('endswith', 'iendswith'):
+                value = value[1:]
+            elif lookup_type in ('contains', 'icontains'):
+                value = value[1:-1]
 
         return value