]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- reinstate "dont set up integer index in keymap if we're on cexts",
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 27 Jan 2016 19:49:40 +0000 (14:49 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 27 Jan 2016 19:49:40 +0000 (14:49 -0500)
and this time also fix the cext itself to properly handle int vs. long
on py2k

lib/sqlalchemy/cextension/resultproxy.c
lib/sqlalchemy/engine/result.py

index 9c4d0c7e49e4e042bd239befdcc92c29ff7e4cad..a87fe7b56542e4b439a7f421ce2cd0b2bcfb4dfe 100644 (file)
@@ -263,7 +263,7 @@ BaseRowProxy_subscript(BaseRowProxy *self, PyObject *key)
 #if PY_MAJOR_VERSION < 3
     if (PyInt_CheckExact(key)) {
         index = PyInt_AS_LONG(key);
-    }
+    } else
 #endif
 
     if (PyLong_CheckExact(key)) {
index cc4ac74cd5931bcfa7f248ad5ad0beeee1ed5e08..39f4fc50c903d58ad8ec23dcbab7fa3d306d0c5e 100644 (file)
@@ -35,7 +35,10 @@ except ImportError:
 
 try:
     from sqlalchemy.cresultproxy import BaseRowProxy
+    _baserowproxy_usecext = True
 except ImportError:
+    _baserowproxy_usecext = False
+
     class BaseRowProxy(object):
         __slots__ = ('_parent', '_row', '_processors', '_keymap')
 
@@ -210,11 +213,13 @@ class ResultMetaData(object):
             context, cursor_description, result_columns,
             num_ctx_cols, cols_are_ordered, textual_ordered)
 
-        # keymap indexes by integer index...
-        self._keymap = dict([
-            (elem[0], (elem[3], elem[4], elem[0]))
-            for elem in raw
-        ])
+        self._keymap = {}
+        if not _baserowproxy_usecext:
+            # keymap indexes by integer index...
+            self._keymap.update([
+                (elem[0], (elem[3], elem[4], elem[0]))
+                for elem in raw
+            ])
 
         # processors in key order for certain per-row
         # views like __iter__ and slices