mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-03-03 23:55:46 +03:00
Allow parsing boolean both upper and lowercase
Reportedly useful on H2 databases. Close #965
This commit is contained in:
parent
5e9572aff8
commit
96156727c0
|
@ -114,16 +114,27 @@ typecast_UNICODE_cast(const char *s, Py_ssize_t len, PyObject *curs)
|
||||||
static PyObject *
|
static PyObject *
|
||||||
typecast_BOOLEAN_cast(const char *s, Py_ssize_t len, PyObject *curs)
|
typecast_BOOLEAN_cast(const char *s, Py_ssize_t len, PyObject *curs)
|
||||||
{
|
{
|
||||||
PyObject *res;
|
PyObject *res = NULL;
|
||||||
|
|
||||||
if (s == NULL) { Py_RETURN_NONE; }
|
if (s == NULL) { Py_RETURN_NONE; }
|
||||||
|
|
||||||
if (s[0] == 't')
|
switch (s[0]) {
|
||||||
res = Py_True;
|
case 't':
|
||||||
else
|
case 'T':
|
||||||
res = Py_False;
|
res = Py_True;
|
||||||
|
break;
|
||||||
|
|
||||||
Py_INCREF(res);
|
case 'f':
|
||||||
|
case 'F':
|
||||||
|
res = Py_False;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
PyErr_Format(InterfaceError, "can't parse boolean: '%s'", s);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
Py_XINCREF(res);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user