Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

respect UTF8 #108

Closed
KES777 opened this issue Jul 31, 2018 · 3 comments
Closed

respect UTF8 #108

KES777 opened this issue Jul 31, 2018 · 3 comments

Comments

@KES777
Copy link

KES777 commented Jul 31, 2018

If my Result/Table.pm looks like:

use utf8;
...
sub sqlt_deploy_hook {
        my( $self, $sqlt_table ) =  @_;

        my $sqlt =  $sqlt_table->schema;
        $sqlt->add_procedure(()
                ,name =>  'ch_saldo'
                ....
                ,extra =>  {()
                        ,returns =>  { type => 'VOID' }
                        ,definitions =>  [()
                                ,{ language  =>  'plpgsql'  }
                                ,{ attribute =>  'VOLATILE' }
                                ,{ quote => "\$\$\n",  body => <<'      FUNC' =~ s!^\t\t!  !grm  =~
                /*Только суммарный учёт по счёту*/
                DECLARE _YearFrom  smallint;
                DECLARE _YearTo    smallint;

When I run prepare command I get migration script with broken comments:

CREATE FUNCTION "ch_saldo" (in _DocDate DATE, in _Schet TBuhSchet, in _Suma TMoney)
 RETURNS VOID
 LANGUAGE plpgsql
 VOLATILE
 AS $$
  /*Тол�ко ��мма�н�й ���� по �����*/
  DECLARE _YearFrom  smallint;/**/
  DECLARE _YearTo    smallint;/**/
@KES777
Copy link
Author

KES777 commented Aug 1, 2018

This happen only on project where Result classes use Moose.
On project without Moose this does not happen.

@KES777
Copy link
Author

KES777 commented Sep 7, 2018

A few more information on this.

I set breakpoint at /DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator.pm:500
when downgrade script is generated.

  >>500:   return [SQL::Translator::Diff::schema_diff(
    501:      $source_schema, $db,
    502:      $dest_schema,   $db,
    503:      { producer_args => $sqltargs }
    504:   )];

One interesting fact that same method from same file is different for $source_schema VS $dest_schema.

$dest_schema:

    ch_saldo => SQL::Translator::Schema::Procedure {
      _ERROR => ,
      comments => [
        ,
      ],
      extra => {
        definitions => [
          {
            language => plpgsql,
          },
          {
            attribute => VOLATILE,
          },
          {
            body =>   /*Тол�ко ��мма�н�й ���� по �����*/
  DECLARE _YearFrom  smallint;/**/
  DECLARE _YearTo    smallint;/**/
  DECLARE _MonthFrom smallint;/**/
  DECLARE _MonthTo   smallint;/**/

$source_schema:

    ch_saldo => SQL::Translator::Schema::Procedure {
      _ERROR => ,
      comments => [
        ,
      ],
      extra => {
        definitions => [
          {
            language => plpgsql,
          },
          {
            attribute => VOLATILE,
          },
          {
            body =>   /*Только суммарный учёт по счёту*/
  DECLARE _YearFrom  smallint;/**/
  DECLARE _YearTo    smallint;/**/
  DECLARE _MonthFrom smallint;/**/
  DECLARE _MonthTo   smallint;/**/

As you can see $dest_schema is not UTF8 decoded

It is worth to mention that SQL added by sub sqlt_deploy_hook { called from App::Schema in both cases: for $source and $dest is both decoded correctly.
All files: App::Schema and ::Result package both have use utf8
I use this patch which adds stored procedures: dbsrgits/sql-translator#82

@mohawk2
Copy link
Collaborator

mohawk2 commented Mar 5, 2019

This is a bug (which I agree, an actual bug) in either DBICDH or, more likely, SQLT. It needs reporting there. This module cannot fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants