Accept custom connection callback sub(s) #19

Closed
rwstauner opened this Issue May 14, 2012 · 4 comments

Comments

Projects
None yet
2 participants
Contributor

rwstauner commented May 14, 2012

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:

  • set schema search path
  • connect additional databases (sqlite)
  • set job priority

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.

Owner

theory commented May 16, 2012

Replicates issue #8.

@theory theory closed this May 16, 2012

Contributor

rwstauner commented May 16, 2012

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!

Contributor

rwstauner commented May 16, 2012

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!

Owner

theory commented May 16, 2012

No problem. :-)

rwstauner added a commit to rwstauner/dbix-connector that referenced this issue May 16, 2012

Mention the 'connected' DBI Callback from constructor Pod
to avoid having more issues like gh-8 and gh-19 opened.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment