Hello Ruby folk,
I'm having a problem making a subclass of PGconn, the Ruby interface
to PostgreSQL defined in the 'postgres' extension.
Consider this example, which should let us open a connection to a
specific database without having to provide authentication info:
require 'postgres'
class MyPGconn < PGconn
def initialize
begin
super(nil, nil, nil, nil, 'dbname', 'user', 'pass')
end
end
end
conn = MyPGconn.new
conn.close
When run, this generates the error:
test.rb:11:in `new': fe_sendauth: no password supplied (PGError)
from test.rb:11
....just as if no arguments had been supplied to PGconn.new. Apparently the
inherited initialize method isn't being overridden properly.
Back in January of this year, someone mentioned the same problem and both
Guy Decoux and Matz explained that the then-current PostgreSQL interface
wasn't calling initialize correctly. My understanding of the internals of
C extensions isn't very good, but I've checked the source of the version
I'm using (0.6.4), and it *seems* to be calling rb_obj_call_init in the right
place... I think? :}
So why doesn't it work? Am I doing something wrong? Also, in case it's
relevant, I'm using ruby version 1.6.4 (2001-06-19).
Thanks very much!
- Hoss