| ... | ... |
@@ -1,3 +1,5 @@ |
| 1 |
+0.1737 |
|
| 2 |
+ - fixed DEBUG messsage bug |
|
| 1 | 3 |
0.1736 |
| 2 | 4 |
- micro optimization |
| 3 | 5 |
0.1735 |
| ... | ... |
@@ -1,7 +1,7 @@ |
| 1 | 1 |
package DBIx::Custom; |
| 2 | 2 |
use Object::Simple -base; |
| 3 | 3 |
|
| 4 |
-our $VERSION = '0.1736'; |
|
| 4 |
+our $VERSION = '0.1737'; |
|
| 5 | 5 |
use 5.008001; |
| 6 | 6 |
|
| 7 | 7 |
use Carp 'croak'; |
| ... | ... |
@@ -19,9 +19,6 @@ use DBIx::Custom::NotExists; |
| 19 | 19 |
use Encode qw/encode encode_utf8 decode_utf8/; |
| 20 | 20 |
use Scalar::Util qw/weaken/; |
| 21 | 21 |
|
| 22 |
-use constant DEBUG => $ENV{DBIX_CUSTOM_DEBUG} || 0;
|
|
| 23 |
-use constant DEBUG_ENCODING => $ENV{DBIX_CUSTOM_DEBUG_ENCODING} || 'UTF-8';
|
|
| 24 |
- |
|
| 25 | 22 |
has [qw/connector dsn password quote user exclude_table user_table_info |
| 26 | 23 |
user_column_info/], |
| 27 | 24 |
cache => 0, |
| ... | ... |
@@ -477,17 +474,16 @@ sub execute {
|
| 477 | 474 |
. qq{$query->{sql}\n} . _subname) if $@;
|
| 478 | 475 |
|
| 479 | 476 |
# DEBUG message |
| 480 |
- if (DEBUG) {
|
|
| 481 |
- print STDERR "SQL:\n" . $query->sql . "\n"; |
|
| 477 |
+ if ($ENV{DBIX_CUSTOM_DEBUG}) {
|
|
| 478 |
+ warn "SQL:\n" . $query->sql . "\n"; |
|
| 482 | 479 |
my @output; |
| 483 |
- for my $b (@$bind) {
|
|
| 484 |
- my $value = $b->{value};
|
|
| 480 |
+ for my $value (@$bind) {
|
|
| 485 | 481 |
$value = 'undef' unless defined $value; |
| 486 |
- $value = encode(DEBUG_ENCODING(), $value) |
|
| 482 |
+ $value = encode($ENV{DBIX_CUSTOM_DEBUG_ENCODING} || 'UTF-8', $value)
|
|
| 487 | 483 |
if utf8::is_utf8($value); |
| 488 | 484 |
push @output, $value; |
| 489 | 485 |
} |
| 490 |
- print STDERR "Bind values: " . join(', ', @output) . "\n\n";
|
|
| 486 |
+ warn "Bind values: " . join(', ', @output) . "\n\n";
|
|
| 491 | 487 |
} |
| 492 | 488 |
|
| 493 | 489 |
# Not select statement |
| ... | ... |
@@ -41,6 +41,7 @@ my $binary; |
| 41 | 41 |
# Prepare table |
| 42 | 42 |
$dbi = DBIx::Custom->connect; |
| 43 | 43 |
|
| 44 |
+ |
|
| 44 | 45 |
### SQLite only test |
| 45 | 46 |
test 'dbi_option default'; |
| 46 | 47 |
$dbi = DBIx::Custom->new; |
| ... | ... |
@@ -67,6 +68,18 @@ $result = $dbi->execute('select * from table1;');
|
| 67 | 68 |
$rows = $result->all; |
| 68 | 69 |
is_deeply($rows, [{key1 => 1, key2 => 4}], "basic");
|
| 69 | 70 |
|
| 71 |
+test 'DBIX_CUSTOM_DEBUG ok'; |
|
| 72 |
+{
|
|
| 73 |
+ local $ENV{DBIX_CUSTOM_DEBUG} = 1;
|
|
| 74 |
+ $dbi = DBIx::Custom->connect; |
|
| 75 |
+ eval { $dbi->execute('drop table table1') };
|
|
| 76 |
+ my $error; |
|
| 77 |
+ local $SIG{__WARN__} = sub {
|
|
| 78 |
+ $error = shift; |
|
| 79 |
+ }; |
|
| 80 |
+ $dbi->execute('create table table1 (key1 varchar, key2 varchar, primary key(key1));');
|
|
| 81 |
+ ok($error); |
|
| 82 |
+} |
|
| 70 | 83 |
|
| 71 | 84 |
test 'quote'; |
| 72 | 85 |
$dbi = DBIx::Custom->connect; |