Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Dancer1/Changes
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
Revision history for Dancer-Plugin-Database

2.14 2018-11-20
[ ENHANCEMENTS ]
- added pre database connection hook

2.13 2016-08-13
[ BUG FIXES ]
- Require 0.16 of core library, as 0.15 had a bug in :(
Expand Down
12 changes: 10 additions & 2 deletions Dancer1/lib/Dancer/Plugin/Database.pm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Dancer::Plugin::Database - easy database connections for Dancer applications

=cut

our $VERSION = '2.13';
our $VERSION = '2.14';

my $settings = undef;

Expand All @@ -42,7 +42,9 @@ register database => sub {
register_hook(qw(database_connected
database_connection_lost
database_connection_failed
database_error));
database_error
database_connection_new
));

register_plugin;

Expand Down Expand Up @@ -314,6 +316,12 @@ to connect (as obtained from the config file).
Called when a database error is raised by C<DBI>. Receives two parameters: the
error message being returned by DBI, and the database handle in question.

=item C<database_connection_new>

Called when a new database connection is about to be created. Receives a hashref of
connection settings as a parameter, containing the settings the plugin will be using
to connect (as obtained from the config file).

=back

If you need other hook positions which would be useful to you, please feel free
Expand Down
4 changes: 4 additions & 0 deletions Dancer2/Changes
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
Revision history for Dancer2-Plugin-Database

2.17 2018-11-20
[ ENHANCEMENTS ]
- added pre database connection hook

2.17 2016-08-13

[ BUG FIXES ]
Expand Down
11 changes: 9 additions & 2 deletions Dancer2/lib/Dancer2/Plugin/Database.pm
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ Dancer2::Plugin::Database - easy database connections for Dancer2 applications

=cut

our $VERSION = '2.17';
our $VERSION = '2.18';

register_hook qw(database_connected
database_connection_lost
database_connection_failed
database_error);
database_error
database_connection_new);


my $settings = {};
Expand Down Expand Up @@ -343,6 +344,12 @@ to connect (as obtained from the config file).
Called when a database error is raised by C<DBI>. Receives two parameters: the
error message being returned by DBI, and the database handle in question.

=item C<database_connection_new>

Called when a new database connection is about to be created. Receives a hashref of
connection settings as a parameter, containing the settings the plugin will be using
to connect (as obtained from the config file).

=back

If you need other hook positions which would be useful to you, please feel free
Expand Down
4 changes: 4 additions & 0 deletions Shared/Changes
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
Revision history for Dancer-Plugin-Database-Core

0.21 2018-11-20
[ ENHANCEMENTS ]
- added hook for pre database connection

0.20 2016-09-01
[ ENHANCEMENTS ]
- Support "ILIKE" for Postgres users (Mario Duhanic)
Expand Down
3 changes: 2 additions & 1 deletion Shared/lib/Dancer/Plugin/Database/Core.pm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Dancer::Plugin::Database::Core - Shared core for D1 and D2 Database plugins

=cut

our $VERSION = '0.20';
our $VERSION = '0.21';

my %handles;
# Hashref used as key for default handle, so we don't have a magic value that
Expand Down Expand Up @@ -202,6 +202,7 @@ sub _set_defaults {
sub _get_connection {
my ($settings, $logger, $hook_exec) = @_;

$hook_exec->('database_connection_new', $settings);
if (!$settings->{dsn} && !$settings->{driver}) {
die "Can't get a database connection without settings supplied!\n"
. "Please check you've supplied settings in config as per the "
Expand Down