diff --git a/lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator.pm b/lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator.pm index 71f7cd1..cd431bb 100644 --- a/lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator.pm +++ b/lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator.pm @@ -20,6 +20,7 @@ require DBIx::Class::Storage; # loaded for type constraint use DBIx::Class::DeploymentHandler::Types; use Path::Class qw(file dir); +use utf8; with 'DBIx::Class::DeploymentHandler::HandlesDeploy'; @@ -803,6 +804,7 @@ sub prepare_protoschema { open my $file, q(>), $filename; binmode $file; + utf8::encode($yml); print {$file} $yml; close $file; } diff --git a/t/deploy_methods/sql_translator.t b/t/deploy_methods/sql_translator.t index 3158584..ae4d7ff 100644 --- a/t/deploy_methods/sql_translator.t +++ b/t/deploy_methods/sql_translator.t @@ -200,7 +200,12 @@ VERSION3: { ok( $dm, 'DBIC::DH::SQL::Translator w/3.0 instantiates correctly'); my $version = $s->schema_version(); - $dm->prepare_deploy; + { + my @warns; + local $SIG{__WARN__} = sub { push @warns, shift }; + $dm->prepare_deploy; + ok scalar @warns == 0, "UTF handled correctly. No 'Wide character in print' warning."; + } ok( -f file($sql_dir, qw(SQLite deploy 3.0 001-auto.sql )), '2.0 schema gets generated properly' diff --git a/t/lib/DBICVersion_v3.pm b/t/lib/DBICVersion_v3.pm index e7a94ea..6e58444 100644 --- a/t/lib/DBICVersion_v3.pm +++ b/t/lib/DBICVersion_v3.pm @@ -1,5 +1,6 @@ package DBICVersion::Foo; +use utf8; use base 'DBIx::Class::Core'; use strict; use warnings; @@ -29,6 +30,34 @@ __PACKAGE__->add_columns( __PACKAGE__->set_primary_key('foo'); + +sub sqlt_deploy_hook { + my( $self, $sqlt_table ) = @_; + + $sqlt_table->schema->add_procedure( + name => 'test_utf', + parameters => [ name => '_string', type => 'text' ], + extra => { + returns => { type => 'VOID' }, + definitions => [ + { language => 'sql' }, + { quote => '$$', body => 'SELECT "перевірка ЮТФ/check UTF"' }, + ] + } + ); + + $sqlt_table->schema->add_trigger( + name => 'test_utf', + perform_action_when => 'before', + database_events => 'update', + on_table => $sqlt_table->name, + scope => 'row', + action => q!EXECUTE PROCEDURE test_utf("перевірка ЮТФ/check UTF")! + ); + +} + + package DBICVersion::Schema; use base 'DBIx::Class::Schema'; use strict;