]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- engines
authorGaëtan de Menten <gdementen@gmail.com>
Sun, 11 Apr 2010 18:56:39 +0000 (20:56 +0200)
committerGaëtan de Menten <gdementen@gmail.com>
Sun, 11 Apr 2010 18:56:39 +0000 (20:56 +0200)
  - The C extension now also works with DBAPIs which use custom
    sequences as row (and not only tuples). [ticket:1757]

CHANGES
lib/sqlalchemy/cextension/resultproxy.c

diff --git a/CHANGES b/CHANGES
index 4831295913b5017faced17731071a9508e210e0e..99b8ffa815b0ed2b28755c07710d7683422063af 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -35,6 +35,10 @@ CHANGES
     as the sorting functions now require hashable objects
     only.  [ticket:1756]
     
+- engines
+  - The C extension now also works with DBAPIs which use custom
+    sequences as row (and not only tuples). [ticket:1757]
+
 - sql
   - Restored some bind-labeling logic from 0.5 which ensures
     that tables with column names that overlap another column
index 5d9100469eb22f3d255e5a1b800095326f08d318..50830b660fb529bff48182159098b429195c3b7c 100644 (file)
@@ -150,8 +150,8 @@ BaseRowProxy_processvalues(PyObject *values, PyObject *processors, int astuple)
     PyObject **valueptr, **funcptr, **resultptr;
     PyObject *func, *result, *processed_value, *values_fastseq;
 
-    num_values = Py_SIZE(values);
-    num_processors = Py_SIZE(processors);
+    num_values = PySequence_Length(values);
+    num_processors = PyList_Size(processors);
     if (num_values != num_processors) {
         PyErr_Format(PyExc_RuntimeError,
             "number of values in row (%d) differ from number of column "
@@ -225,7 +225,7 @@ BaseRowProxy_iter(BaseRowProxy *self)
 static Py_ssize_t
 BaseRowProxy_length(BaseRowProxy *self)
 {
-    return Py_SIZE(self->row);
+    return PySequence_Length(self->row);
 }
 
 static PyObject *
@@ -233,7 +233,7 @@ BaseRowProxy_subscript(BaseRowProxy *self, PyObject *key)
 {
     PyObject *processors, *values;
     PyObject *processor, *value;
-    PyObject *record, *result, *indexobject;
+    PyObject *row, *record, *result, *indexobject;
     PyObject *exc_module, *exception;
     char *cstr_key;
     long index;
@@ -303,7 +303,11 @@ BaseRowProxy_subscript(BaseRowProxy *self, PyObject *key)
     if (processor == NULL)
         return NULL;
 
-    value = PyTuple_GetItem(self->row, index);
+    row = self->row;
+    if (PyTuple_CheckExact(row))
+        value = PyTuple_GetItem(row, index);
+    else
+        value = PySequence_GetItem(row, index);
     if (value == NULL)
         return NULL;