On Wed, Jan 20, 2010 at 03:24:23PM +0000, Martin Evans wrote:
> > 
> >> but I don't see any call to connect when clone is called.
> > 
> > You don't see a call to DBI->connect, but there is a call to
> > $drh->connect via the closure.
> > 
> >> I presume there is something I need to do - any ideas?
> > 
> > The closure calles the connected() method ad that's a good method to
> > override to (re)setup any private stuff you need.

> Tim,
> 
> Thank you for the pointers.

I'm glad you could interpret it despite the typos :)

> I had all DBIx::Log4perl setup in the
> connect method (strangely I don't recollect reading about the connected
> method) and after moving it all to the connected method and deleting my
> failing attempt at clone override this now seems to work except:
> 
> o when I pass DBIx::Log4perl attributes in the connection e.g.,
>   connect('dbi:Oracle:xxx','user', 'pass', {DBIx_l4p_logmask => 1})
> 
> I get warnings from the connect closure like this:
> 
> Can't set DBIx::Log4perl::db=HASH(0x87116c0)->{DBIx_l4p_logmask}:
> unrecognised attribute name or invalid value
> 
> Previously I didn't get these as I parsed my attributes out in my
> connect method then deleted them before DBI saw them but now I need them
> to get down to the connected method but I don't want those warnings and
> the code checks before calling connected:
> [...]
> and I cannot capture them in connect as this does not work for clone (as
> my connect never gets called if you clone).

It seems that the current clone method doesn't play well with DBI
subclasses.

I've never been very happy with the behaviour of the clone() method
(which is why it has "likely to change" in the docs) but I've not had a
clear idea of what to do with it.

Part of the problem in this case is that you're using uppercase
attribute names. If you used lowercase then things might 'just work'.

Otherwise you probably need to override clone() to remove your
attributes (perhaps stashing them in a 'private_l4p_tmp_attr'
attribute), call the SUPER::clone and then handle your attributes.
Either after SUPER::clone returns or in connected().

> o "Can't locate auto/DBIx/Log4perl/st/DELETE.al"
> 
> I feel this is something I've done wrong but I cannot find it yet. My
> connect method is trying to call $dbh->func('dbms_output_enable') in
> DBD::Oracle (as it always has done) but it is failing in my execute
> attempting to undefine HandleError:

Does DBIx::Log4perl::st subclass DBI::st? It needs to.

Tim.

Reply via email to