-
-
Notifications
You must be signed in to change notification settings - Fork 436
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
When I try to filter a model by a boolean property with an sqlite DB i get this error:
Traceback (most recent call last):
File "buggy.py", line 31, in <module>
loop.run_until_complete(init())
File "/usr/lib/python3.6/asyncio/base_events.py", line 468, in run_until_complete
return future.result()
File "buggy.py", line 23, in init
result = await Tournament.filter(bool_field=True)
File "…/Code/tortoise-orm/tortoise/queryset.py", line 479, in _execute
self.query, custom_fields=list(self._annotations.keys())
File "…/Code/tortoise-orm/tortoise/backends/base/executor.py", line 24, in execute_select
raw_results = await self.connection.execute_query(str(query))
File "…/Code/tortoise-orm/tortoise/backends/sqlite/client.py", line 23, in wrapped
raise OperationalError(exc)
tortoise.exceptions.OperationalError: no such column: true
You can reproduce this bug by executing this code:
import asyncio
from tortoise import Tortoise
from tortoise.models import Model
from tortoise import fields
class Tournament(Model):
id = fields.IntField(pk=True)
bool_field = fields.BooleanField()
def __str__(self):
return self.name
async def init():
await Tortoise.init(
db_url='sqlite://:memory:',
modules={'models': ['__main__']}
)
await Tortoise.generate_schemas()
result = await Tournament.filter(bool_field=True)
await Tortoise.close_connections()
loop = asyncio.get_event_loop()
loop.run_until_complete(init())
This is the same problem on related models filters.
I was excepting a filtered queryset that contains only Tournament with bool_field
value to True
.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working