The “postgres” module is old and it’s been a long time since there’s
been a release. The module has the following problems:
uses PQescapeString() and PQescapeBytea(), both of which are long-
since deprecated, and provides no interface to the newer functions
(which have been around for a long time).
uses wrong quoting routine to quote connection string arguments.
release version doesn’t provide any interface to PQexecParams().
snapshot introduces some ruby array to PG array type-awareness, but
I wrote a patch that makes the following changes to the module from the
added instance methods “escape” and “escape_bytea” which use
PQescapeStringConn() and PQescapeByteaConn(). The class methods by the
same names should be deprecated, but I left them in for compatibility.
added the instance method “unescape_bytea”, which is the same as the
class method by the same name. This didn’t strictly need to be done, but
I did this for consistency with “escape_bytea” which is now an instance
added an instance and class method “quote_ident” to quote identifiers.
wrote separate quoting routine (not exported) to properly quote
connection string arguments according to the documented quoting rules
for the connection string arguments. The old code did this by using the
same routine as for quoting values passed to a SQL string, which is
removed code that tried to convert ruby arrays into postgresql arrays.
It was broken (in the quote method, did not actually quote the array),
and the code should be substantially refactored to better enable more
intelligent type awareness from ruby to postgresql. I could reintroduce
this if people care about more type awareness.
I’d like to do some more serious refactoring, but I just wanted to get
some feedback first. Who uses this module, and what do you think about
my changes? How old of a client library do we want to support? The
current module uses ugly #define directives to bolt on support for
ancient versions of libpq, is this necessary?
Should I fork and put a project on RAA, or should I try to take over the
current “postgres” module?