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

Enums not quoted #7

Open
maratori opened this issue Jun 15, 2023 · 1 comment · May be fixed by #10
Open

Enums not quoted #7

maratori opened this issue Jun 15, 2023 · 1 comment · May be fixed by #10

Comments

@maratori
Copy link

The original pypika has the bug kayak/pypika#560 which was fixed in kayak/pypika#576. pypika-tortoise has the same bug.

import asyncio
from tortoise import fields, Tortoise, Model
from enum import Enum

class MyModel(Model):
    name = fields.TextField()

class MyEnum(str, Enum):
    A = "a"

async def do():
    await Tortoise.init(db_url="sqlite://:memory:", modules={"models": ["__main__"]})
    qs = MyModel.filter(name=MyEnum.A)
    qs._make_query()
    print(qs.query)
    # expected   SELECT "id","name" FROM "mymodel" WHERE "name"='a'
    # actual     SELECT "id","name" FROM "mymodel" WHERE "name"=a

asyncio.run(do())
@long2ice
Copy link
Member

Thanks for report! Could you make a PR?

@waketzheng waketzheng linked a pull request May 26, 2024 that will close this issue
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

Successfully merging a pull request may close this issue.

2 participants