go-gitea / gitea

Git with a cup of tea! Painless self-hosted all-in-one software development service, including Git hosting, code review, team collaboration, package registry and CI/CD
https://gitea.com
MIT License
45.08k stars 5.49k forks source link

can't add emoji to issues #5660

Closed helmut72 closed 5 years ago

helmut72 commented 5 years ago

Description

Can't add emoji to issues. I get this error:

[...outers/repo/issue.go:1192 NewComment()] [E] CreateIssueComment: CreateComment: Error 1366: Incorrect string value: '\xF0\x9F\xA5\xB6' for column 'content' at row 1

techknowlogick commented 5 years ago

@helmut72 Is your mysql DB utf8, or utf8mb4?

helmut72 commented 5 years ago

I've created every db with utf8mb4 last year, but I see that most gitea tables was utf8. Now it's utf8mb4. Found this issue: https://github.com/go-gitea/gitea/issues/3513 and converted it to utf8mb4.

But it doesn't help.

helmut72 commented 5 years ago

Can I help with some more log files? I have completely reinstalled Gitea (1.7.2). Even if I create utf8mb4 database in MariaDB, Gitea creates utf8 tables after the first start. Looks like this is the default behavior.

helmut72 commented 5 years ago

Tried another installation and use: CREATE DATABASE IF NOT EXISTS gitea CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

Instead of: CREATE DATABASE IF NOT EXISTS gitea CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;

Found it on this Wiki: https://wiki.archlinux.org/index.php/Gitea#MariaDB/MySQL

But also doesn't work.

What is the supported database in Gitea? Is SQLite enough for 10-20 users?

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.

lunny commented 5 years ago

We recommend you to use Mysql / Postgres when non personal use.

helmut72 commented 5 years ago

Thanks, then I'd like to continue with MySQL. It's not that we use that many Emojis, but a 500 error isn't the best user experience.

zeripath commented 5 years ago

The issue is that we currently use utf8 tables on mysql not utf8mb4. Therefore you can't have emojis on mysql

It's not as simple as just changing the tables yourself - as xorm will just change them back!

If you want emojis use postgres. If you can help make utf8mb4 work that would be excellent.

lunny commented 5 years ago

I have made utf8mb4 work on gitea now. But @zeripath I don't think xorm will change them back. I think we have to change two things:

[mysqld] collation-server = utf8mb4_unicode_ci character-set-server = utf8mb4



- [ ] change the code on models.go:226 to `connStr = fmt.Sprintf("%s:%s@%s(%s)/%s%scharset=utf8mb4&collation=utf8mb4_unicode_ci&parseTime=true&tls=%s", DbCfg.User, DbCfg.Passwd, connType, DbCfg.Host, DbCfg.Name, Param, tls)`

restart gitea.

And xorm should also support customerize charset and collation when create tables. I will send some PRs to xorm and gitea.