mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-07-10 16:22:33 +03:00
Fixes to row_factory.
This commit is contained in:
parent
091270db2a
commit
818caa5637
|
@ -1,3 +1,12 @@
|
||||||
|
2004-11-19 Federico Di Gregorio <fog@debian.org>
|
||||||
|
|
||||||
|
* psycopg/cursor_type.c (_psyco_curs_buildrow_fill): now standard
|
||||||
|
tuples are filled using PyTuple_SET_ITEM while extended types
|
||||||
|
(created via row_factory) are filled using PySequence_SetItem.
|
||||||
|
|
||||||
|
* psycopg/cursor_type.c: change cursor attribute name from
|
||||||
|
tuple_factory to row_factory.
|
||||||
|
|
||||||
2004-10-14 Federico Di Gregorio <fog@debian.org>
|
2004-10-14 Federico Di Gregorio <fog@debian.org>
|
||||||
|
|
||||||
* psycopg/cursor_type.c (_psyco_curs_buildrow_fill): now we use
|
* psycopg/cursor_type.c (_psyco_curs_buildrow_fill): now we use
|
||||||
|
|
|
@ -508,7 +508,8 @@ _psyco_curs_prefetch(cursorObject *self)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
_psyco_curs_buildrow_fill(cursorObject *self, PyObject *res, int row, int n)
|
_psyco_curs_buildrow_fill(cursorObject *self, PyObject *res,
|
||||||
|
int row, int n, int istuple)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
PyObject *str, *val;
|
PyObject *str, *val;
|
||||||
|
@ -537,9 +538,14 @@ _psyco_curs_buildrow_fill(cursorObject *self, PyObject *res, int row, int n)
|
||||||
|
|
||||||
if (val) {
|
if (val) {
|
||||||
Dprintf("_psyco_curs_buildrow: val->refcnt = %d", val->ob_refcnt);
|
Dprintf("_psyco_curs_buildrow: val->refcnt = %d", val->ob_refcnt);
|
||||||
|
if (istuple) {
|
||||||
|
PyTuple_SET_ITEM(res, i, val);
|
||||||
|
}
|
||||||
|
else {
|
||||||
PySequence_SetItem(res, i, val);
|
PySequence_SetItem(res, i, val);
|
||||||
Py_DECREF(val);
|
Py_DECREF(val);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
/* an error occurred in the type system, we return NULL to raise
|
/* an error occurred in the type system, we return NULL to raise
|
||||||
an exception. the typecast code should already have set the
|
an exception. the typecast code should already have set the
|
||||||
|
@ -559,7 +565,7 @@ _psyco_curs_buildrow(cursorObject *self, int row)
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
n = PQnfields(self->pgres);
|
n = PQnfields(self->pgres);
|
||||||
return _psyco_curs_buildrow_fill(self, PyTuple_New(n), row, n);
|
return _psyco_curs_buildrow_fill(self, PyTuple_New(n), row, n, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
|
@ -572,7 +578,7 @@ _psyco_curs_buildrow_with_factory(cursorObject *self, int row)
|
||||||
if ((res = PyObject_CallFunction(self->tuple_factory, "O", self))== NULL)
|
if ((res = PyObject_CallFunction(self->tuple_factory, "O", self))== NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return _psyco_curs_buildrow_fill(self, res, row, n);
|
return _psyco_curs_buildrow_fill(self, res, row, n, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1030,7 +1036,7 @@ static struct PyMemberDef cursorObject_members[] = {
|
||||||
#ifdef PSYCOPG_EXTENSIONS
|
#ifdef PSYCOPG_EXTENSIONS
|
||||||
{"statusmessage", T_OBJECT, OFFSETOF(pgstatus), RO},
|
{"statusmessage", T_OBJECT, OFFSETOF(pgstatus), RO},
|
||||||
{"query", T_STRING, OFFSETOF(query), RO},
|
{"query", T_STRING, OFFSETOF(query), RO},
|
||||||
{"tuple_factory", T_OBJECT, OFFSETOF(tuple_factory), 0},
|
{"row_factory", T_OBJECT, OFFSETOF(tuple_factory), 0},
|
||||||
{"tzinfo_factory", T_OBJECT, OFFSETOF(tzinfo_factory), 0},
|
{"tzinfo_factory", T_OBJECT, OFFSETOF(tzinfo_factory), 0},
|
||||||
#endif
|
#endif
|
||||||
{NULL}
|
{NULL}
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -47,7 +47,7 @@ from distutils.core import setup, Extension
|
||||||
from distutils.sysconfig import get_python_inc
|
from distutils.sysconfig import get_python_inc
|
||||||
import distutils.ccompiler
|
import distutils.ccompiler
|
||||||
|
|
||||||
PSYCOPG_VERSION = '1.99.10'
|
PSYCOPG_VERSION = '1.99.11'
|
||||||
|
|
||||||
have_pydatetime = False
|
have_pydatetime = False
|
||||||
have_mxdatetime = False
|
have_mxdatetime = False
|
||||||
|
|
Loading…
Reference in New Issue
Block a user