...
 
Commits (2)
......@@ -777,7 +777,17 @@ All functionality listed here is highly experimental and should be used with gre
The 'MySQL' in the DSN will be picked up and the MySQL specific attribute aliasing will be used.
Right now only MySQL is supported by this feature, and even that support is very minimal. Currently the MySQL `$dbh` and `$sth` attributes 'mysql\_insertid' are aliased to the `$dbh` attribute 'mock\_last\_insert\_id'. It is possible to add more aliases though, using the `DBD::Mock:_set_mock_attribute_aliases` function (see the source code for details).
Right now there is only minimal support for MySQL and MariaDB:
- MySQL
Currently the 'mysql\_insertid' attribute for `$dbh` and `$sth` are aliased to the `$dbh` attribute 'mock\_last\_insert\_id'.
- MariaDB
Currently the 'mariadb\_insertid' attribute for `$dbh` and `$sth` are aliased to the `$dbh` attribute 'mock\_last\_insert\_id'.
It is possible to add more aliases though, using the `DBD::Mock:_set_mock_attribute_aliases` function (see the source code for details)
- Connection Callbacks
......
......@@ -89,6 +89,16 @@ my %AttributeAliases = (
sub { (shift)->{Database}->{'mock_last_insert_id'} }
}
},
mariadb => {
db => {
mariadb_insertid => 'mock_last_insert_id'
},
st => {
mariadb_insertid =>
sub { (shift)->{Database}->{'mock_last_insert_id'} }
}
}
);
sub _get_mock_attribute_aliases {
......@@ -955,7 +965,21 @@ Once this is turned on, you will need to choose a database specific attribute al
The 'MySQL' in the DSN will be picked up and the MySQL specific attribute aliasing will be used.
Right now only MySQL is supported by this feature, and even that support is very minimal. Currently the MySQL C<$dbh> and C<$sth> attributes 'mysql_insertid' are aliased to the C<$dbh> attribute 'mock_last_insert_id'. It is possible to add more aliases though, using the C<DBD::Mock:_set_mock_attribute_aliases> function (see the source code for details).
Right now there is only minimal support for MySQL and MariaDB:
=over 4
=item MySQL
Currently the 'mysql_insertid' attribute for C<$dbh> and C<$sth> are aliased to the C<$dbh> attribute 'mock_last_insert_id'.
=item MariaDB
Currently the 'mariadb_insertid' attribute for C<$dbh> and C<$sth> are aliased to the C<$dbh> attribute 'mock_last_insert_id'.
=back
It is possible to add more aliases though, using the C<DBD::Mock:_set_mock_attribute_aliases> function (see the source code for details)
=item Connection Callbacks
......
......@@ -90,4 +90,50 @@ like($@, qr/Attribute aliases not available for \'Fail\'/, '... got the error we
}
# test the MariaDB mock db
{
my $dbh;
eval {
$dbh = DBI->connect('dbi:Mock:mariadb', '', '');
};
ok(!$@, '... got our mock DB successfully');
isa_ok($dbh, 'DBI::db');
is($dbh->{mock_database_name}, 'mariadb', '... and its the name we expected');
ok(defined($dbh->{mock_attribute_aliases}), '... got something here');
is(ref($dbh->{mock_attribute_aliases}), 'HASH', '... and its the hash we expected');
my $sth = $dbh->prepare('INSERT INTO Foo (bar) VALUES(NULL)');
isa_ok($sth, 'DBI::st');
$sth->execute();
is($dbh->{mariadb_insertid}, 1, '... our alias works');
}
# and test it with the lowercasing
{
my $dbh;
eval {
$dbh = DBI->connect('dbi:Mock:MariaDB', '', '');
};
ok(!$@, '... got our mock DB successfully');
isa_ok($dbh, 'DBI::db');
is($dbh->{mock_database_name}, 'MariaDB', '... and its the name we expected');
ok(defined($dbh->{mock_attribute_aliases}), '... got something here');
is(ref($dbh->{mock_attribute_aliases}), 'HASH', '... and its the hash we expected');
my $sth = $dbh->prepare('INSERT INTO Foo (bar) VALUES(NULL)');
isa_ok($sth, 'DBI::st');
$sth->execute();
is($dbh->{mariadb_insertid}, 1, '... our alias works');
}
done_testing();