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

How to convert the comment field to Chinese if the comment field is Unicode #16

Closed
qiufeihai opened this issue Nov 12, 2020 · 4 comments

Comments

@qiufeihai
Copy link

How to convert the comment field to Chinese if the comment field is Unicode

comment: "\u521B\u5EFA\u65F6\u95F4"

@spinlud
Copy link
Owner

spinlud commented Dec 9, 2020

Hi! Please can you share dialect (Postgres, MySQL, etc), database version and CREATE TABLE statement for your table?

@jsicu
Copy link

jsicu commented May 14, 2021

Hi! Please can you share dialect (Postgres, MySQL, etc), database version and CREATE TABLE statement for your table?

Local usage example:

npx stg -D mysql -h localhost -p 3306 -d koa2_server -u root -x password --indices --case camel --out-dir ./models --clean

CREATE TABLE statement:

`/*
Navicat Premium Data Transfer

Source Server : localhost
Source Server Type : MySQL
Source Server Version : 80019
Source Host : localhost:3306
Source Schema : koa2_server

Target Server Type : MySQL
Target Server Version : 80019
File Encoding : 65001

Date: 14/05/2021 16:53:14
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;


-- Table structure for log


DROP TABLE IF EXISTS log;
CREATE TABLE log (
id int(0) NOT NULL AUTO_INCREMENT,
type int(0) NOT NULL COMMENT '日志类型',
ip varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '访问地址',
user_id varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '用户id',
method varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '请求方法',
original_url varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '请求接口',
token varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'token',
point varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '坐标',
address varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '所在地',
update_time datetime(6) NOT NULL DEFAULT '0162-09-12 09:32:46.000000' ON UPDATE CURRENT_TIMESTAMP(6) COMMENT '最后更新时间',
delete_time datetime(6) NULL DEFAULT NULL COMMENT '删除时间',
PRIMARY KEY (id) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;


-- Records of log


SET FOREIGN_KEY_CHECKS = 1;
`

model

`
import { Model, Table, Column, DataType, Index, Sequelize, ForeignKey } from 'sequelize-typescript';

interface logAttributes {
id?: number;
type: number;
ip: string;
userId?: string;
method?: string;
originalUrl?: string;
token: string;
point?: string;
address?: string;
updateTime: Date;
deleteTime?: Date;
}

@table({ tableName: 'log', timestamps: false })
export class log extends Model<logAttributes, logAttributes> implements logAttributes {
@column({ primaryKey: true, autoIncrement: true, type: DataType.INTEGER })
@Index({ name: 'PRIMARY', using: 'BTREE', order: 'ASC', unique: true })
id?: number;

@column({ type: DataType.INTEGER, comment: '\u65E5\u5FD7\u7C7B\u578B' })
type!: number;

@column({ type: DataType.STRING(255), comment: '\u8BBF\u95EE\u5730\u5740' })
ip!: string;

@column({ field: 'user_id', allowNull: true, type: DataType.STRING(255), comment: '\u7528\u6237id' })
userId?: string;

@column({ allowNull: true, type: DataType.STRING(10), comment: '\u8BF7\u6C42\u65B9\u6CD5' })
method?: string;

@column({ field: 'original_url', allowNull: true, type: DataType.STRING(255), comment: '\u8BF7\u6C42\u63A5\u53E3' })
originalUrl?: string;

@column({ type: DataType.STRING(500), comment: 'token' })
token!: string;

@column({ allowNull: true, type: DataType.STRING(50), comment: '\u5750\u6807' })
point?: string;

@column({ allowNull: true, type: DataType.STRING(50), comment: '\u6240\u5728\u5730' })
address?: string;

@column({ field: 'update_time', type: DataType.DATE(6), comment: '\u6700\u540E\u66F4\u65B0\u65F6\u95F4' })
updateTime!: Date;

@column({ field: 'delete_time', allowNull: true, type: DataType.DATE(6), comment: '\u5220\u9664\u65F6\u95F4' })
deleteTime?: Date;
}
`

I want to make the comment name in normal character than the Unicode code.

Thank you!

@KingDracula
Copy link

can you fix it now?

@spinlud
Copy link
Owner

spinlud commented Mar 18, 2022

Hi!
Should be fixed in v8.1.1

@spinlud spinlud closed this as completed Mar 18, 2022
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

4 participants