[Bps-public-commit] dbix-searchbuilder branch, optionally-quote-table-names, created. 1.67-9-g0f58aad
Dianne Skoll
dianne at bestpractical.com
Fri Dec 4 10:20:39 EST 2020
The branch, optionally-quote-table-names has been created
at 0f58aad91ccdcfc530ab637c86565a9df7a32e1c (commit)
- Log -----------------------------------------------------------------
commit 0f58aad91ccdcfc530ab637c86565a9df7a32e1c
Author: Aaron Trevena <aaron at aarontrevena.co.uk>
Date: Tue Aug 25 21:16:11 2020 +0100
Add support for automatic quoting of table names
MySQL 8 adds new reserved and keywords, that will cause queries with tables or
columns of those names to fail with syntax errors.
https://dev.mysql.com/doc/mysqld-version-reference/en/keywords-8-0.html
The new QuoteTableNames option will automatically quote tables in SQL created
by SearchBuilder, and will enabled if MySQL version 8 is detected. New helpers
simplify quoting and de-quoting table or column names.
diff --git a/Changes b/Changes
index bed91f1..35316a7 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,8 @@
Revision history for Perl extension DBIx::SearchBuilder.
+ - New option to quote tablenames in queries, enabled automatically for MySQL 8
+ - Updated tests for new MySQL 8 reserved words and tablename quoting
+
1.68 2020-07-06
- Avoid segmentation faults on disconnect on MariaDB 10.2+
diff --git a/lib/DBIx/SearchBuilder.pm b/lib/DBIx/SearchBuilder.pm
index 195669e..fa271b0 100755
--- a/lib/DBIx/SearchBuilder.pm
+++ b/lib/DBIx/SearchBuilder.pm
@@ -1251,6 +1251,7 @@ sub NewAlias {
my $alias = $self->_GetAlias($table);
+ $table = $self->_Handle->QuoteName($table) if ($self->_Handle->QuoteTableNames);
unless ( $type ) {
push @{ $self->{'aliases'} }, "$table $alias";
} elsif ( lc $type eq 'left' ) {
diff --git a/lib/DBIx/SearchBuilder/Handle.pm b/lib/DBIx/SearchBuilder/Handle.pm
index d0f67fc..98e5026 100755
--- a/lib/DBIx/SearchBuilder/Handle.pm
+++ b/lib/DBIx/SearchBuilder/Handle.pm
@@ -27,7 +27,8 @@ DBIx::SearchBuilder::Handle - Perl extension which is a generic DBI handle
Database => 'dbname',
Host => 'hostname',
User => 'dbuser',
- Password => 'dbpassword');
+ Password => 'dbpassword' );
+
# now $handle isa DBIx::SearchBuilder::Handle::mysql
=head1 DESCRIPTION
@@ -50,13 +51,17 @@ sub new {
my $self = {};
bless ($self, $class);
+ # Enable quotes table names
+ my %args = ( QuoteTableNames => 0, @_ );
+ $self->{'QuoteTableNames'} = $args{QuoteTableNames};
+
@{$self->{'StatementLog'}} = ();
return $self;
}
-=head2 Connect PARAMHASH: Driver, Database, Host, User, Password
+=head2 Connect PARAMHASH: Driver, Database, Host, User, Password, QuoteTableNames
Takes a paramhash and connects to your DBI datasource.
@@ -71,6 +76,9 @@ If you created the handle with
and there is a DBIx::SearchBuilder::Handle::(Driver) subclass for the driver you have chosen,
the handle will be automatically "upgraded" into that subclass.
+QuoteTableNames option will force all table names to be quoted if the driver subclass has a method
+for quoting implemented. The mysql subclass will detect mysql version 8 and set the flag.
+
=cut
sub Connect {
@@ -85,6 +93,7 @@ sub Connect {
Password => undef,
RequireSSL => undef,
DisconnectHandleOnDestroy => undef,
+ QuoteTableNames => undef,
@_
);
@@ -96,6 +105,9 @@ sub Connect {
# So we need to explicitly call it
$self->{'DisconnectHandleOnDestroy'} = $args{'DisconnectHandleOnDestroy'};
+ # Enable optional quoted table names
+ $self->{'QuoteTableNames'} = delete $args{QuoteTableNames} if (defined $args{QuoteTableNames});
+
my $old_dsn = $self->DSN || '';
my $new_dsn = $self->BuildDSN( %args );
@@ -116,6 +128,9 @@ sub Connect {
# Cache version info
$self->DatabaseVersion;
+ # force quoted tables for mysql 8
+ $self->{'QuoteTableNames'} = 1 if ($self->_RequireQuotedTables);
+
return 1;
}
@@ -390,6 +405,7 @@ sub InsertQueryString {
push @bind, shift @pairs;
}
+ $table = $self->QuoteName($table) if ($self->QuoteTableNames);
my $QueryString = "INSERT INTO $table";
$QueryString .= " (". join(", ", @cols) .")";
$QueryString .= " VALUES (". join(", ", @vals). ")";
@@ -415,6 +431,7 @@ sub InsertFromSelect {
$columns = join ', ', @$columns
if $columns;
+ $table = $self->QuoteName($table) if ($self->{'QuoteTableNames'});
my $full_query = "INSERT INTO $table";
$full_query .= " ($columns)" if $columns;
$full_query .= ' '. $query;
@@ -446,6 +463,7 @@ sub UpdateRecordValue {
@_ );
my @bind = ();
+ $args{Table} = $self->QuoteName($args{Table}) if ($self->{'QuoteTableNames'});
my $query = 'UPDATE ' . $args{'Table'} . ' ';
$query .= 'SET ' . $args{'Column'} . '=';
@@ -518,6 +536,7 @@ sub SimpleUpdateFromSelect {
push @binds, $values->{$k};
}
+ $table = $self->QuoteName($table) if ($self->{'QuoteTableNames'});
my $full_query = "UPDATE $table SET ";
$full_query .= join ', ', map "$_ = ?", @columns;
$full_query .= ' WHERE id IN ('. $query .')';
@@ -541,6 +560,7 @@ select query, eg:
sub DeleteFromSelect {
my ($self, $table, $query, @binds) = @_;
+ $table = $self->QuoteName($table) if ($self->{'QuoteTableNames'});
my $sth = $self->SimpleQuery(
"DELETE FROM $table WHERE id IN ($query)",
@binds
@@ -753,6 +773,16 @@ sub CaseSensitive {
return(1);
}
+=head2 QuoteTableNames
+
+Returns 1 if table names will be quoted in queries, otherwise 0
+
+=cut
+
+sub QuoteTableNames {
+ return shift->{'QuoteTableNames'}
+}
+
@@ -1016,6 +1046,7 @@ sub Join {
if ( $old_alias =~ /^(.*?) (\Q$args{'ALIAS2'}\E)$/ ) {
$args{'TABLE2'} = $1;
$alias = $2;
+ $args{'TABLE2'} = $self->DequoteName($args{'TABLE2'}) if ($self->QuoteTableNames);
}
else {
push @new_aliases, $old_alias;
@@ -1039,7 +1070,7 @@ sub Join {
if ( $old_alias =~ /^(.*?) ($args{'ALIAS2'})$/ ) {
$args{'TABLE2'} = $1;
$alias = $2;
-
+ $args{'TABLE2'} = $self->DequoteName($args{'TABLE2'}) if ($self->QuoteTableNames);
}
else {
push @new_aliases, $old_alias;
@@ -1055,6 +1086,7 @@ sub Join {
# XXX: this situation is really bug in the caller!!!
return ( $self->_NormalJoin(%args) );
}
+ $args{TABLE2} = $self->QuoteName($args{TABLE2}) if ($self->QuoteTableNames);
$args{'SearchBuilder'}->{'aliases'} = \@new_aliases;
} elsif ( $args{'COLLECTION2'} ) {
# We're joining to a pre-limited collection. We need to take
@@ -1062,7 +1094,9 @@ sub Join {
# alias, apply them locally, then proceed as usual.
my $collection = delete $args{'COLLECTION2'};
$alias = $args{ALIAS2} = $args{'SearchBuilder'}->_GetAlias( $collection->Table );
- $args{TABLE2} = $collection->Table;
+ my $table2 = $collection->Table;
+ $table2 = $self->QuoteName($table2) if ($self->QuoteTableNames);
+ $args{TABLE2} = $table2;
eval {$collection->_ProcessRestrictions}; # RT hate
@@ -1087,6 +1121,7 @@ sub Join {
$args{SearchBuilder}{restrictions}{$_} = $restrictions->{$_} for keys %{$restrictions};
} else {
$alias = $args{'SearchBuilder'}->_GetAlias( $args{'TABLE2'} );
+ $args{TABLE2} = $self->QuoteName($args{TABLE2}) if ($self->QuoteTableNames);
}
my $meta = $args{'SearchBuilder'}->{'left_joins'}{"$alias"} ||= {};
@@ -1161,6 +1196,7 @@ sub _NormalJoin {
if ( $args{'TYPE'} =~ /LEFT/i ) {
my $alias = $sb->_GetAlias( $args{'TABLE2'} );
my $meta = $sb->{'left_joins'}{"$alias"} ||= {};
+ $args{TABLE2} = $self->QuoteName($args{TABLE2}) if ($self->QuoteTableNames);
$meta->{'alias_string'} = " LEFT JOIN $args{'TABLE2'} $alias ";
$meta->{'depends_on'} = $args{'ALIAS1'};
$meta->{'type'} = 'LEFT';
@@ -1192,8 +1228,9 @@ sub _BuildJoins {
my $sb = shift;
$self->OptimizeJoins( SearchBuilder => $sb );
+ my $table = ($self->{'QuoteTableNames'}) ? $self->QuoteName($sb->Table) : $sb->Table;
- my $join_clause = join " CROSS JOIN ", ($sb->Table ." main"), @{ $sb->{'aliases'} };
+ my $join_clause = join " CROSS JOIN ", ("$table main"), @{ $sb->{'aliases'} };
my %processed = map { /^\S+\s+(\S+)$/; $1 => 1 } @{ $sb->{'aliases'} };
$processed{'main'} = 1;
@@ -1453,8 +1490,11 @@ sub Fields {
unless ( $FIELDS_IN_TABLE{$table} ) {
$FIELDS_IN_TABLE{ $table } = [];
- my $sth = $self->dbh->column_info( undef, '', $table, '%' )
- or return ();
+ my $sth = $self->dbh->column_info( undef, '', $table, '%' );
+ unless ($sth) {
+ warn "couldn't get column info for $table " . $sth->errstr;
+ return ();
+ }
my $info = $sth->fetchall_arrayref({});
foreach my $e ( @$info ) {
push @{ $FIELDS_IN_TABLE{ $table } }, $e->{'COLUMN_NAME'};
@@ -1738,6 +1778,50 @@ sub HasSupportForNullsOrder {
}
+=head2 QuoteName
+
+Quote table or column name to avoid reserved word errors.
+
+Returns same value passed unless over-ridden in database-specific subclass.
+
+=cut
+
+# over-ride in subclass
+sub QuoteName {
+ my ($self, $name) = @_;
+ # use dbi built in quoting if we have a connection,
+ if ($self->dbh) {
+ return $self->dbh->quote_identifier($name);
+ }
+ warn "QuoteName called without a db handle";
+ return $name;
+}
+
+=head2 DequoteName
+
+Undo the effects of QuoteName by removing quoting.
+
+=cut
+
+sub DequoteName {
+ my ($self, $name) = @_;
+ if ($self->dbh) {
+ # 29 = SQL_IDENTIFIER_QUOTE_CHAR; see "perldoc DBI"
+ my $quote_char = $self->{dbh}->get_info( 29 );
+
+ if ($quote_char) {
+ if ($name =~ /^$quote_char(.*)$quote_char$/) {
+ return $1;
+ }
+ }
+ return $name;
+ }
+ warn "DequoteName called without a db handle";
+ return $name;
+}
+
+sub _RequireQuotedTables { return 0 };
+
=head2 DESTROY
When we get rid of the Searchbuilder::Handle, we need to disconnect from the database
diff --git a/lib/DBIx/SearchBuilder/Handle/mysql.pm b/lib/DBIx/SearchBuilder/Handle/mysql.pm
index a0302aa..37bed86 100755
--- a/lib/DBIx/SearchBuilder/Handle/mysql.pm
+++ b/lib/DBIx/SearchBuilder/Handle/mysql.pm
@@ -74,6 +74,7 @@ sub SimpleUpdateFromSelect {
push @binds, $values->{$k};
}
+ $table = $self->QuoteName($table) if ($self->{'QuoteTableNames'});
my $update_query = "UPDATE $table SET "
. join( ', ', map "$_ = ?", @columns )
.' WHERE ID IN ';
@@ -92,6 +93,7 @@ sub DeleteFromSelect {
$table, $query, @query_binds
) unless $query =~ /\b\Q$table\E\b/i;
+ $table = $self->QuoteName($table) if ($self->{'QuoteTableNames'});
return $self->SimpleMassChangeFromSelect(
"DELETE FROM $table WHERE id IN ", [],
$query, @query_binds
@@ -289,6 +291,64 @@ sub _DateTimeIntervalFunction {
return "TIMESTAMPDIFF(SECOND, $args{'From'}, $args{'To'})";
}
+
+=head2 QuoteName
+
+Quote table or column name to avoid reserved word errors.
+
+=cut
+
+# over-rides inherited method
+sub QuoteName {
+ my ($self, $name) = @_;
+ # use dbi built in quoting if we have a connection,
+ if ($self->dbh) {
+ return $self->dbh->quote_identifier($name);
+ }
+
+ return sprintf('`%s`', $name);
+}
+
+sub DequoteName {
+ my ($self, $name) = @_;
+
+ # If we have a handle, the base class can do it for us
+ if ($self->dbh) {
+ return $self->SUPER::DequoteName($name);
+ }
+
+ if ($name =~ /^`(.*)`$/) {
+ return $1;
+ }
+ return $name;
+}
+
+sub _IsMariaDB {
+ my $self = shift;
+
+ # We override DatabaseVersion to chop off "-MariaDB-whatever", so
+ # call super here to get the original version
+ my $v = $self->SUPER::DatabaseVersion();
+
+ return ($v =~ /mariadb/i);
+}
+
+sub _RequireQuotedTables {
+ my $self = shift;
+
+ # MariaDB version does not match mysql, and hasn't added new reserved words
+ return 0 if $self->_IsMariaDB;
+
+ my $version = $self->DatabaseVersion;
+
+ # Get major version number by chopping off everything after the first "."
+ $version =~ s/\..*//;
+ if ( $version >= 8 ) {
+ return 1;
+ }
+ return 0;
+}
+
1;
__END__
diff --git a/lib/DBIx/SearchBuilder/Record.pm b/lib/DBIx/SearchBuilder/Record.pm
index c1428d0..5de18d0 100755
--- a/lib/DBIx/SearchBuilder/Record.pm
+++ b/lib/DBIx/SearchBuilder/Record.pm
@@ -709,7 +709,7 @@ sub __Value {
my %pk = $self->PrimaryKeys;
return undef if grep !defined, values %pk;
- my $query = "SELECT $field FROM ". $self->Table
+ my $query = "SELECT $field FROM ". $self->QuotedTableName
." WHERE ". join " AND ", map "$_ = ?", sort keys %pk;
my $sth = $self->_Handle->SimpleQuery( $query, sorted_values(%pk) ) or return undef;
return $self->{'values'}{$field} = ($sth->fetchrow_array)[0];
@@ -1147,8 +1147,8 @@ sub LoadByCols {
}
}
-
- my $QueryString = "SELECT * FROM ".$self->Table." WHERE ".
+
+ my $QueryString = "SELECT * FROM ".$self->QuotedTableName." WHERE ".
join(' AND ', @phrases) ;
return ($self->_LoadFromSQL($QueryString, @bind));
}
@@ -1349,7 +1349,7 @@ sub __Delete {
}
$where =~ s/AND\s$//;
- my $QueryString = "DELETE FROM ". $self->Table . ' ' . $where;
+ my $QueryString = "DELETE FROM ". $self->QuotedTableName . ' ' . $where;
my $return = $self->_Handle->SimpleQuery($QueryString, @bind);
if (UNIVERSAL::isa($return, 'Class::ReturnValue')) {
@@ -1369,8 +1369,6 @@ Returns or sets the name of the current Table
=cut
-
-
sub Table {
my $self = shift;
if (@_) {
@@ -1379,7 +1377,23 @@ sub Table {
return ($self->{'table'});
}
+=head2 QuotedTableName
+
+Returns the name of current Table, or the table provided as an argument, including any quoting
+ based on yje Handle's QuoteTableNames flag and driver method.
+=cut
+
+sub QuotedTableName {
+ my ($self, $name) = @_;
+ unless ($name) {
+ return $self->{'_quoted_table'} if (defined $self->{'_quoted_table'});
+ $self->{'_quoted_table'} = ( $self->_Handle->QuoteTableNames ) ?
+ $self->_Handle->QuoteName($self->Table) : $self->Table ;
+ return $self->{'_quoted_table'}
+ }
+ return ( $self->_Handle->QuoteTableNames ) ? $self->_Handle->QuoteName($name) : $name ;
+}
=head2 _Handle
diff --git a/t/01records.t b/t/01records.t
index a1f1366..ffbffd9 100644
--- a/t/01records.t
+++ b/t/01records.t
@@ -21,6 +21,7 @@ SKIP: {
skip "ENV is not defined for driver '$d'", TESTS_PER_DRIVER;
}
+ note("testing $d");
my $handle = get_handle( $d );
connect_handle( $handle );
isa_ok($handle->dbh, 'DBI::db');
diff --git a/t/02searches_function.t b/t/02searches_function.t
index 2fd6e7e..51069ed 100644
--- a/t/02searches_function.t
+++ b/t/02searches_function.t
@@ -168,7 +168,7 @@ CREATE TEMPORARY TABLE UsersToGroups (
GroupId integer
) },
q{
-CREATE TEMPORARY TABLE Groups (
+CREATE TEMPORARY TABLE `Groups` (
id integer primary key AUTO_INCREMENT,
Name varchar(36)
) },
diff --git a/t/02searches_joins.t b/t/02searches_joins.t
index 1661f2b..1743ba8 100644
--- a/t/02searches_joins.t
+++ b/t/02searches_joins.t
@@ -19,7 +19,6 @@ SKIP: {
unless( should_test( $d ) ) {
skip "ENV is not defined for driver '$d'", TESTS_PER_DRIVER;
}
-
my $handle = get_handle( $d );
connect_handle( $handle );
isa_ok($handle->dbh, 'DBI::db');
@@ -296,7 +295,6 @@ diag "mixing DISTINCT" if $ENV{'TEST_VERBOSE'};
cleanup_schema( 'TestApp', $handle );
}} # SKIP, foreach blocks
-
1;
@@ -336,7 +334,7 @@ CREATE TEMPORARY TABLE UsersToGroups (
GroupId integer
) },
q{
-CREATE TEMPORARY TABLE Groups (
+CREATE TEMPORARY TABLE `Groups` (
id integer primary key AUTO_INCREMENT,
Name varchar(36)
) },
diff --git a/t/03cud_from_select.t b/t/03cud_from_select.t
index 7f5d21b..7c7974a 100644
--- a/t/03cud_from_select.t
+++ b/t/03cud_from_select.t
@@ -20,6 +20,7 @@ SKIP: {
skip "ENV is not defined for driver '$d'", TESTS_PER_DRIVER;
}
+ my $groups_table = ($d eq 'mysql') ? '`Groups`' : 'Groups';
my $handle = get_handle( $d );
connect_handle( $handle );
isa_ok($handle->dbh, 'DBI::db');
@@ -50,7 +51,7 @@ diag "insert into table from two tables" if $ENV{'TEST_VERBOSE'};
{
my $res = $handle->InsertFromSelect(
'UsersToGroups' => ['UserId', 'GroupId'],
- 'SELECT u.id as col1, g.id as col2 FROM Users u, Groups g WHERE u.Login LIKE ? AND g.Name = ?',
+ "SELECT u.id as col1, g.id as col2 FROM Users u, $groups_table g WHERE u.Login LIKE ? AND g.Name = ?",
'%a%', 'Support'
);
is( $res, 2 );
@@ -113,7 +114,7 @@ diag "insert into table from two tables" if $ENV{'TEST_VERBOSE'};
local $SIG{__WARN__} = sub {};
$handle->InsertFromSelect(
'UsersToGroups' => ['UserId', 'GroupId'],
- 'SELECT u.id, g.id FROM Users u, Groups g WHERE u.Login LIKE ? AND g.Name = ?',
+ "SELECT u.id, g.id FROM Users u, $groups_table g WHERE u.Login LIKE ? AND g.Name = ?",
'%a%', 'Support'
);
};
@@ -172,7 +173,7 @@ CREATE TABLE UsersToGroups (
GroupId integer
) },
q{
-CREATE TEMPORARY TABLE Groups (
+CREATE TEMPORARY TABLE `Groups` (
id integer primary key AUTO_INCREMENT,
Name varchar(36)
) },
diff --git a/t/04mysql_identifier_quoting.t b/t/04mysql_identifier_quoting.t
new file mode 100644
index 0000000..7c68407
--- /dev/null
+++ b/t/04mysql_identifier_quoting.t
@@ -0,0 +1,18 @@
+#!/usr/bin/perl -w
+
+
+use strict;
+use warnings;
+use Test::More tests => 8;
+
+BEGIN { use_ok("DBIx::SearchBuilder::Handle"); }
+BEGIN { use_ok("DBIx::SearchBuilder::Handle::mysql"); }
+BEGIN { use_ok("DBIx::SearchBuilder::Handle::Pg"); }
+
+my $h = DBIx::SearchBuilder::Handle::mysql->new();
+
+is ($h->QuoteName('foo'), '`foo`', 'QuoteName works as expected');
+is ($h->DequoteName('`foo`'), 'foo', 'DequoteName works as expected');
+is ($h->DequoteName('`foo'), '`foo', 'DequoteName works as expected');
+is ($h->DequoteName('foo`'), 'foo`', 'DequoteName works as expected');
+is ($h->DequoteName('"foo"'), '"foo"', 'DequoteName works as expected');
diff --git a/t/11schema_records.t b/t/11schema_records.t
index 4fc4dc4..06e650a 100644
--- a/t/11schema_records.t
+++ b/t/11schema_records.t
@@ -8,7 +8,7 @@ use Test::More;
BEGIN { require "t/utils.pl" }
our (@AvailableDrivers);
-use constant TESTS_PER_DRIVER => 63;
+use constant TESTS_PER_DRIVER => 66;
my $total = scalar(@AvailableDrivers) * TESTS_PER_DRIVER;
plan tests => $total;
@@ -180,7 +180,13 @@ SKIP: {
is($phone_collection->Next, undef);
}
-
+ ok($phone3->Delete, "Deleted phone $p3_id");
+
+ my $group = TestApp::Group->new($handle);
+ my $g_id = $group->Create( Name => 'Employees' );
+ ok($g_id, "Got an id for the new group: $g_id");
+ $group->Load($g_id);
+ is($group->id, $g_id, "loaded group ok");
cleanup_schema( 'TestApp', $handle );
}} # SKIP, foreach blocks
@@ -201,6 +207,10 @@ CREATE TABLE Phones (
id integer primary key,
Employee integer NOT NULL,
Phone varchar(18)
+) },
+q{CREATE TABLE Groups (
+ id integer primary key,
+ Name varchar(36)
) }
]
}
@@ -217,7 +227,12 @@ CREATE TEMPORARY TABLE Phones (
Employee integer NOT NULL,
Phone varchar(18)
)
-} ]
+},
+q{CREATE TEMPORARY TABLE `Groups` (
+ id integer AUTO_INCREMENT primary key,
+ Name varchar(36)
+) }
+]
}
sub schema_pg {
@@ -232,7 +247,12 @@ CREATE TEMPORARY TABLE Phones (
Employee integer references Employees(id),
Phone varchar
)
-} ]
+},
+q{CREATE TEMPORARY TABLE Groups (
+ id serial primary key,
+ Name varchar
+) }
+]
}
package TestApp::Employee;
@@ -292,4 +312,35 @@ sub NewItem {
}
+package TestApp::Group;
+
+use base $ENV{SB_TEST_CACHABLE}?
+ qw/DBIx::SearchBuilder::Record::Cachable/:
+ qw/DBIx::SearchBuilder::Record/;
+
+sub Table { 'Groups' }
+
+sub Schema {
+ return {
+ Name => { TYPE => 'varchar' },
+ }
+}
+
+package TestApp::GroupCollection;
+
+use base qw/DBIx::SearchBuilder/;
+
+sub Table {
+ my $self = shift;
+ my $tab = $self->NewItem->Table();
+ return $tab;
+}
+
+sub NewItem {
+ my $self = shift;
+ my $class = 'TestApp::Group';
+ return $class->new( $self->_Handle );
+
+}
+
1;
diff --git a/t/utils.pl b/t/utils.pl
index b662034..57bbb5a 100644
--- a/t/utils.pl
+++ b/t/utils.pl
@@ -110,6 +110,8 @@ sub connect_mysql
return $handle->Connect(
Driver => 'mysql',
Database => $ENV{'SB_TEST_MYSQL'},
+ Host => $ENV{'SB_TEST_MYSQL_HOST'},
+ Port => $ENV{'SB_TEST_MYSQL_PORT'},
User => $ENV{'SB_TEST_MYSQL_USER'} || 'root',
Password => $ENV{'SB_TEST_MYSQL_PASS'} || '',
);
@@ -122,6 +124,8 @@ sub connect_pg
Driver => 'Pg',
Database => $ENV{'SB_TEST_PG'},
User => $ENV{'SB_TEST_PG_USER'} || 'postgres',
+ Host => $ENV{'SB_TEST_PG_HOST'},
+ Port => $ENV{'SB_TEST_PG_PORT'},
Password => $ENV{'SB_TEST_PG_PASS'} || '',
);
}
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list