[PATCH] Improve hstore support
[PATCH] Improve hstore support
Hi all, Please find attached a patch to make the hstore extension work reliably with RealDictConnection, and hstore type installed in a custom schema. All the best, -- Jean-Baptiste Quenot
Re: [PATCH] Improve hstore support
От:
Daniele Varrazzo <daniele.varrazzo@gmail.com>
Дата:
2011/2/25 Jean-Baptiste Quenot : > Hi all, > > Please find attached a patch to make the hstore extension work > reliably with RealDictConnection, and hstore type installed in a > custom schema. Thank you JB, yesterday I already pushed a patch to register hstore in whatever schema it is registered, so half of the patch is already in, albeit in a different form. As you have noticed, installation fails if the connection is a RealDictConnection. Do you want to reformulate the patch on the most up-to-date devel? You can clone my git repos at and patch from there. Please, if you provide a patch, also provide a test case for it, e.g. in tests/extras_dictcursor.py. Please note that RealDictCursor is advertised as a "specialized" one (see http://initd.org/psycopg/docs/extras.html#real-dictionary-cursor): it is documented that it doesn't respect the dbapi interface so I expect several higher level areas of the libraries not working correctly with them. You can work around the problem in register_hstore() by manually querying an oid and passing it as register_hstore oid keyword (see http://initd.org/psycopg/docs/extras.html#psycopg2.extras.register_hstore - the feature is new in 2.4). Other cursor types more specialized but still respectful of the dbapi (e.g. NamedTupleConnection) have no problem with register_hstore. So, given the fact that RealDictCursor is not dbapi-compliant and the oid is a workaround for the issue, do we really want to have register_hstore() extended to support it? We would need **tests** and patches in a lot of different areas, pretty much everything into psycopg that creates a cursor. connection.tpc_recover() and extras.register_composite() are the first coming to mind that are likely equally broken. Comments? -- Daniele
Re: [PATCH] Improve hstore support
От:
Jean-Baptiste Quenot <jbq@caraldi.com>
Дата:
2011/2/25 Daniele Varrazzo : > Please note that RealDictCursor is advertised as a "specialized" one > (see http://initd.org/psycopg/docs/extras.html#real-dictionary-cursor): > it is documented that it doesn't respect the dbapi interface so I > expect several higher level areas of the libraries not working > correctly with them. You can work around the problem in > register_hstore() by manually querying an oid and passing it as > register_hstore oid keyword (see > http://initd.org/psycopg/docs/extras.html#psycopg2.extras.register_hstore > - the feature is new in 2.4). OK I integrated the OID query on my side, and pass it to the connection constructor. That's fine that way. Thanks for your dedication, -- Jean-Baptiste Quenot