tortoise-orm icon indicating copy to clipboard operation
tortoise-orm copied to clipboard

CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci

Open dyuzhou opened this issue 3 years ago • 4 comments

Describe the bug CHARSET=utf8mb4,COLLATE=utf8mb4_general_ci They are configured in the mysql configuration file and the database used, but after I use tortoise-orm to create the table, they all use CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci

To Reproduce Steps to reproduce the behavior, preferably a small code snippet.

Expected behavior I want the table he created to also use CHARSET=utf8mb4,COLLATE=utf8mb4_general_ci,Is it a problem of aiomysql or tortoise-orm? what should I do

dyuzhou avatar Jul 27 '22 01:07 dyuzhou

How did you create the table?

long2ice avatar Jul 27 '22 01:07 long2ice

你是如何创建表格的?


class Hospital(Model):
    class Meta:
        table = 'hospital'

    id = fields.CharField(max_length=50, pk=True, index=True, description='医院ID')
    name = fields.CharField(max_length=255, default=None, null=True, description='医院名称')
    alias = fields.TextField(default=None, null=True, description='医院-所有名称名称')
    create_time = fields.DatetimeField(null=False, auto_now_add=True, description='创建时间')
    update_time = fields.DatetimeField(null=False, auto_now=True, description='更新时间')
    table_description = '医院表'

async def init():
    await Tortoise.init(
        db_url=settings.db_url,
        modules={'models': ['models.model']}
    )
    await Tortoise.generate_schemas()


async def close_db():
    await Tortoise.close_connections()


if __name__ == '__main__':
    # 创建数据表
    from tortoise import run_async
    run_async(init())

dyuzhou avatar Jul 27 '22 01:07 dyuzhou

Tortoise will not set that, you can check other

long2ice avatar Jul 27 '22 01:07 long2ice

Tortoise can set CHARSET, but not support COLLATE. you can see function "_table_generate_extra " in "site-packages\tortoise\backends\mysql\schema_generator.py"

frank2088 avatar Aug 26 '22 05:08 frank2088

Can this issues be solved?

sharkcheung avatar Aug 08 '23 06:08 sharkcheung