Re: Sanitize schema name
От | Daniele Varrazzo |
---|---|
Тема | Re: Sanitize schema name |
Дата | |
Msg-id | CA+mi_8YYNZ_GO4K5axhTvfsfjwtvAX_m68RQwNVsbDyapDVoqQ@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: Sanitize schema name (Elliot S <yields.falsehood@gmail.com>) |
Список | psycopg |
On Wed, May 27, 2015 at 5:32 PM, Elliot S <yields.falsehood@gmail.com> wrote: > I've removed the call out to the psycopg quoting. > %t formatting is also removed. Thank you for these adjustments. > I've added a quote_ident() to the connection object. IMO we should have a function on psycopg2.extensions taking a connection or cursor object and a string, like the various extras.register_*. This method doesn't really belong to the connection (it does require a connection to work, but that's pretty much like everything else in libpq). It doesn't even belong to the cursor: it's just an utility function wrapping some libpq functionality. > I'm still working on my quote_ident branch > https://github.com/psycopg/psycopg2/compare/master...yieldsfalsehood:quote_ident > > Return values are just bytestrings right now. bytestring input isn't > accepted on python3.4 (only py3 I tested); unicode and bytestring inputs > look ok for python2.7. I'm not sure the trivial PyArg_ParseTuple(args, "s", &ident) is right here: in py3 you have an utf8 encoded string: maybe good enough but I'm not so sure. Looking at the libpq implementation it makes use of the connection encoding. I think the right thing to do is, in case of unicode input, encode it in the connection encoding. The full roundtrip, IMO, should be a function that returns a string on string input and a unicode on unicode input (with the respective meaning of these terms in Py2 and Py3), using the connection encoding for encoding/decoding in the latter case. > The other PQescape* functions were mentioned earlier but I haven't touched > them, yet. We can take a look at them and work out which one would be useful later, after we get this right. -- Daniele
В списке psycopg по дате отправления: