mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-01-31 09:24:07 +03:00
Added __conform__ to all adapters.
This commit is contained in:
parent
e816aa07b6
commit
515d66cc9f
|
@ -1,7 +1,6 @@
|
|||
2005-03-02 Federico Di Gregorio <fog@debian.org>
|
||||
|
||||
* psycopg/adapter_binary.c (binary_conform): started to add
|
||||
__conform__ to all adapters.
|
||||
* psycopg/adapter_*.c: added __conform__ to all adapters.
|
||||
|
||||
* psycopg/adapter_qstring.c (qstring_quote): we now use
|
||||
PyString_AsStringAndSize() instead of strlen() that would stop at
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include "psycopg/python.h"
|
||||
#include "psycopg/psycopg.h"
|
||||
#include "psycopg/adapter_asis.h"
|
||||
|
||||
#include "psycopg/microprotocols_proto.h"
|
||||
|
||||
/** the AsIs object **/
|
||||
|
||||
|
@ -52,14 +52,19 @@ asis_getquoted(asisObject *self, PyObject *args)
|
|||
}
|
||||
|
||||
PyObject *
|
||||
asis_prepare(asisObject *self, PyObject *args)
|
||||
asis_conform(binaryObject *self, PyObject *args)
|
||||
{
|
||||
PyObject *fake;
|
||||
PyObject *res, *proto;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O", &fake)) return NULL;
|
||||
if (!PyArg_ParseTuple(args, "O", &proto)) return NULL;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
if (proto == (PyObject*)&isqlquoteType)
|
||||
res = (PyObject*)self;
|
||||
else
|
||||
res = Py_None;
|
||||
|
||||
Py_INCREF(res);
|
||||
return res;
|
||||
}
|
||||
|
||||
/** the AsIs object */
|
||||
|
@ -76,8 +81,7 @@ static struct PyMemberDef asisObject_members[] = {
|
|||
static PyMethodDef asisObject_methods[] = {
|
||||
{"getquoted", (PyCFunction)asis_getquoted, METH_VARARGS,
|
||||
"getquoted() -> wrapped object value as SQL-quoted string"},
|
||||
/* {"prepare", (PyCFunction)asis_prepare, METH_VARARGS,
|
||||
"prepare(conn) -> currently does nothing"}, */
|
||||
{"__conform__", (PyCFunction)asis_conform, METH_VARARGS, NULL},
|
||||
{NULL} /* Sentinel */
|
||||
};
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "psycopg/python.h"
|
||||
#include "psycopg/psycopg.h"
|
||||
#include "psycopg/adapter_datetime.h"
|
||||
#include "psycopg/microprotocols_proto.h"
|
||||
|
||||
|
||||
/* the pointer to the datetime module API is initialized by the module init
|
||||
|
@ -83,14 +84,19 @@ pydatetime_getquoted(pydatetimeObject *self, PyObject *args)
|
|||
}
|
||||
|
||||
PyObject *
|
||||
pydatetime_prepare(pydatetimeObject *self, PyObject *args)
|
||||
datetime_conform(binaryObject *self, PyObject *args)
|
||||
{
|
||||
PyObject *fake;
|
||||
PyObject *res, *proto;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O", &fake)) return NULL;
|
||||
if (!PyArg_ParseTuple(args, "O", &proto)) return NULL;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
if (proto == (PyObject*)&isqlquoteType)
|
||||
res = (PyObject*)self;
|
||||
else
|
||||
res = Py_None;
|
||||
|
||||
Py_INCREF(res);
|
||||
return res;
|
||||
}
|
||||
|
||||
/** the DateTime wrapper object **/
|
||||
|
@ -108,8 +114,7 @@ static struct PyMemberDef pydatetimeObject_members[] = {
|
|||
static PyMethodDef pydatetimeObject_methods[] = {
|
||||
{"getquoted", (PyCFunction)pydatetime_getquoted, METH_VARARGS,
|
||||
"getquoted() -> wrapped object value as SQL date/time"},
|
||||
/* {"prepare", (PyCFunction)pydatetime_prepare, METH_VARARGS,
|
||||
"prepare(conn) -> currently does nothing"}, */
|
||||
{"__conform__", (PyCFunction)pydatetime_conform, METH_VARARGS, NULL},
|
||||
{NULL} /* Sentinel */
|
||||
};
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "psycopg/python.h"
|
||||
#include "psycopg/psycopg.h"
|
||||
#include "psycopg/adapter_mxdatetime.h"
|
||||
#include "psycopg/microprotocols_proto.h"
|
||||
|
||||
/* the pointer to the mxDateTime API is initialized by the module init code,
|
||||
we just need to grab it */
|
||||
|
@ -59,14 +60,19 @@ mxdatetime_getquoted(mxdatetimeObject *self, PyObject *args)
|
|||
}
|
||||
|
||||
PyObject *
|
||||
mxdatetime_prepare(mxdatetimeObject *self, PyObject *args)
|
||||
mxdatetime_conform(binaryObject *self, PyObject *args)
|
||||
{
|
||||
PyObject *fake;
|
||||
PyObject *res, *proto;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O", &fake)) return NULL;
|
||||
if (!PyArg_ParseTuple(args, "O", &proto)) return NULL;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
if (proto == (PyObject*)&isqlquoteType)
|
||||
res = (PyObject*)self;
|
||||
else
|
||||
res = Py_None;
|
||||
|
||||
Py_INCREF(res);
|
||||
return res;
|
||||
}
|
||||
|
||||
/** the MxDateTime object **/
|
||||
|
@ -84,8 +90,7 @@ static struct PyMemberDef mxdatetimeObject_members[] = {
|
|||
static PyMethodDef mxdatetimeObject_methods[] = {
|
||||
{"getquoted", (PyCFunction)mxdatetime_getquoted, METH_VARARGS,
|
||||
"getquoted() -> wrapped object value as SQL date/time"},
|
||||
/* {"prepare", (PyCFunction)mxdatetime_prepare, METH_VARARGS,
|
||||
"prepare(conn) -> currently does nothing"}, */
|
||||
{"__conform__", (PyCFunction)mxdatetime_conform, METH_VARARGS, NULL},
|
||||
{NULL} /* Sentinel */
|
||||
};
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "psycopg/python.h"
|
||||
#include "psycopg/psycopg.h"
|
||||
#include "psycopg/adapter_pboolean.h"
|
||||
#include "psycopg/microprotocols_proto.h"
|
||||
|
||||
|
||||
/** the Boolean object **/
|
||||
|
@ -52,14 +53,19 @@ pboolean_getquoted(pbooleanObject *self, PyObject *args)
|
|||
}
|
||||
|
||||
PyObject *
|
||||
pboolean_prepare(pbooleanObject *self, PyObject *args)
|
||||
pboolean_conform(binaryObject *self, PyObject *args)
|
||||
{
|
||||
PyObject *fake;
|
||||
PyObject *res, *proto;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O", &fake)) return NULL;
|
||||
if (!PyArg_ParseTuple(args, "O", &proto)) return NULL;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
if (proto == (PyObject*)&isqlquoteType)
|
||||
res = (PyObject*)self;
|
||||
else
|
||||
res = Py_None;
|
||||
|
||||
Py_INCREF(res);
|
||||
return res;
|
||||
}
|
||||
|
||||
/** the Boolean object */
|
||||
|
@ -76,8 +82,7 @@ static struct PyMemberDef pbooleanObject_members[] = {
|
|||
static PyMethodDef pbooleanObject_methods[] = {
|
||||
{"getquoted", (PyCFunction)pboolean_getquoted, METH_VARARGS,
|
||||
"getquoted() -> wrapped object value as SQL-quoted string"},
|
||||
/* {"prepare", (PyCFunction)pboolean_prepare, METH_VARARGS,
|
||||
"prepare(conn) -> currently does nothing"}, */
|
||||
{"__conform__", (PyCFunction)pboolean_conform, METH_VARARGS, NULL},
|
||||
{NULL} /* Sentinel */
|
||||
};
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "psycopg/psycopg.h"
|
||||
#include "psycopg/connection.h"
|
||||
#include "psycopg/adapter_qstring.h"
|
||||
#include "psycopg/microprotocols_proto.h"
|
||||
|
||||
|
||||
/** the quoting code */
|
||||
|
@ -183,6 +184,21 @@ qstring_prepare(qstringObject *self, PyObject *args)
|
|||
return Py_None;
|
||||
}
|
||||
|
||||
PyObject *
|
||||
qstring_conform(binaryObject *self, PyObject *args)
|
||||
{
|
||||
PyObject *res, *proto;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O", &proto)) return NULL;
|
||||
|
||||
if (proto == (PyObject*)&isqlquoteType)
|
||||
res = (PyObject*)self;
|
||||
else
|
||||
res = Py_None;
|
||||
|
||||
Py_INCREF(res);
|
||||
return res;
|
||||
}
|
||||
|
||||
/** the QuotedString object **/
|
||||
|
||||
|
@ -202,6 +218,7 @@ static PyMethodDef qstringObject_methods[] = {
|
|||
"getquoted() -> wrapped object value as SQL-quoted string"},
|
||||
{"prepare", (PyCFunction)qstring_prepare, METH_VARARGS,
|
||||
"prepare(conn) -> set encoding to conn->encoding"},
|
||||
{"__conform__", (PyCFunction)qstring_conform, METH_VARARGS, NULL},
|
||||
{NULL} /* Sentinel */
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user