| 1 | package Silki::Role::Schema::DebugUTF8; | ||
| 2 | { | ||
| 3 | $Silki::Role::Schema::DebugUTF8::VERSION = '0.29'; | ||
| 4 | } | ||
| 5 | |||
| 6 | use namespace::autoclean; | ||
| 7 | |||
| 8 | use Moose::Role; | ||
| 9 | use Encode (); | ||
| 10 | |||
| 11 | before new => sub { | ||
| 12 | warn "new\n"; | ||
| 13 | shift->_debug_utf8(@_); | ||
| 14 | }; | ||
| 15 | |||
| 16 | sub _get_column_values { | ||
| 17 | my $self = shift; | ||
| 18 | my $select = shift; | ||
| 19 | my $bind = shift; | ||
| 20 | |||
| 21 | my $dbh = $self->_dbh($select); | ||
| 22 | |||
| 23 | my $sth = $dbh->prepare( $select->sql($dbh) ); | ||
| 24 | |||
| 25 | $sth->execute( @{$bind} ); | ||
| 26 | |||
| 27 | my %col_values; | ||
| 28 | $sth->bind_columns( \( @col_values{ @{ $sth->{NAME} } } ) ); | ||
| 29 | |||
| 30 | my $fetched = $sth->fetch(); | ||
| 31 | |||
| 32 | $sth->finish(); | ||
| 33 | |||
| 34 | return unless $fetched; | ||
| 35 | |||
| 36 | warn "_get_column_values\n"; | ||
| 37 | $self->_debug_utf8(%col_values); | ||
| 38 | |||
| 39 | $self->_set_column_values_from_hashref( \%col_values ); | ||
| 40 | |||
| 41 | return \%col_values; | ||
| 42 | } | ||
| 43 | |||
| 44 | sub _debug_utf8 { | ||
| 45 | my $inv = shift; | ||
| 46 | |||
| 47 | my %data = ref $_[0] ? %{ $_[0] } : @_; | ||
| 48 | |||
| 49 | my $class = ref $inv || $inv; | ||
| 50 | warn "$class\n"; | ||
| 51 | |||
| 52 | for my $k ( sort keys %data ) { | ||
| 53 | next if $k eq 'cached_content'; | ||
| 54 | warn " $k => $data{$k} - ", | ||
| 55 | ( Encode::is_utf8( $data{$k} ) || 0 ), "\n"; | ||
| 56 | } | ||
| 57 | warn "\n\n"; | ||
| 58 | } | ||
| 59 | |||
| 60 | 1; |