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

Problem with utf8mb4_polish_ci #1286

Closed
Damian-tworks opened this issue Nov 23, 2021 · 3 comments
Closed

Problem with utf8mb4_polish_ci #1286

Damian-tworks opened this issue Nov 23, 2021 · 3 comments

Comments

@Damian-tworks
Copy link

Hi. At first - sorry for my english level. I have similar problem to #745 but in my case SELECT @@collation_connection returns proper collation. My tables / columns were corectly created (charset=utf8mb4, collation=utf8mb4_polish_ci).

Anyway, queries like this:
insert, err := db.Exec("INSERT INTO podstawowe_dostawcze (id_podstawowe, rodzaj_ogloszenia) VALUES (NULL, 'sprzedaż')")
gives me sprzeda? instead of sprzedaż.

I don't have this problem within my app (PHP). I choosed Go for small app for integration (my PHP app with external company's app), because there is a lot of data to process, so PHP is not best choice for something like that. But I'm a begginer in Golang world, so maybe that wasn't best choice either. :D

To sum up - I can't see polish characters when I'm inserting data to database through go-sql-driver.

go version go1.17.2 windows/amd64
MySQL 5.7.31
[email protected]
Windows 10

@methane
Copy link
Member

methane commented Nov 23, 2021

Please provide a reproducible example.

@Damian-tworks
Copy link
Author

Damian-tworks commented Nov 24, 2021

db, err = sql.Open("mysql", database.User+":"+database.Pass+"@tcp("+database.Host+")/"+database.Database+"?collation=utf8mb4_polish_ci")

insert, err := db.Exec("INSERT INTO podstawowe_dostawcze (id_podstawowe, rodzaj_ogloszenia) VALUES (NULL, 'sprzedaż')")

Table:
CREATE TABLE IF NOT EXISTS podstawowe_dostawcze ( id_podstawowe int(11) NOT NULL AUTO_INCREMENT, rodzaj_ogloszenia varchar(255) NOT NULL, PRIMARY KEY (id_podstawowe) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_polish_ci;

Result:
image

The same insert to the same database (even the same query) from other app (PHP) is working properly. I'm working on samll, integration app in Go. The first thought was about XML, because my integration app is processing a lot of XML files. But no - I'm also trying just type query like in example in db.Exec() above.

@Damian-tworks
Copy link
Author

SOLVED on Go Programming Language Facebook group. Reason - my new local environment was not set properly and I had to check charset on PHP's MySQL session etc. and I found many differences between server and local env and that was the problem. So - everything was ok with go-sql-driver.

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