mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-26 02:43:43 +03:00
Fixed problem with array results that begin with "[...]=". (Closes: #80)
This commit is contained in:
parent
31d85750b0
commit
e72f3dba40
|
@ -1,3 +1,10 @@
|
||||||
|
2005-12-11 Federico Di Gregorio <fog@initd.org>
|
||||||
|
|
||||||
|
* psycopg/typecast_array.c (typecast_array_cleanup): added functio
|
||||||
|
to cleanup the "[...]=" part of an array result. This probably will
|
||||||
|
need some more work for nested arrays but it fixed every test I was
|
||||||
|
able to write. (Closes: #80)
|
||||||
|
|
||||||
2005-12-11 Federico Di Gregorio <fog@initd.org>
|
2005-12-11 Federico Di Gregorio <fog@initd.org>
|
||||||
|
|
||||||
* setup.py: half-applied patch from Tavis to specify mx_include_dir
|
* setup.py: half-applied patch from Tavis to specify mx_include_dir
|
||||||
|
|
|
@ -21,6 +21,27 @@
|
||||||
|
|
||||||
#define MAX_DIMENSIONS 16
|
#define MAX_DIMENSIONS 16
|
||||||
|
|
||||||
|
/** typecast_array_cleanup - remove the horrible [...]= stuff **/
|
||||||
|
|
||||||
|
static int
|
||||||
|
typecast_array_cleanup(char **str, int *len)
|
||||||
|
{
|
||||||
|
int i, depth = 1;
|
||||||
|
|
||||||
|
if ((*str)[0] != '[') return -1;
|
||||||
|
|
||||||
|
for (i=1 ; depth > 0 && i < *len ; i++) {
|
||||||
|
if ((*str)[i] == '[')
|
||||||
|
depth += 1;
|
||||||
|
else if ((*str)[i] == ']')
|
||||||
|
depth -= 1;
|
||||||
|
}
|
||||||
|
if ((*str)[i] != '=') return -1;
|
||||||
|
|
||||||
|
*str = &((*str)[i+1]);
|
||||||
|
*len = *len - i - 2;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/** typecast_array_scan - scan a string looking for array items **/
|
/** typecast_array_scan - scan a string looking for array items **/
|
||||||
|
|
||||||
|
@ -198,6 +219,8 @@ typecast_GENERIC_ARRAY_cast(char *str, int len, PyObject *curs)
|
||||||
PyObject *base = ((typecastObject*)((cursorObject*)curs)->caster)->bcast;
|
PyObject *base = ((typecastObject*)((cursorObject*)curs)->caster)->bcast;
|
||||||
|
|
||||||
if (str == NULL) {Py_INCREF(Py_None); return Py_None;}
|
if (str == NULL) {Py_INCREF(Py_None); return Py_None;}
|
||||||
|
if (str[0] == '[')
|
||||||
|
typecast_array_cleanup(&str, &len);
|
||||||
if (str[0] != '{') {
|
if (str[0] != '{') {
|
||||||
PyErr_SetString(Error, "array does not start with '{'");
|
PyErr_SetString(Error, "array does not start with '{'");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user