... | ... |
@@ -1,4 +1,5 @@ |
1 | 1 |
0.1682 |
2 |
+ - improved debug message |
|
2 | 3 |
- fixed merge_param bug |
3 | 4 |
0.1681 |
4 | 5 |
- added EXPERIMENTAL assign_tag() method |
... | ... |
@@ -17,9 +17,10 @@ use DBIx::Custom::Where; |
17 | 17 |
use DBIx::Custom::Model; |
18 | 18 |
use DBIx::Custom::Tag; |
19 | 19 |
use DBIx::Custom::Util qw/_array_to_hash _subname/; |
20 |
-use Encode qw/encode_utf8 decode_utf8/; |
|
20 |
+use Encode qw/encode encode_utf8 decode_utf8/; |
|
21 | 21 |
|
22 | 22 |
use constant DEBUG => $ENV{DBIX_CUSTOM_DEBUG} || 0; |
23 |
+use constant DEBUG_ENCODING => $ENV{DBIX_CUSTOM_DEBUG_ENCODING} || 'UTF-8'; |
|
23 | 24 |
|
24 | 25 |
our @COMMON_ARGS = qw/table query filter type/; |
25 | 26 |
|
... | ... |
@@ -528,8 +529,19 @@ sub execute { |
528 | 529 |
. qq{$query->{sql}\n} . _subname); |
529 | 530 |
} |
530 | 531 |
|
531 |
- # Output SQL for debug |
|
532 |
- warn $query->sql . "\n" if DEBUG; |
|
532 |
+ # DEBUG message |
|
533 |
+ if (DEBUG) { |
|
534 |
+ print STDERR "SQL:\n" . $query->sql . "\n"; |
|
535 |
+ my @output; |
|
536 |
+ foreach my $b (@$bind) { |
|
537 |
+ my $value = $b->{value}; |
|
538 |
+ $value = 'undef' unless defined $value; |
|
539 |
+ $value = encode(DEBUG_ENCODING(), $value) |
|
540 |
+ if utf8::is_utf8($value); |
|
541 |
+ push @output, $value; |
|
542 |
+ } |
|
543 |
+ print STDERR "Bind values: " . join(', ', @output) . "\n\n"; |
|
544 |
+ } |
|
533 | 545 |
|
534 | 546 |
# Select statement |
535 | 547 |
if ($sth->{NUM_OF_FIELDS}) { |
... | ... |
@@ -2834,7 +2846,11 @@ Updata parameter tag. |
2834 | 2846 |
=head2 C<DBIX_CUSTOM_DEBUG> |
2835 | 2847 |
|
2836 | 2848 |
If environment variable C<DBIX_CUSTOM_DEBUG> is set to true, |
2837 |
-executed SQL is printed to STDERR. |
|
2849 |
+executed SQL and bind values are printed to STDERR. |
|
2850 |
+ |
|
2851 |
+=head2 C<DBIX_CUSTOM_DEBUG_ENCODING> |
|
2852 |
+ |
|
2853 |
+DEBUG output encoding. Default to UTF-8. |
|
2838 | 2854 |
|
2839 | 2855 |
=head1 STABILITY |
2840 | 2856 |
|