8000 Change default encoding for utf8mb4 and mysql 8 or allow setting encoding when connecting · Issue #1092 · PyMySQL/PyMySQL · GitHub
[go: up one dir, main page]

Skip to content
Change default encoding for utf8mb4 and mysql 8 or allow setting encoding when connecting #1092
Closed
@jin-harmoney

Description

@jin-harmoney

Describe the bug

We're getting the following error when connecting to our mysql 8 database with the standard collation utf8mb4_0900_ai_ci for utf8mb4:

Illegal mix of collations (utf8mb4_0900_ai_ci,IMPLICIT) and (utf8mb4_general_ci,IMPLICIT) for operation '='

To Reproduce

  • Create a simple table with a varchar column on a standard mysql 8 database
  • Run query:
set @test = 'test';
select * from table where col_name = @test;

This does work, but it shouldn't be necessary to specify the collation:

set @test = 'test' collate 'utf8mb4_0900_ai_ci';
select * from table where col_name = @test;

Execute this query using pymysql. Since the default charset used by pymysql is utf8mb4_general_ci, you'll get the error mentioned above.

Expected behavior

The query should either work because the default collation used by pymysql matches the default collation of mysql, or it should be possible to specify the collation (or encoding) when connecting.

The current behavior in the code is to use the default: https://github.com/PyMySQL/PyMySQL/blob/main/pymysql/connections.py#L307-L310

Environment

  • Server and version: 8.0.27-18.1 - Percona XtraDB Cluster
  • PyMySQL version: 0.7.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0