ap / DBIx-Connector

Fast, safe DBI connection and transaction management
https://metacpan.org/release/DBIx-Connector
39 stars 15 forks source link

Accept custom connection callback sub(s) #19

Closed rwstauner closed 12 years ago

rwstauner commented 12 years ago

I think it would be really handy if you could specify a coderef to be executed when the database is connected.

I have a few applications where it would be great to use this (in fact I could replace a lot of icky code with this module), but I have custom actions that happen after connecting.

For example:

I took a look at the code and i think it would be fairly simple to add to _connect.

Is this something you'd be interested in having in the main module? I'd be happy to whip up the code and submit a pull req if you think that'd be a good feature.

It looks like I could easily subclass DBIx::Connector or one of the drivers and override _connect which would get me the same thing, but I think it would be a handy feature to have in the main module.

What do you think?

I guess a before-connect sub could be handy, too, so that you could lazily set up (or reinitialize) a proxy connection or something like that.

theory commented 12 years ago

Replicates issue #8.

rwstauner commented 12 years ago

Sorry about that... I glanced at the other issues but I guess I didn't see that. Thanks for the tip, I'll check that out!

rwstauner commented 12 years ago

Oh, It's the Callbacks that I had recently learned of... I've got that as an open tab in my browser somewhere... guess I better check it out. Thanks again!

theory commented 12 years ago

No problem. :-)