sqlparse icon indicating copy to clipboard operation
sqlparse copied to clipboard

SQL statements and comments that contain Chinese writing are garbled

Open cheKnowYoung opened this issue 5 years ago • 2 comments

Snipaste_2020-10-18_14-56-28

Thanks!

cheKnowYoung avatar Oct 18 '20 06:10 cheKnowYoung

Do you have an example to reproduce this issue (preferably text, not as an image). There's at least on test that actually checks that chinese characters are handled properly: https://github.com/andialbrecht/sqlparse/blob/master/tests/test_cli.py#L76

andialbrecht avatar Oct 19 '20 06:10 andialbrecht

here have an example

use `test_sql`;
show databases;

describe `student2`;
-- drop table `student2`;

create table `student2`(
	`student_id` INT ,
    `name` varchar(20) not null,
    `major` varchar(20) unique default '歷史' , -- unique 不重複 , default '歷史' 
    primary key(`student_id`)
);

insert into `student2` values(1, null,'英文'); -- error
insert into `student2` values(1, '小白','英文');
insert into `student2` values(2, '小黑','英文'); -- error
insert into `student2` (`student_id`,`name` ) values(2, '小黑');
select * from `student2`;

after sqlparse

use `test_sql`;
show databases;

describe `student2`;
-- drop table `student2`;

create table `student2`(
	`student_id` INT ,
    `name` varchar(20) not null,
    `major` varchar(20) unique default '���v' , -- unique ������ , default '���v'
    primary key(`student_id`)
);

insert into `student2` values(1, null,'�^��'); -- error
insert into `student2` values(1, '�p��','�^��');
insert into `student2` values(2, '�p��','�^��'); -- error
insert into `student2` (`student_id`,`name` ) values(2, '�p��');
select * from `student2`;

we684123 avatar May 19 '22 16:05 we684123