Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoyu-meng-mxy committed Aug 28, 2024
1 parent 8a4a749 commit 48563dc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion mysql_mimic/variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Default: ...
"character_set_database": (str, CharacterSet.utf8mb4.name, True),
"character_set_results": (str, CharacterSet.utf8mb4.name, True),
"character_set_server": (str, CharacterSet.utf8mb4.name, True),
"collation_connection": (str, Collation.utf8mb4_general_ci.name, True),
"collation_connection": (str, Collation.utf8mb4_0900_ai_ci.name, True),
"collation_database": (str, Collation.utf8mb4_general_ci.name, True),
"collation_server": (str, Collation.utf8mb4_general_ci.name, True),
"external_user": (str, "", False),
Expand Down
19 changes: 11 additions & 8 deletions tests/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ async def q3(sql: str) -> Sequence[Dict[str, Any]]:

async def q4(sql: str) -> Sequence[Dict[str, Any]]:
async with sqlalchemy_engine.connect() as conn:
# sqlglot by-default run `SET NAMES 'utf8mb4'` which removes COLLATE settings
# See https://github.com/sqlalchemy/sqlalchemy/discussions/7858
await conn.execute(text("SET NAMES 'utf8mb4' COLLATE 'utf8mb4_0900_ai_ci'"))
cursor = await conn.execute(text(sql))
if cursor.returns_rows:
return cursor.mappings().all() # type: ignore
Expand Down Expand Up @@ -370,12 +373,12 @@ async def test_query_attributes(
),
(
"""
SELECT
/*+ SET_VAR(max_execution_time=2) */
x
SELECT
/*+ SET_VAR(max_execution_time=2) */
x
FROM (
SELECT
/*+ SET_VAR(max_execution_time=1) */
SELECT
/*+ SET_VAR(max_execution_time=1) */
@@max_execution_time AS x
) AS a
""",
Expand Down Expand Up @@ -404,7 +407,7 @@ async def test_query_attributes(
"@@character_set_client": "utf8mb4",
"@@SESSION.character_set_connection": "utf8mb4",
"@@character_set_results": "utf8mb4",
"@@collation_connection": "utf8mb4_general_ci",
"@@collation_connection": "utf8mb4_0900_ai_ci",
}
],
),
Expand Down Expand Up @@ -653,7 +656,7 @@ async def test_query_attributes(
{"Value": "utf8mb4", "Variable_name": "character_set_results"},
{"Value": "utf8mb4", "Variable_name": "character_set_server"},
{
"Value": "utf8mb4_general_ci",
"Value": "utf8mb4_0900_ai_ci",
"Variable_name": "collation_connection",
},
{"Value": "utf8mb4_general_ci", "Variable_name": "collation_database"},
Expand Down Expand Up @@ -751,7 +754,7 @@ async def test_query_attributes(
"character_set_connection": "utf8mb4",
"character_set_results": "utf8mb4",
"character_set_server": "utf8mb4",
"collation_connection": "utf8mb4_general_ci",
"collation_connection": "utf8mb4_0900_ai_ci",
"collation_server": "utf8mb4_general_ci",
"init_connect": "",
"interactive_timeout": 28800,
Expand Down

0 comments on commit 48563dc

Please sign in to comment.