Fix wrong codec with MySQL plugin in newer versions
Since MySQL now properly supports UTF-8 through utf8mb4 option, it caused regression on systems which did not use UTF-8 encoding by default which caused queries to fail as they were converted into system codec. To fix this, simply use UTF-8 encoding for queries when MySQL supports it. Task-number: QTBUG-59176 Change-Id: I21cc9102b15df15a31bc7c74469321c44a257946 Reviewed-by: Andy Shaw <andy.shaw@qt.io>
This commit is contained in:
parent
740b5c1fea
commit
e7f019011a
@ -1421,13 +1421,17 @@ bool QMYSQLDriver::open(const QString& db,
|
||||
if (mysql_get_client_version() >= 50503 && mysql_get_server_version(d->mysql) >= 50503) {
|
||||
// force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters)
|
||||
mysql_set_character_set(d->mysql, "utf8mb4");
|
||||
} else {
|
||||
#ifndef QT_NO_TEXTCODEC
|
||||
d->tc = QTextCodec::codecForName("UTF-8");
|
||||
#endif
|
||||
} else
|
||||
{
|
||||
// force the communication to be utf8
|
||||
mysql_set_character_set(d->mysql, "utf8");
|
||||
}
|
||||
#endif
|
||||
#ifndef QT_NO_TEXTCODEC
|
||||
d->tc = codec(d->mysql);
|
||||
d->tc = codec(d->mysql);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#if MYSQL_VERSION_ID >= 40108
|
||||
|
Loading…
Reference in New Issue
Block a user