use DBIx::Class::Schema::Loader::Optional::Dependencies ();
use Try::Tiny;
use DBIx::Class ();
+use Encode qw/decode encode/;
use namespace::clean;
our $VERSION = '0.07010';
warn qq/# Loaded external class definition for '$class'\n/
if $self->debug;
- my $code = $self->_rewrite_old_classnames(scalar slurp $real_inc_path);
+ my $code = $self->_rewrite_old_classnames(decode 'UTF-8', scalar slurp $real_inc_path);
if ($self->dynamic) { # load the class too
eval_package_without_redefine_warnings($class, $code);
}
if ($old_real_inc_path) {
- my $code = slurp $old_real_inc_path;
+ my $code = decode 'UTF-8', scalar slurp $old_real_inc_path;
$self->_ext_stmt($class, <<"EOF");
eval_package_without_redefine_warnings ($class, "require $class");
}
catch {
- my $source = slurp $self->_get_dump_filename($class);
+ my $source = decode 'UTF-8', scalar slurp $self->_get_dump_filename($class);
die "Failed to reload class $class: $_.\n\nCLASS SOURCE:\n\n$source";
};
}
my $compare_to;
if ($old_md5) {
$compare_to = $text . $self->_sig_comment($old_ver, $old_ts);
- if (Digest::MD5::md5_base64($compare_to) eq $old_md5) {
+ if (Digest::MD5::md5_base64(encode 'UTF-8', $compare_to) eq $old_md5) {
return unless $self->_upgrading_from && $is_schema;
}
}
POSIX::strftime('%Y-%m-%d %H:%M:%S', localtime)
);
- open(my $fh, '>', $filename)
+ open(my $fh, '>:encoding(UTF-8)', $filename)
or croak "Cannot open '$filename' for writing: $!";
# Write the top half and its MD5 sum
- print $fh $text . Digest::MD5::md5_base64($text) . "\n";
+ print $fh $text . Digest::MD5::md5_base64(encode 'UTF-8', $text) . "\n";
# Write out anything loaded via external partial class file in @INC
print $fh qq|$_\n|
return unless -f $fn;
- open(my $fh, '<', $fn)
+ open(my $fh, '<:encoding(UTF-8)', $fn)
or croak "Cannot open '$fn' for reading: $!";
my $mark_re =
$gen .= $pre_md5;
croak "Checksum mismatch in '$fn', the auto-generated part of the file has been modified outside of this loader. Aborting.\nIf you want to overwrite these modifications, set the 'overwrite_modifications' loader option.\n"
- if !$self->overwrite_modifications && Digest::MD5::md5_base64($gen) ne $md5;
+ if !$self->overwrite_modifications && Digest::MD5::md5_base64(encode 'UTF-8', $gen) ne $md5;
last;
}
use dbixcsl_common_tests;
use Test::More;
use File::Slurp 'slurp';
+use utf8;
+use Encode 'decode';
my $dsn = $ENV{DBICTEST_PG_DSN} || '';
my $user = $ENV{DBICTEST_PG_USER} || '';
password => $password,
loader_options => { preserve_case => 1 },
connect_info_opts => {
- on_connect_do => [ 'SET client_min_messages=WARNING' ],
+ pg_enable_utf8 => 1,
+ on_connect_do => [ 'SET client_min_messages=WARNING' ],
},
quote_char => '"',
data_types => {
)
},
qq{
- COMMENT ON TABLE pg_loader_test1 IS 'The\15\12Table'
+ COMMENT ON TABLE pg_loader_test1 IS 'The\15\12Table ∑'
},
qq{
COMMENT ON COLUMN pg_loader_test1.value IS 'The\15\12Column'
my $class = $classes->{pg_loader_test1};
my $filename = $schema->_loader->get_dump_filename($class);
- my $code = slurp $filename;
+ my $code = decode('UTF-8', scalar slurp $filename);
- like $code, qr/^=head1 NAME\n\n^$class - The\nTable\n\n^=cut\n/m,
+ like $code, qr/^=head1 NAME\n\n^$class - The\nTable ∑\n\n^=cut\n/m,
'table comment';
like $code, qr/^=head2 value\n\n(.+:.+\n)+\nThe\nColumn\n\n/m,