mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-03-03 15:45: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 *
|
||||
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[0] == 't')
|
||||
switch (s[0]) {
|
||||
case 't':
|
||||
case 'T':
|
||||
res = Py_True;
|
||||
else
|
||||
res = Py_False;
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user