summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/cextension/resultproxy.c
diff options
context:
space:
mode:
authorGaëtan de Menten <gdementen@gmail.com>2010-04-11 20:56:39 +0200
committerGaëtan de Menten <gdementen@gmail.com>2010-04-11 20:56:39 +0200
commitaa9506a0da35b78b2c4b1c62b1700fe33f5bea2e (patch)
tree6037643748944c11f5115c4b2749aa21facf1607 /lib/sqlalchemy/cextension/resultproxy.c
parent646afe94ffdcc8eafeafdeb09b5dae4b34483794 (diff)
downloadsqlalchemy-aa9506a0da35b78b2c4b1c62b1700fe33f5bea2e.tar.gz
- engines
- The C extension now also works with DBAPIs which use custom sequences as row (and not only tuples). [ticket:1757]
Diffstat (limited to 'lib/sqlalchemy/cextension/resultproxy.c')
-rw-r--r--lib/sqlalchemy/cextension/resultproxy.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/sqlalchemy/cextension/resultproxy.c b/lib/sqlalchemy/cextension/resultproxy.c
index 5d9100469..50830b660 100644
--- a/lib/sqlalchemy/cextension/resultproxy.c
+++ b/lib/sqlalchemy/cextension/resultproxy.c
@@ -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;