From 8b50815336c03e9fe11767d082a9dc0e3dd945c4 Mon Sep 17 00:00:00 2001 From: Wakaba Date: Wed, 24 Jan 2024 17:15:15 +0900 Subject: [PATCH] Workaround for DBI incompatibility --- lib/Dongry/Database.pod | 10 +++++++++- t/database/connect.t | 18 +++++++++++++----- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/lib/Dongry/Database.pod b/lib/Dongry/Database.pod index a3962a29..15a9aabe 100644 --- a/lib/Dongry/Database.pod +++ b/lib/Dongry/Database.pod @@ -247,11 +247,19 @@ for more information. The user name used to connect the database. This is optional if the database or the database driver module does not require user name. +If both of C and C's C are specified, how they +are used is database driver dependent. For the +L mode, C is used if defined. + =item password => string The password used to connect the database. This is optional if the database or the database driver module does not require password. +If both of C and C's C are specified, how +they are used is database driver dependent. For the +L mode, C is used if defined. + =item writable => boolean Whether the database is writable or not. If not writable, the @@ -1704,7 +1712,7 @@ until 7 March, 2022. =head1 LICENSE -Copyright 2011-2022 Wakaba . +Copyright 2011-2024 Wakaba . This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. diff --git a/t/database/connect.t b/t/database/connect.t index fef4cfdb..e5dce14f 100644 --- a/t/database/connect.t +++ b/t/database/connect.t @@ -78,8 +78,10 @@ sub _onerror_new : Test(2) { my $db = Dongry::Database->new (onerror => sub { ($onerror_self, %onerror_args) = @_; }); + my $dsn = $test_dsn_1; + $dsn =~ s/password/X/; $db->source (hoge => { - dsn => $test_dsn_1, + dsn => $dsn, password => 'foo', }); dies_here_ok { $db->connect ('hoge') }; @@ -191,13 +193,17 @@ sub _connect_wrong_username_onerror : Test(5) { undef $onerror_self; } # _connect_wrong_username -sub _connect_wrong_password : Test(1) { +sub _connect_wrong_password : Test(2) { my $db = Dongry::Database->new; + my $dsn = $test_dsn_1; + $dsn =~ s/password/X/; $db->source (hoge => { - dsn => $test_dsn_1, + dsn => $dsn, password => 'hoge', }); - dies_here_ok { $db->connect ('hoge') }; + my $r; + dies_here_ok { $r = $db->connect ('hoge') }; + is $r, undef, $r; } # _connect_wrong_password sub _connect_wrong_password_onerror : Test(5) { @@ -206,8 +212,10 @@ sub _connect_wrong_password_onerror : Test(5) { $db->onerror (sub { ($onerror_self, %onerror_args) = @_; }); + my $dsn = $test_dsn_1; + $dsn =~ s/password/X/; $db->source (hoge => { - dsn => $test_dsn_1, + dsn => $dsn, password => 'hoge', }); dies_here_ok { $db->connect ('hoge') };