tortoise / tortoise/tortoise-orm
no such function: floor
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.6k
- Forks
- 516
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 9
Description
Describe the bug
zh: 我使用的数据库是 sqlite 执行原始 sql 语句报错
en: The database I am using is sqlite executing the original sql statement with an error This quote comes from the translation
tortoise.exceptions.OperationalError: no such function: floor
To Reproduce
sql = """SELECT *
FROM
ImgPath
WHERE
id >= ( SELECT floor( RANDOM() * ( SELECT MAX( id ) FROM ImgPath ) ) )
ORDER BY
id
LIMIT 10;"""
res = await ImgPath.raw(sql)
Expected behavior
zh: 在 Navicat 执行是正常的,在代码中出现了错误
en: Execution is fine in Navicat, there is an error in the code This quote comes from the translation
Additional context
zh: 还是看下图片,这个问题好像是 sqlite 和 python 的问题。这里有什么解决方法吗?
en: Looking at the picture again, this seems to be a problem with sqlite and python.Is there a solution here? This quote comes from the translation

Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the raw SQL in the reported Python SQLite environment and compare it with the Navicat result. Investigate whether the failure belongs to SQLite, Python's SQLite integration, or Tortoise ORM; done means identifying the responsible layer and a clearly scoped fix or documentation response.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, sqlite
- Domain
- database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100